开发者

Where to store a datastore cursor, in memcache or in the datastore?

In the google documentation it shows开发者_如何学运维 storing cursors in memcache, however as pointed out in an answer to this question memcache retention isn't guaranteed.

So I was wondering how other people store cursors and what strategies you use for handling missing cursors?


In the case of task queue chaining, as in the linked question, it may be best to just send the cursor in the payload for the next task (which is also mentioned in the documentation.) Memcache is fine if occasionally losing your place and starting over is acceptable. In theory if you're storing a small bit of data in memcache and using it soon afterwards it's unlikely to be evicted, although of course you should do some testing to see that you get an acceptably low rate of cache misses and watch out for situations where the memcache service being unavailable will do something really bad.


The short answer is both. Write the value to the datastore. When a read request comes in, check to see if it exists in memcache. If so, return it. If not, read it into memcache from the datastore first. This gives you the guaranteed durability of the datastore and the speed of memcache.


Of course memcache doesn`t guarantee that you will have your cursor when you call it so using datastore is better. But you must know that you have to "reset" them if you add/delete/modify entities from their kind. You must have in mind how slow this will be with memcache and datastore.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜