Retrieving the age of a given key

Randy Wigginton krw at nobugz.com
Fri Aug 18 19:47:24 UTC 2006


I do it by simply having a prefix for the date.  ie,
mc.put("DATE"+key, new Date());
mc.put(key, myObject);

Works for me, YMMV.

On Aug 18, 2006, at 12:45 PM, Anthony Volodkin wrote:

> Hi,
>
>
> Is there any way to get the age of a given key when you retrieve it  
> from memcache?
>
>
> A portion of my app currently uses disk-based caching to store the  
> HTML generated from dynamic pages.  A major update is "published"  
> on the site once an hour and at that point the code knows not to  
> use the cached files and overwrites them with new data as requests  
> come in.  This is implemented by checking modification times of the  
> cache files vs another datetime value.
>
> I want to start using memcached for this instead of the disk.
>
> To make it work, I would need to know the age of any given key.   
> Using the more-traditional expiration feature of memcached can lead  
> to having an inconsistent set of data.  It would also be very  
> difficult to flush the appropriate keys as these hourly updates are  
> published.
>
>
> What do you guys think?
>
>
> Thank you,
>
> -Anthony
>



More information about the memcached mailing list