开发者

php + memcache(d) extensions : possible to find when an element was set / remaining ttl?

开发者 https://www.devze.com 2023-03-30 20:45 出处:网络
when using php + memcache(d) pecl extensions, is it possible to pull the remaining lifetime of an element using one of the built in memcache(d) functions?

when using php + memcache(d) pecl extensions, is it possible to pull the remaining lifetime of an element using one of the built in memcache(d) functions?

i know this can be done by doing a full dump of the memcached base, parsing out the element one is after, and reading the timestamp. but this is a very heavy way of doing things.

another way i suppose this could be done is by setting the time added in the element itself, sort of like this:

$data=array('dateadded'=>time(),'data'=>$datatostore);

but once again, this seams slightly redundant.

btw, by memcache(d) i mean w开发者_如何转开发e have both the memcache extension installed (http://pecl.php.net/memcache) as well as the memcached one (http://pecl.php.net/memcached).

we use the memcached one for our actual code based stuff (set, read, remove, etc) and the memcache one for our sessions.

thanks!


No, this is not possible. Storing the expiration time with the data itself is probably your best bet if you need this info. See here also.

0

精彩评论

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

关注公众号