选择语言 :

 Driver_Cache_Driver_Apc::get

取得数据

mixed Driver_Cache_Driver_Apc::get( string/array $key )

参数列表

参数 类型 描述 默认值
$key string/array $key
返回值
  • mixed
File: ./drivers/cache/apc/apc.class.php
public function get($key)
{
    $is_array_key = is_array($key);

    if ($this->prefix)
    {
        if ($is_array_key)
        {
            $key_map = array();
            foreach ($key as &$k)
            {
                $key_map[$this->prefix . $k] = $k;
                $k = $this->prefix . $k;
            }
        }
        else
        {
            $key = $this->prefix . $key;
        }
    }

    $success = false;

    $return = apc_fetch($key, $success);

    if (false===$success)
    {
        if (IS_DEBUG)Core::debug()->error($key, 'apc cache mis key');
        return false;
    }
    else
    {
        if ($is_array_key)
        {
            if ($this->prefix)
            {
                # 有前缀,移除前缀
                $new_rs = array();
                foreach ($return as $k=>$item)
                {
                    $this->_de_format_data($item);
                    $new_rs[$key_map[$k]] = $item;
                }
                $return = $new_rs;
            }
            else
            {
                foreach ($return as &$item)
                {
                    $this->_de_format_data($item);
                }
            }
        }
        else
        {
            $this->_de_format_data($return);
        }

        if (IS_DEBUG)Core::debug()->info($key, 'apc cache hit key');
    }

    return $return;
}