What strategies can ORM use to cache data and minimize complexity?

If an application requests a similar result set to one that was recently requested, how can the ORM keep track of which results are stale and which can be reused earlier without using too much resources (memory) or creating too much architectural complexity?

+2


source to share


2 answers


Invalidation of the cache is a very difficult issue. The basic example you propose seems to be the one that is most easily handled by the database query cache (frequent queries keep the query in the cache). As the caching strategy gets more complex, most of it will involve manual cache management and cache expiration with a separate store of cache values.

If such a thing is the norm for your application's data access and you are trying to use fancy, new things, couchdb's mapreduce views might be appropriate.



Aside from basic memoization, I tend to view ORM caching as a rather subtle and bad plan.

+2


source


When I need to know if local data is in sync with a (remote) server, I track transactions.

So, before "updating" the local data, I "query the transaction history" and if no transaction has occurred on the corresponding (remote) data since the last "update", it is still synchronized.



But I don't know if this "minimizes complexity".

+1


source







All Articles