Hi Subra,
1) Thanks, but is there an official documentation that would verify your below statement?
"Once the transaction is commited, cache will be updated with the new values and further selection will use only the cache records."
In this article
2) So first select in transaction will always do DB hit
And any "select for update" inside transaction will always do DB hit
But the cache is invalidated not when we call custTable.update() and not when we call ttscommit. The cache is invalidated directly when we do first select inside transaction?
3) So in case of
NotInTTs:
select custTable where custTable.AccountNum == '4000'; //if first select then DB hit, if already found in cache, then reads from cache
ttsbegin;
select custTable where custTable.AccountNum == '4000'; //DB hit and cache is invalidated (cache updated)
select custTable where custTable.AccountNum == '4000'; //reads latest value from cache
select forupdate custTable where custTable.AccountNum == '4000'; //DB hit and cache is invalidated (cache updated)
custTable.custGroup = "10";
custTable.update(); //DB hit and referesh cache directly?
select custTable where custTable.AccountNum == '4000'; //reads latest value from cache
select forupdate custTable where custTable.AccountNum == '4000'; //DB hit and cache is invalidated (cache updated)
custTable.custGroup = "30";
custTable.update(); DB hit and referesh cache directly?
ttscommit; //doesn't affect cache?
select custTable where custTable.AccountNum == '4000'; //reads latest value from cache
4) And in case of
Found:
select custTable where custTable.AccountNum == '4000' //if first select then DB hit, if already found in cache, then reads from cache
ttsbegin;
select custTable where custTable.AccountNum == '4000'; //reads from cache (no DB hit, different to NotInTTs and it seems like it's the only difference?)
select custTable where custTable.AccountNum == '4000'; //reads from cache
select forupdate custTable where custTable.AccountNum == '4000'; //DB hit and cache is invalidated (cache updated)
custTable.custGroup = "10";
custTable.update(); //DB hit and referesh cache directly?
select custTable where custTable.AccountNum == '4000'; //reads latest value from cache
select forupdate custTable where custTable.AccountNum == '4000'; //DB hit and cache is invalidated (cache updated)
custTable.custGroup = "30";
custTable.update(); //DB hit and referesh cache directly?
ttscommit; //doesn't affect cache?
select custTable where custTable.AccountNum == '4000'; //reads latest value from cache
I would appreciate if you can verify each comment i wrote next to each line