1
votes

I have several appengine entities that are frequently read at different places of my applications and not so frequently updated.

I'd like to use memcache to reduce the number of datastore reads of my app, but i don't really want to update my code everywhere.

I was wondering if there is a decent way to override the get() method of my entity to check if we stored it in memcache before doing a datastore read, and use put() to delete this memcache entry.

Does someone have a good solution for that ?

1
If you are using NDB then memcache is already being used. If you aren't using NDB you should consider doing so.Tim Hoffman
NDB seems to be indeed a good solution, but i guess it will be quite a work to update all my entities from db to ndb in production... I'm looking for a "quick optimization" solution here.Sebastien
Take you pick, change your code - say with decorators or move to NDB. Alternately look at hooks on the model, but that's not so easy with db.Tim Hoffman

1 Answers

2
votes

If you're not using NDB, use NDB. Your data won't change, just the way you interface with the datastore will. NDB entities are automatically cached so any requests by key are searched for in memcache first and then the datastore if the entity is not found.

NDB is the new standard anyways, so you might as well switch now instead of later.