#1 2024-05-22 14:19:19

RaelB
Member
Registered: 2010-08-04
Posts: 57

How to disable cache?

Hi,

I am working on an ajax client. The server is using a standard sqlite db, and as part of debugging, I am manually making changes to the sqlite data, which mORMot does not detect. So repeated ajax requests to the server do not reflect the changes I am making. How to disable mormot caching?

Thanks

Offline

#2 2024-05-22 17:32:23

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

Re: How to disable cache?

See https://synopse.info/forum/viewtopic.php?id=1826
and https://synopse.info/files/html/Synopse … ml#TITL_38
about caching and use from external DB.

In short, mORMot expects to own the SQLite3 database.
The other process(es) should better ask the mORMot server, via an API, to update the database.
You can disable caching, but you would loose performance and stability.

Please give some more information about your process, because it sounds a bit unclear, and I am confused about what you call client and server in your case.

Offline

#3 2024-05-22 19:29:39

RaelB
Member
Registered: 2010-08-04
Posts: 57

Re: How to disable cache?

The server is a descendant of TRestServerDB, using a standard sqlite db, in turn served by a TRestHttpServer. The client is an ajax javascript application, but you could also just say using postman, i.e sending get/post http requests to the server.

ab wrote:

You can disable caching, but you would loose performance and stability.

Right, this is just for a particular debugging scenario, where the cache is getting in the way, or could be getting in the way, and I want to disable it temporarily. Stopping and restarting the application, can be slow, and it would just be faster if I can disable the cache. From the docs it sounds like it is at the "Database" or SQL level.

A TSynCache instance is instantiated within the TSQLDataBase internal global instance,

I seem to have missed it before, but now I see I can access the DB property of the server, so looks like I can disable with

constructor TSampleServer.Create(aModel: TOrmModel; const aDBFileName:
    TFileName);
begin
  inherited Create(AModel, ADBFileName, True);

  Self.DB.UseCache := False;

works smile

Offline

#4 2024-05-22 19:36:48

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

Re: How to disable cache?

Also ensure you keep 

  DB.LockingMode := lmNormal;

Offline

Board footer

Powered by FluxBB