开发者

How does incr work with expiry times?

开发者 https://www.devze.com 2022-12-14 00:08 出处:网络
In memcached (appengine api implementation), how does expiration interact with incr()? There isn\'t a time argument for incr(), but what happens if I add the key with another call

In memcached (appengine api implementation), how does expiration interact with incr()? There isn't a time argument for incr(), but what happens if I add the key with another call r开发者_StackOverflow中文版ather than using the initial_value param, like so:

memcache.add('testcounter', 0, time=60*90) 
newcnt = memcache.incr('testcounter') 

will testcounter still expire in 90 minutes? Whether or not I call this again in that time?


In the memcache overview of GAE they say:

"The app can provide an expiration time when a value is stored, as either a number of seconds relative to when the value is added, or as an absolute Unix epoch time in the future (a number of seconds from midnight January 1, 1970). The value will be evicted no later than this time, though it may be evicted for other reasons." it doesn't mention modifications.

If you look at the code of memcache in google.appengine.api.memcache.init.py you'll see that neither in incr or in _incrdecr there is a call to the set_expiration_time function


The expiration time is not affected by incr.

That object will expire from the cache no later than 90 seconds after you add it regardless of the number of times you incr it.

(and, of course, it may expire sooner)

0

精彩评论

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

关注公众号