Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is NDB query() going through the cache?

Is NDB query() going through the cache?

NDB docs mention that it will use the cache automatically. Is this only for get_by_id or also for query statements like e.g.:

Product.query().order(Product.name).fetch()

In many pages I’m displaying a Product list that’s why I want it to come from the cache.

Alternative way would be to query the Product list and store in memcache myself, but in this case Product updates will not end up in my ‘manual’ cache. Or would it be an option to store all Product id’s in the cache myself and retrieve them then via memcache/datastore. But this would require a get_by_id which accepts multiple id’s and returns a list..

like image 967
Marcel Overdijk Avatar asked Nov 13 '22 09:11

Marcel Overdijk


1 Answers

I had the same problem. Since query is not cached (at least, between diferent contexts, or this is what I understood in docs) I resolved to memcache the querys and keep it synced with my add/update/delete data.

Here was my solution for the problem. I hope it helps.

like image 142
Eagle Avatar answered Nov 14 '22 23:11

Eagle