src/FileCache.php
public function set($key, $value, $expire = 0)
    {
        $fileName = $this->getFileName($key);
        if (is_file($fileName)) {
            unlink($fileName);
        }
        $data = ['data' => $value, 'expire' => $expire];
        if (file_put_contents($fileName, json_encode($data))) {
            return true;
        }
        return false;
    }
public function set($key, $value, $expire = 0)
    {
        $fileName = $this->getFileName($key);
        if (is_file($fileName)) {
            unlink($fileName);
        }
        $data = ['data' => $value, 'expire' => $expire];
        if (file_put_contents($fileName, json_encode($data))) {
            return true;
        }
        return false;
    }
public function set ( $ key , $ value , $ expire = 0 ) { $ fileName = $ this -> getFileName ( $ key ) ; if ( is_file ( $ fileName ) ) { unlink ( $ fileName ) ; } $ data = [ 'data' => $ value , 'expire' => $ expire ] ; if ( file_put_contents ( $ fileName , json_encode ( $ data ) ) ) { return true ; } return false ; }
设置缓存
@param $key  缓存名称
@param $value    缓存值
@param $expire   有效时间
@return mixed
设置缓存