exilon / QuickLib

Quick development library (AutoMapper, LinQ, IOC Dependency Injection, MemoryCache, Scheduled tasks, Json and Yml Config and Options pattern, Serializers, etc) with crossplatform support for Delphi/Firemonkey (Windows,Linux,OSX/IOS/Android) and freepascal (Windows/Linux).
Apache License 2.0
639 stars 187 forks source link

Save TFDQuery in memory #93

Closed AndersondaCampo closed 2 years ago

AndersondaCampo commented 2 years ago

Is it possible with TMemorycache to save TFDQuery in its current state? I performed some tests and none of them got the expected result.

exilon commented 2 years ago

I think TFDQuery data is pointing to db and not really into TFDQuery object. If you want to cache db queries, you could transform this query result to a json object or objectlist. By example, your app needs list of users often. You make a query to db, then you process your data to fill a objectlist. You can cache this objectlist into TMemoryCache and avoid to query db every time.