选择语言 :

 Driver_Cache_Driver_File::get

取得数据,支持批量取

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

参数列表

参数 类型 描述 默认值
$key string/array $key
返回值
  • mixed
File: ./drivers/cache/file/file.class.php
public function get($key)
{
    if ($this->is_file_write_disalbed)return null;

    if (is_array($key))
    {
        # 支持多取
        $data = array();
        foreach ($key as $k=>$v)
        {
            $data[$k] = $this->get((string)$v);
        }
        return $data;
    }

    $filename = $this->get_filename_by_key($key);

    if (file_exists($filename))
    {
        $data = @file_get_contents($filename);

        if ($data && $this->get_expired_setting($key, $data))
        {
            return $data;
        }
        else
        {
            # 删除失效文件
            $this->delete($key);
            return null;
        }
    }
    else
    {
        return null;
    }
}