TTL of record

Jacob Coby jcoby at listingbook.com
Tue May 10 08:27:41 PDT 2005


Pavel Francirek wrote:
> Hello,
> 
> is there any way to update record only once _before_ it expires? Or what
> about of idea of getting time-to-live of record? 
> We cache some database queries that takes seconds to get. So if memcache
> expires it takes hundreds of requests before memcache is filled again.
> We use scripts invoked by cron to fill it in shorter period than expire
> time. But it means same waste of resources (we do quetries long time
> before data expires (to be sure we even use interval several times
> shorter than expire time).

I posted a patch to the list a while back that implements the "test" 
command to test whether or not a key was set.  It returns the ts of when 
the key is set to expire.  I haven't tested this code in production, but 
maybe it can help you?

The "test" command looks something like:

set foo 0 600 1
1
STORED
get foo
VALUE foo 0 1
1
END
test foo
EXISTS foo 0 1 1108506400
END
quit

Search the archives for "test command" if you're interested. I can also 
re-post the patch.

-- 
-Jacob


More information about the memcached mailing list