选择语言 :

 Module_Cache::_get_adv_data

null Module_Cache::_get_adv_data( )
File: ./modules/cache/cache.class.php
protected function _get_adv_data(& $value)
{
    if (substr($value, 0, 18) == '__::foRMat_CacHe::' && preg_match('#^__::foRMat_CacHe::Type=(?P<type>[a-z0-9_]+),ExpKey=(?P<expkey>[a-f0-9]{32}),Exp=(?P<exp>[0-9,~/]+),SaveTime=(?P<savetime>[0-9]+),Value=(?P<value>.*)$#', $value, $match))
    {
        #200~250,1/100
        if (!preg_match('#^([0-9]+)~([0-9]+),([0-9]+)/([0-9]+)$#', $match['exp'], $match_exp))
        {
            return true;
        }

        switch ( $match['type'] )
        {
            case Cache::TYPE_ADV_HIT :
            case Cache::TYPE_MAX_HIT :
                # 获取命中统计数
                $exp = $this->driver->get($match['expkey']);
                break;
            case Cache::TYPE_ADV_AGE :
            case Cache::TYPE_MAX_AGE :
            default :
                $exp = TIME - $match['savetime'];
                break;
        }

        if ($exp >= $match_exp[0] && $exp <= $match_exp[1])
        {
            # 在指定范围内按比例更新
            $rand = mt_rand(1, $match_exp[3]);
            if ($rand <= $match_exp[2])
            {
                # 命中,则清除数据,让程序可主动更新
                $value = null;
                return;
            }
        }
        elseif ($exp > $match_exp[1])
        {
            # 强制认为没有获取数据
            $value = null;
            return;
        }

        if ($match['type'] == Cache::TYPE_ADV_HIT || $match['type'] == Cache::TYPE_MAX_HIT)
        {
            # 计数器增加
            $this->driver->increment($match['expkey'], 1, $match_exp[1]);
        }

        $value = @unserialize($match['value']);
    }
}