-
Notifications
You must be signed in to change notification settings - Fork 27
Support saving of entities to memcache in putMulti() #58
Copy link
Copy link
Open
Description
If I got it right currently entities are not stored to memcache on Put().
Suppose we run in transaction and need to update some entities. Then current execution order is:
- User code calss nds.RunInTransaction()
- Get entity by key from datastore (not stored to memcache)
- Change entities
- User code calls nds.PutMulti() with transactional context
- nds.putMulti() add items to tx.lockMemcacheItems (memcache not changed)
- nds.putMulti() call datastorePutMulti()
- nds.putMulti() executes deferrer that removes from memcache tx.lockMemcacheItems.
First of all it's not clear why we create lockItem() at line 129 as it seems it is not used further in current implementation.
Second just removing items from memcache results in unnecessary paid Get() operation on following request while potentially results could be retrieved from the "free" memcache. For example I have a chat application and whenever user writes to the bot and bot sends response I do following:
- On request Chat entity is retrieved outside of transaction
- On response Chat entity updated within transaction (if state changed)
Currently the firstGet()is not leveraging memcache with always a miss. This increases response time & costs.
So the suggestion is:
- Before putting
ndsshould try to lock items in memcache. - If previous pre-put locks was successful
ndstries to put items to memcaches using CAS. - If lock or putting to memcache failed try delete from memcache as currently.
- Not related improvement: If delete from memcache failed create a deferred task for removing items from memcache. That could mitigate temporarily memcache unavailability.
I know caching is hard to get right and probably I'm missing something.
edit: fixed urls to permalinks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels