Memcache expiration

69 views
Skip to first unread message

Pertti Kellomäki

unread,
Jun 3, 2013, 9:08:01 AM6/3/13
to google-a...@googlegroups.com
Hi all,

I have never used the app engine memcache before, so I would like to double check that I understand how expiration works.

I maintain a bit of state in memcache for each client, and I want the state to hang around as long as the client is alive, but go away after that. Reading the docs suggests that expiration is solely determined by insertion/update operations, so my client does a periodic .cas() on the state to move the expiration deadline forward. 

Is this a sensible implementation on app engine? My app is in Python if that makes a difference.

The background is that clients poll for new events posted on the server. New events are inserted in event queues in memcache for each client, with a fallback of reading the events from datastore.
-- 
Pertti

timh

unread,
Jun 3, 2013, 9:48:33 AM6/3/13
to google-a...@googlegroups.com
The main thing to remember is memcache on appengine is not reliable, Despite any deadline you set, items in memcache can be purged/removed by google infrastructure at any point and you have no control over that.  Having said that relatively short periods 30 minutes for expiration tend to be ok. Though some times apps have at times very short life spans for data in memcache

T

Pertti Kellomäki

unread,
Jun 3, 2013, 10:18:14 AM6/3/13
to google-a...@googlegroups.com
Thanks. In my case the memcache entry reflects what would be the result of a particular datastore query, so if the entry is purged the datastore query can always be run.

Pertti


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Vinny P

unread,
Jun 4, 2013, 10:55:52 AM6/4/13
to google-a...@googlegroups.com
On Monday, June 3, 2013 9:18:14 AM UTC-5, Pertti Kellomäki wrote:
In my case the memcache entry reflects what would be the result of a particular datastore query, so if the entry is purged the datastore query can always be run.


That is exactly the recommended best practice way to use the memcache + datastore, so your implementation is great!

-----------------
-Vinny P
Technology & Media Advisor
Chicago, IL

My Go side project: http://invalidmail.com/

Pertti Kellomäki

unread,
Jun 4, 2013, 11:04:38 AM6/4/13
to google-a...@googlegroups.com
Glad to hear that ;-)

Pertti


Reply all
Reply to author
Forward
0 new messages