Google App Engine ndb memcache when to use memcache
One case would be inside a transaction in which you want to read some related entity values but you don't care about accessing those particular entities consistently or not (in the context of that transaction).
In such case reading from the datastore would unnecessarily include those related entities in the transaction which contributes to datastore contention and could potentially cause exceeding various per-transaction limits.
Reading memcached values for those related entities instead would not include the entities in the transaction itself. Now I'm not 100% certain if this is applicable to ndb's memcache copy of an entity (I don't even know how to access that), I used my own memcache copies of such entities, updated whenever I modify these entities.
If read/writes into the ndb datastore automatically caches both in-context and via memcache, in what cases would you want to call the memcache api directly (in the context of the datastore)?
To elaborate, would I ever need to set the memcache for a particular datatstore read/write and get reads from the memcache instead of the datastore directly?