存数据
boolean Driver_Cache_Driver_File::set( string/array $key [, $data $value = null , $lifetime $lifetime = integer 3600 ] )
参数列表
参数 类型 描述 默认值 $key
string/array
支持多存 $value
$data
Value 多存时此项可空 null $lifetime
$lifetime
有效期,默认3600,即1小时,0表示最大值30天(2592000) integer 3600
boolean
public function set($key, $value = null, $lifetime = 3600)
{
if ($this->is_file_write_disalbed)return false;
if (is_array($key))
{
# 支持多存
$i=0;
foreach ($key as $k=>$v)
{
if ($this->set((string)$k, $v, $lifetime))
{
$i++;
}
}
return $i==count($key)?true:false;
}
$filename = $this->get_filename_by_key($key);
$value = $this->format_data($lifetime, $value);
return File::create_file($filename, $value, null, null, $this->storage);
}