设置缓存
@param string $name
@param string $value
@param int $expired
@return mixed
439991
static public function set($name, $value, $expired = 0)
    {
        if (isset(Loader::$callback['CacheSet'])) {
            return call_user_func_array(Loader::$callback['CacheSet'], func_get_args());
        }
        $data = serialize(array('value' => $value, 'expired' => $expired > 0 ? time() + $expired : 0));
        return self::check() && file_put_contents(self::$cachepath . $name, $data);
    }
682345
public static function setx($name, $expire, $value = null){
        if (is_null($value)) {
            $value = $expire;
            $expire = null;
        }
        if(is_callable($value)) {
            $value = call_user_func($value);
        }
        else if(is_array($value)) {
            $do = $value[0];
            unset($value[0]);
            if (!strpos($do, '::')) {
                $do = explode(':',$do);
                $class = $do[0];
                $do[0] = new $class();
            }
            $value = call_user_func_array($do,$value);
        }
        self::driver()->set($name,$value,$expire);
        return $value;
    }
315246
public function set($key,$value,$expired){
		if(DEBUG_MODE){
			BDebug::message('[Memcached]: Set key('.$key.')');
			}
		$mc=$this->getMemcached();
		if(empty($mc))return false;
		$this->queries_set_count++;
		return $mc->set($key,$value,$expired);
		}
431207
public function set($key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
    {
        $expireResolution = strtolower($expireResolution);
        $expireTTL = strtolower($expireTTL);

        $condition = null;
        $ttl = 0;
        if (in_array($expireResolution, array('nx', 'xx'))) {
            $condition = $expireResolution;
            if ($expireTTL === 'ex') {
                $ttl = $flag;
            } elseif ($expireTTL === 'px') {
                $ttl = ceil($flag / 1000);
            }
        } else {
            if ($expireResolution === 'ex') {
                $ttl = $expireTTL;
            } elseif ($expireResolution === 'px') {
                $ttl = ceil($expireTTL / 1000);
            }
        }

        if ($condition === 'nx' && $this->doExists($key)) {
            return null;
        }
        if ($condition === 'xx' && !$this->doExists($key)) {
            return null;
        }

        $this->data[$key] = $value;
        if ($ttl > 0) {
            $this->expiring[$key] = $this->getTimestamp() + $ttl;
        }

        return 'OK';
    }
48092
public static function create(string $name, $value, int $expire = 1209600)
    {
        $cookieText = 'Set-Cookie: '.$name.'='.$value;
        
        $expireTime = new \DateTime;
        $expireTime->modify('+ '.$expire.' second');
        $cookieText .= '; Expires='.$expireTime->format('D, d M Y H:i:s e');
        
        $cookieText .= '; Path='.self::$path;
        $cookieText .= '; Domain='.self::$domain;
        
        if (self::$httpOnly === true) {
            $cookieText .= '; HttpOnly';
        }
        
        if (self::$secure === true) {
            $cookieText .= '; Secure';
        }
        
        if (!empty(self::$sameSite)) {
            $cookieText .= '; Samesite='.self::$sameSite;
        }
        
        header($cookieText);
    }
413901
function set($key, $value, $expire = 0)
    {
        if ($expire <= 0)
        {
            $expire = 0x7fffffff;
        }
        return $this->redis->setex($key, $expire, serialize($value));
    }
362550
public static function set($name, $value, $expire = null){
        return self::driver()->set($name,$value,$expire);
    }
1113645
public function set($key, $value, $lifetime = 7200)
    {
        if (self::$cacheSetter) {
            return call_user_func_array(self::$cacheSetter, func_get_args());
        }

        $data = array(
                 'data'       => $value,
                 'expired_at' => time() + $lifetime - 500, //XXX: 微信API是世界上最烂的，没有之一
                );

        if (!file_put_contents($this->getCacheFile($key), serialize($data))) {
            throw new Exception('Access toekn 缓存失败');
        }
    }
1048194
private function IsLegalValue($Name, $ClassName, $Value)
        {
            // 取得合法資料內容
            $ReflectionObject = new ReflectionClass($ClassName);
            $ContentList = $ReflectionObject->getConstants();
            unset($ReflectionObject);

            // 檢查是否為合法資料
            if (! in_array($Value, $ContentList)) {
                throw new Exception('Illegal '.$Name.'.');
            }
        }
750880
private function cookie($name, $value = null, $expire = 0, $domain = '', $path = '/', $secure = false)
    {
        if($value === false) {
            \Yii::$app->response->cookies->remove($name);
        } elseif($value === null) {
            return \Yii::$app->request->cookies->getValue($name);
        }

        /*$options['name'] = $name;
        $options['value'] = $value;
        $options['expire'] = $expire; //$expire?:time()+86400*365
        $options['domain'] = $domain;
        $options['path'] = $path;
        $options['secure'] = $secure;
        $cookie = new \yii\web\Cookie($options);
        \Yii::$app->response->cookies->add($cookie);*/
    }
1193983
public function result($name = null, $value = null)
    {
        if ($name === null) {
            return $this->result;
        }
        if (array_key_exists($name, $this->result)) {
            if ($value === null) {
                return $this->result[$name];
            }
            $this->result[$name] = $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;
        }
    }
159317
public function set($name, $value, $expire = null) {
        N('cache_write',1);
        if(is_null($expire)) {
            $expire  =  $this->options['expire'];
        }
        $name   =   $this->options['prefix'].$name;
        if($result = apc_store($name, $value, $expire)) {
            if($this->options['length']>0) {
                // 记录缓存队列
                $this->queue($name);
            }
        }
        return $result;
     }
638520
public function set($name, $value) {
        N('cache_write',1);
        $lh = $this->_lock();
        $val = $this->get();
        if (!is_array($val)) $val = array();
        if( C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
            //数据压缩
            $value   =   gzcompress($value,3);
        }
        $name   =   $this->options['prefix'].$name;
        $val[$name] = $value;
        $val = serialize($val);
        if($this->_write($val, $lh)) {
            if($this->options['length']>0) {
                // 记录缓存队列
                $this->queue($name);
            }
            return true;
        }
        return false;
    }
698864
public function set($name, $value, $expire = null): bool
    {
        $this->writeTimes++;

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

        if (!empty($this->tag) && !$this->has($name)) {
            $first = true;
        }

        $key    = $this->getCacheKey($name);
        $expire = $this->getExpireTime($expire);

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

        if ($expire) {
            $this->handler->setex($key, $expire, $value);
        } else {
            $this->handler->set($key, $value);
        }

        isset($first) && $this->setTagItem($key);

        return true;
    }
951244
public static function float(string $name, ?float $value = null, int $expire = 0): RedisFloat
    {
        $float = new RedisFloat(self::handle(), $name);
        if (!is_null($value)) {
            $float->set($value, $expire);
        }
        return $float;
    }
767397
public function modifyResponseCookie($response, $name, $value = null, $expiration = 0)
    {
        $expiration = 1;
        if ($expiration == 0) {
            $expiration = 30; //Expire After 30 Days
        }
        if (is_numeric($expiration)) {
            $expiration = $expiration;
        }

        $modify = function (SetCookie $setCookie) {
            $value = $setCookie->getValue();

            // ... inspect current $value and determine if $value should
            // change or if it can stay the same. in all cases, a cookie
            // should be returned from this callback...

            return $setCookie
                ->withValue($value)
                ->withExpires($expiration)
            ;
        };

        $response = FigResponseCookies::modify($response, $name, $modify);

        return $response;
    }