设置缓存

@param $name
@param $value
@param $expire

@return bool
196002
public function set($name, $value, $expire) {
        if (is_null($expire)) {
            $expire = $this->options[ 'expire' ];
        }
        $filename = $this->getCacheFile($name);

        $data = serialize($value);
        if ($this->options[ 'data_compress' ] && function_exists('gzcompress')) {
            //数据压缩
            $data = gzcompress($data, 3);
        }
        $data = "<?php\n//" . sprintf('%012d', $expire) . $data . "\n?>";
        $result = file_put_contents($filename, $data);
        if ($result) {
            clearstatcache();
            return true;
        } else {
            return false;
        }
    }
773045
public function set($value,  int $expire = 0): bool
    {
        return parent::setString(json($value),  $expire);
    }
45099
public function set($name, $value,$expire=null) {
        N('cache_write',1);
        $name  = $this->options['prefix'].sqlite_escape_string($name);
        $value = sqlite_escape_string(serialize($value));
        if(is_null($expire)) {
            $expire  =  $this->options['expire'];
        }
        $expire	=	($expire==0)?0: (time()+$expire) ;//缓存有效期为0表示永久缓存
        if( C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
            //数据压缩
            $value   =   gzcompress($value,3);
        }
        $sql  = 'REPLACE INTO '.$this->options['table'].' (var, value,expire) VALUES (\''.$name.'\', \''.$value.'\', \''.$expire.'\')';
        if(sqlite_query($this->handler, $sql)){
            if($this->options['length']>0) {
                // 记录缓存队列
                $this->queue($name);
            }
            return true;
        }
        return false;
    }
405884
public function Set($name, $value, $expiry = self::OneYear, $path = '/', $domain = false)
    {

        $retval = false;
        if (!headers_sent()) {

            if ($domain === false)
                $domain = $_SERVER['HTTP_HOST'];

            if ($expiry === -1)
                $expiry = 1893456000; // Lifetime = 2030-01-01 00:00:00
            elseif (is_numeric($expiry))
                $expiry += time();
            else
                $expiry = strtotime($expiry);

            //echo "$name, $value, $expiry, $path, $domain";
            $retval = setcookie($name, $value, $expiry, $path, $domain);
            if ($retval)
                $_COOKIE[$name] = $value;

        }
        return $retval;
    }
362066
public function cofigureSession (string $name, $value) : bool
    {
        if (!property_exists($this, $name)) return FALSE;
        $allowedProperties = ['expire', 'path', 'domain', 'secure', 'httponly'];
        if (!in_array(strtolower($name), $allowedProperties)) return FALSE;
        $this->$name = $value;                
        return TRUE;
    }
224755
public function update($key, $value, $expire = 0)
    {
        $arr = $this->get($key);
        if (!empty($arr)) {
            $arr = array_merge($arr, $value);
            return $this->set($key, $arr, $expire);
        }
        return 0;
    }
594413
function set($key, $value, $expire = 0)
    {
        // 如果是对象，需要进行序列号存储
        if (is_array($value) || is_object($value)) {
            $value = serialize($value);
        }

        if ($expire > 0) {
            return $this->connection->setex($key, $expire, $value);
        } else {
            return $this->connection->set($key, $value);
        }
    }
400386
public function set($key, $value, $expire = 0)
    {
        if ($this->expire) {
            $expire = $this->expire;
        }

        return $this->handle->set($key, $value, $expire);
    }
573214
public function set(string $value, int $expire = 0): bool
    {
        return parent::setString($value, $expire);
    }
1007963
public function set($name, $value, $expire=0, $path='', $domain='', $secure=FALSE, $httponly=FALSE) {
		$_COOKIE[$name] = $this->encrypt( $value );
		return setcookie($name, $_COOKIE[$name], $expire, $path, $domain, $secure, $httponly);
	}
413901
function set($key, $value, $expire = 0)
    {
        if ($expire <= 0)
        {
            $expire = 0x7fffffff;
        }
        return $this->redis->setex($key, $expire, serialize($value));
    }
866549
public function set($name, $value,$expire=null) {
        $data   =  serialize($value);
        $name   =  $this->options['prefix'].addslashes($name);
        N('cache_write',1);
        if( C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
            //数据压缩
            $data   =   gzcompress($data,3);
        }
        if(C('DATA_CACHE_CHECK')) {//开启数据校验
            $crc  =  md5($data);
        }else {
            $crc  =  '';
        }
        if(is_null($expire)) {
            $expire  =  $this->options['expire'];
        }
        $expire	    =   ($expire==0)?0: (time()+$expire) ;//缓存有效期为0表示永久缓存
        $result     =   $this->handler->query('select `cachekey` from `'.$this->options['table'].'` where `cachekey`=\''.$name.'\' limit 0,1');
        if(!empty($result) ) {
        	//更新记录
            $result  =  $this->handler->execute('UPDATE '.$this->options['table'].' SET data=\''.$data.'\' ,datacrc=\''.$crc.'\',expire='.$expire.' WHERE `cachekey`=\''.$name.'\'');
        }else {
        	//新增记录
             $result  =  $this->handler->execute('INSERT INTO '.$this->options['table'].' (`cachekey`,`data`,`datacrc`,`expire`) VALUES (\''.$name.'\',\''.$data.'\',\''.$crc.'\','.$expire.')');
        }
        if($result) {
            if($this->options['length']>0) {
                // 记录缓存队列
                $this->queue($name);
            }
            return true;
        }else {
            return false;
        }
    }
1300805
public function set(string $key, string $value, int $expire): bool {
		$filename = $this->generateFilename($key);
		$data     = "<?php\n//" . sprintf('%012d', $expire) . sprintf('%012d', time()) . $value . "\n?>";
		return $this->filePutContents($filename, $data);
	}
1308219
public function set($key, $value, $expire = 600) {
        $this->redis->setex($this->formatKey($key), $expire, $this->formatValue($value));
    }
1355160
public function setBin(string $value, int $expire = 0): bool
    {
        return $this->setRaw(pack('H*', base_convert($value, 2, 16)), $expire);
    }
143567
public function set($name, $value, $expire = null): bool
    {
        $this->writeTimes++;

        $name = $this->getCacheKey($name);

        $value = sqlite_escape_string($this->serialize($value));

        if (is_null($expire)) {
            $expire = $this->options['expire'];
        }

        if ($expire instanceof \DateTime) {
            $expire = $expire->getTimestamp();
        } else {
            $expire = (0 == $expire) ? 0 : (time() + $expire); //缓存有效期为0表示永久缓存
        }

        if (function_exists('gzcompress')) {
            //数据压缩
            $value = gzcompress($value, 3);
        }

        if (!empty($this->tag)) {
            $tag       = current($this->tag);
            $this->tag = null;
        } else {
            $tag = '';
        }

        $sql = 'REPLACE INTO ' . $this->options['table'] . ' (var, value, expire, tag) VALUES (\'' . $name . '\', \'' . $value . '\', \'' . $expire . '\', \'' . $tag . '\')';

        if (sqlite_query($this->handler, $sql)) {
            return true;
        }

        return false;
    }
287171
public function setBytes(array $value, int $expire = 0): bool
    {
        return $this->setRaw(pack('C*', $value), $expire);
    }