views:

99

answers:

3

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?

A: 

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.

Ilian Iliev
+2  A: 

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.

Drew Sears
You get the speed for reading only. If you read as much as you write, it's actually a slow down :)
Matthieu M.
+2  A: 

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.

Wooble