Jamm\Memory\APCObject::del_old PHP Метод

del_old() публичный Метод

Delete old (by ttl) variables from storage It's very important function to prevent APC's cache fragmentation.
public del_old ( ) : boolean
Результат boolean
    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;
    }