You are not logged in.
Pages: 1
hi, ab:
is it possibly to change TSqlDataBase.LockJson in mormot.db.raw.sqlite3.pas code as follow:
from:
fSafe.Lock; // cache access is also protected by fSafe
try
if IsCacheable(aSql) then
begin
result := fCache.Find(aSql, aResultCount); // try to get JSON result from cache
if result <> '' then
begin
if fLog <> nil then
begin
fLog.Add.Log(sllSQL, 'from cache % %', [FileNameWithoutPath, aSql], self);
fLog.Add.Log(sllResult, result, self, fLogResultMaximumSize);
end;
fSafe.UnLock; // found in cache -> leave critical section <-------- from here
end;
end
else
begin
// UPDATE, INSERT or any non SELECT statement
CacheFlush;
result := '';
end;
except
...;
end;
to
fSafe.Lock; // cache access is also protected by fSafe
try
if IsCacheable(aSql) then
begin
result := fCache.Find(aSql, aResultCount); // try to get JSON result from cache
if result <> '' then
begin
if fLog <> nil then
begin
fLog.Add.Log(sllSQL, 'from cache % %', [FileNameWithoutPath, aSql], self);
fLog.Add.Log(sllResult, result, self, fLogResultMaximumSize);
end;
end;
end
else
begin
// UPDATE, INSERT or any non SELECT statement
CacheFlush;
result := '';
end;
except
...;
end;
fSafe.UnLock; // found in cache -> leave critical section <------- to here
thanks for your great job!
Offline
I don't think so: caller is responsible for calling UnLockJson if the function returns '', i.e. the result was not found in cache.
Please follow the forum rules and don't post code here in the forum.
A github pull request is easier to follow and merge.
Offline
Please follow the forum rules and don't post code here in the forum.
sorry about that.
already got to run, thanks again!
Offline
Pages: 1