note 70896 modified in function.apc-store by danbrown
| From: | danbrown@php.net | Date: | Thu, 18 Feb 2010 14:28:33 +0000 |
| Subject: | note 70896 modified in function.apc-store by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166132@lists.php.net to get a copy of this message | ||
Seems to be no (easy) way at the to know how old a value fetched is and to check whether it is out
of date.
I've made these wrappers so that you can fetch and store values based on a udt returned from
get_last_modified_date() which should return a udt of when your data was last changed, and hence
needs junking out of the cache.
<?php
function apc_fetch_udt($key){
$g = apc_fetch($key);
if ($g){
list($udt,$val) = $g;
if (get_last_modified_date()<$udt) {
$val = unserialize($val);
return $val;
} else {
apc_delete($key);
}
}
}
function apc_store_udt($key,$g){
$udt = time();
$g = serialize($g);
$apc = array($udt,$g);
apc_store($key, $apc);
}
?>
--was--
Seems to be no (easy) way at the to know how old a value fetched is and to check whether it is out
of date.
I've made these wrappers so that you can fetch and store values based on a udt returned from
get_last_modified_date() which should return a udt of when your data was last changed, and hence
needs junking out of the cache.
function apc_fetch_udt($key){
$g = apc_fetch($key);
if ($g){
list($udt,$val) = $g;
if (get_last_modified_date()<$udt) {
$val = unserialize($val);
return $val;
} else {
apc_delete($key);
}
}
}
function apc_store_udt($key,$g){
$udt = time();
$g = serialize($g);
$apc = array($udt,$g);
apc_store($key, $apc);
}
http://php.net/manual/en/function.apc-store.php