What you're describing is more of the behavior of the LRU part of the cache, 
which is not directly exposed to clients. Each time a key is accessed, it is 
moved to the front of the LRU list so it will be the last to be evicted, but 
this does not affect expiration time.

I don't know of a way to update expiration time on get -- I expect it doesn't 
exist because updating an item can be quite a bit more expensive than fetching 
an item due to the need to acquire additional locks when doing the write.

Probably doing a probabilistic touch after each get (say 10% of the time) would 
be sufficient for your needs, but only touching the key after each get would 
guarantee the behavior you're looking for.

~Ryan (mobile)

> On Jun 16, 2014, at 4:44 PM, Caroline Beltran <[email protected]> 
> wrote:
> 
> Ryan, thank you for your suggestion, I looked at the link you sent and I 
> think that does what I would need.  If I understand correctly, my application 
> would periodically issue a 'touch' causing memcached to forward the 
> expiration time.
> 
> Just out of curiosity, do you know if it is possible for memcached to 
> automatically touch itself after every time a key is looked up?  Thanks again.
> 
>> On Monday, June 16, 2014 3:38:16 PM UTC-5, Ryan McElroy wrote:
>> Check out the touch command here: 
>> https://github.com/memcached/memcached/blob/master/doc/protocol.txt
>> 
>> It lets you update expiration time and should work for your purpose.
>> 
>> ~Ryan (mobile)
>> 
>>> On Jun 16, 2014, at 3:22 PM, Caroline Beltran <[email protected]> 
>>> wrote:
>>> 
>>> I am thinking about using Memcache and have read that you can set an 
>>> expiration time for your items but an expiry is not a good option for 
>>> storing sessions keys (in my opinion) because I don't want sessions to 
>>> expire after a pre-specified time such as 30 minutes.
>>> 
>>> Instead, I want sessions to expire 30 minutes after the last session 
>>> activity. So for example, I want the session to remain in cache for the 
>>> duration of the user's visit end 30 minutes after the web browser is closed.
>>> 
>>> 
>>> Please advise if Memcache would allow me to do this. Thank you.
>>> 
>>> -- 
>>> 
>>> --- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "memcached" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "memcached" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to