#1 2023-03-24 21:56:48

w0rker
Member
Registered: 2021-03-19
Posts: 5

Temporary in-memory storage with TSQLRestTempStorage

Hello,
I've seen TSQLRestTempStorage in the code but I'm unsure how to use it.
Right now, we use a TSQLRestClientDB with SQLite3 but we would like to write the data asynchronously into the DB from a TThread.

1. Would you recommend using TSQLRestTempStorage to speed-up writing data and reading data (99,999% of the time we need only the data from past 5min; checking if entry exist and add if not)?
2. What do we need to change in our existing code?
3. If I understood it correctly, it'll hold the old and new data in memory (RAM) and then write it from time to time into the SQLite database (based on own coded TThread with sleep time)?
4. Is this also available in mORMot2?

Thanks in advance and a nice weekend!

Last edited by w0rker (2023-03-24 22:04:51)

Offline

#2 2023-03-25 08:15:37

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

Re: Temporary in-memory storage with TSQLRestTempStorage

Usually we use a REST background method,  and a batch for this purpose. The batch will speed up the insertion.
It works for both mORMot 1 and mORMot 2.

But I may add an automated way to do it in mORMot 2, since it is a common pattern.

Offline

#3 2023-04-15 20:37:58

w0rker
Member
Registered: 2021-03-19
Posts: 5

Re: Temporary in-memory storage with TSQLRestTempStorage

ab wrote:

Usually we use a REST background method,  and a batch for this purpose. The batch will speed up the insertion.
It works for both mORMot 1 and mORMot 2.

What do you mean? Could you please give an example.

ab wrote:

But I may add an automated way to do it in mORMot 2, since it is a common pattern.

Good idea to have an automated way!

And could you maybe also give some answers to my questions above? Thanks smile

Offline

#4 2023-05-19 19:25:48

w0rker
Member
Registered: 2021-03-19
Posts: 5

Re: Temporary in-memory storage with TSQLRestTempStorage

@ab ?

Offline

#5 2023-05-19 20:22:43

tbo
Member
Registered: 2015-04-20
Posts: 335

Re: Temporary in-memory storage with TSQLRestTempStorage

An example for a batch can be found here (mORMot 2). For a background process search for TSynBackgroundTimer/TSQLRestBackgroundTimer in mORMot source code. All information on how to use it can be found in the help description of the class.

With best regards
Thomas

Offline

Board footer

Powered by FluxBB