public function del_old()
{
$t = time();
$todel = array();
$apc_user_info = apc_cache_info('user', true);
$apc_ttl = 0;
if (!empty($apc_user_info['ttl'])) {
$apc_ttl = $apc_user_info['ttl'] / 2;
}
$i = new \APCIterator('user', null, APC_ITER_TTL + APC_ITER_KEY + APC_ITER_CTIME + APC_ITER_ATIME);
foreach ($i as $key) {
if ($key[self::apc_arr_ttl] > 0 && $t - $key[self::apc_arr_ctime] > $key[self::apc_arr_ttl]) {
$todel[] = $key[self::apc_arr_key];
} else {
//this code is necessary to prevent deletion variables from cache by apc.ttl (they deletes not by their ttl+ctime, but apc.ttl+atime)
if ($apc_ttl > 0 && $t - $key[self::apc_arr_atime] > $apc_ttl) {
apc_fetch($key[self::apc_arr_key]);
}
}
}
if (!empty($todel)) {
$r = apc_delete($todel);
if (!empty($r)) {
return $r;
} else {
return true;
}
}
return true;
}