#1 2021-04-08 12:19:10

turkerali
Member
Registered: 2021-03-30
Posts: 10

Mormot external table caching seems broken

Hi forum members,

I am using Mormot framework with an external MySQL database. I have a very small table
which never changes. So I am trying to activate table cache for this particular table with the
following code:

aetRestServerDB := TSQLRestServerDB.Create(aetDBSchema, ':memory:', false);
aetRestServerDB.CreateMissingTables(0);
aetRestServerDB.Cache.SetCache(TSQLDriveRecord);

Then I retrieve the contents of this external table directly in JSON format, via the SOA method as follows:

procedure TMyRestServer.mysql_test(Ctxt: TSQLRestServerURIContext);
begin
   // ALTERNATIVE 1
   Ctxt.Returns(aetRestServerDB.RetrieveListJSON(TSQLDriveRecord,'',''));

   // ALTERNATIVE 2
   //Ctxt.Returns(VariantSaveJson(aetRestServerDB.RetrieveDocVariantArray(TSQLDriveRecord,'','')));
end;

Whether I activate the cache or not, when I benchmark the above method with ab, I always get around 4,000 req/s (with both ALTERNATIVE 1 and 2).
Therefore the cache seems not working. Is there another method to retrieve all the records at once in JSON from the cache?
Please note that the table I would like to cache is an external table.

Thanks in advance.

Offline

#2 2021-04-09 07:32:45

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Mormot external table caching seems broken

The cache is for individual records, i.e. for lookup by ID, not for lists.
It is clearly stated by the documentation.

Then there is a cache at SQLite3 level, but there is no cache for direct external DB access, with no virtual table.

Online

Board footer

Powered by FluxBB