#1 2012-02-14 15:39:28

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

ORM Cache

Here is the definition of "cache", as stated by Wikipedia:

In computer engineering, a cache is a component that transparently stores data so that future requests for that data can be served faster. The data that is stored within a cache might be values that have been computed earlier or duplicates of original values that are stored elsewhere. If requested data is contained in the cache (cache hit), this request can be served by simply reading the cache, which is comparatively faster. Otherwise (cache miss), the data has to be recomputed or fetched from its original storage location, which is comparatively slower. Hence, the greater the number of requests that can be served from the cache, the faster the overall system performance becomes.

To be cost efficient and to enable an efficient use of data, caches are relatively small. Nevertheless, caches have proven themselves in many areas of computing because access patterns in typical computer applications have locality of reference. References exhibit temporal locality if data is requested again that has been recently requested already. References exhibit spatial locality if data is requested that is physically stored close to data that has been requested already.

In our ORM framework, since performance was one goal since the beginning, cache has been implemented at four levels:
- Statement cache for reuse of SQL prepared statements, and bound parameters on the fly - note that this cache is available not only for the SQlite3 database engine, but also for any external engine;
- Global JSON result cache at the database level, which is flushed globally on any INSERT / UPDATE;
- Tuned record cache at the CRUD/RESTful level for specified tables or records on the server side;
- Tuned record cache at the CRUD/RESTful level for specified tables or records on the client side.

The last two caches are in fact shared at the TSQLRest level. A dedicated TSQLRestCache instance can be created, and will maintain such a tuned caching mechanism.

Comments from blog article http://blog.synopse.info/post/2012/02/14/ORM-cache

Offline

#2 2012-02-21 12:52:13

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

Re: ORM Cache

I've updated the documentation about caching (including new diagrams), and added TSQLRestCache.SetCache(aRecord: TSQLRecord) overloaded method.

See http://synopse.info/fossil/info/efa16a1cc7

Offline

Board footer

Powered by FluxBB