创建一个有序集合
@param $name string 有序集合名称
@param array|null $kvs 集合成员(键值数组)
@param int $expire 过期时间(秒),默认无限
@return RedisSortedSet
326823
public static function sortedSet(string $name, ?array $kvs = null, int $expire = 0): RedisSortedSet
    {
        //创建集合对象
        $set = new RedisSortedSet(self::handle(), $name);

        //如果指定了成员,则添加成员
        if (!is_null($kvs)) {
            $set->inserts($kvs);
        }

        //设置过期时间
        $set->setExpire($expire);

        //返回有序集合对象
        return $set;
    }
376448
public function set($key, $data, $expire = 0) {
		$expire = intval($expire);
		return $this->cache->set($this->prefix.$key, $data, $expire);
	}
186438
public static function int(string $name, ?int $value = null, int $expire = 0): RedisInt
    {
        $int = new RedisInt(self::handle(), $name);

        if (!is_null($value)) {
            $int->set($value, $expire);
        }
        return $int;
    }
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;
    }
23944
public function setExpires($expires)
    {
        if (empty($expires)) {
            return $this;
        }

        $this->expires = strtotime($expires);

        return $this;
    }
1327036
public function set($key, $val, $expire = 0)
    {
        if (!is_numeric($val)) {
            $val = json_encode($val);
        }

        if ($expire) {
            return $this->redis->setex($key, $expire, $val);
        }

        return $this->redis->set($key, $val);
    }
1045473
public function setCookie($key, $name, $expires = '')
    {
        if (!$this->_cookie) {
            $this->_cookie = new Cookie();
            $this->_cookie->setVitex(Vitex::getInstance());
        }
        $this->_cookie->setCookie($key, $name, $expires);
        return $this;
    }
358055
public function getSortedSets($key, $start = 0, $limit = 20, $with_scores = true)
    {
        return $this->getSortedSetsAsc($key, $start, $limit, $with_scores);
    }
846028
public function execute($name, $args)
	{
	    if (!$this->__sock) {
	        return null;
	    }
	    
	    $args = (array) $args;
	    if(in_array($name, static::$keyCommands)) {
	        if ($this->options['prefix'] && strpos($args[0], $this->options['prefix']) === false) {
	            $args[0] = $this->options['prefix'] . $args[0];
	        }
	    }
	    
	    /* Build the Redis unified protocol command */
	    array_unshift($args, strtoupper($name));
	    $command = sprintf('*%d%s%s%s', count($args), CRLF, implode(array_map(array($this, 'formatArgument'), $args), CRLF), CRLF);
	    
	    /* Open a Redis connection and execute the command */
	    for ($written = 0; $written < strlen($command); $written += $fwrite) {
	        $fwrite = fwrite($this->__sock, substr($command, $written));
	        if ($fwrite === FALSE) {
	            throw new Exception('Failed to write entire command to stream');
	        }
	    }
	    
	    /* Parse the response based on the reply identifier */
	    $reply = trim(fgets($this->__sock, 512));
	    switch (substr($reply, 0, 1)) {
	        /* Error reply */
	        case '-':
	            throw new RedisException(substr(trim($reply), 4));
	            break;
	            /* Inline reply */
	        case '+':
	            $response = substr(trim($reply), 1);
	            break;
	            /* Bulk reply */
	        case '$':
	            $response = null;
	            if ($reply == '$-1') {
	                break;
	            }
	            $read = 0;
	            $size = substr($reply, 1);
	            do {
	                $block_size = ($size - $read) > 1024 ? 1024 : ($size - $read);
	                $response .= fread($this->__sock, $block_size);
	                $read += $block_size;
	            } while ($read < $size);
	            fread($this->__sock, 2); /* discard crlf */
	            break;
	            /* Multi-bulk reply */
	        case '*':
	            $count = substr($reply, 1);
	            if ($count == '-1') {
	                return null;
	            }
	            $response = array();
	            for ($i = 0; $i < $count; $i++) {
	                $bulk_head = trim(fgets($this->__sock, 512));
	                $size = substr($bulk_head, 1);
	                if ($size == '-1') {
	                    $response[] = null;
	                }
	                else {
	                    $read = 0;
	                    $block = "";
	                    do {
	                        $block_size = ($size - $read) > 1024 ? 1024 : ($size - $read);
	                        $block .= fread($this->__sock, $block_size);
	                        $read += $block_size;
	                    } while ($read < $size);
	                    fread($this->__sock, 2); /* discard crlf */
	                    $response[] = $block;
	                }
	            }
	            break;
	            /* Integer reply */
	        case ':':
	            $response = intval(substr(trim($reply), 1));
	            break;
	        default:
	            throw new RedisException("invalid server response: {$reply}");
	            break;
	    }
	    /* Party on */
	    return $response;
	}
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);
        }
    }
1030785
public function setExpire($expire)
    {
        if (null !== $expire) {
            $this->expire = (int) $expire;
        } else {
            $this->expire = $expire;
        }

        return $this;
    }
700287
public function hSet($hashKey, $key, $data, $expireTime = 3600)
    {
        $data = (is_object($data) || is_array($data)) ? json_encode($data) : $data;

        $data = gzdeflate($data, 0);

        if (strlen($data) > 4096) {
            $data = gzdeflate($data, 6);
        }

        $status = $this->redis->hSet($hashKey, $key, $data);

        $this->redis->expire($hashKey, $expireTime);

        return $status;
    }
1195301
public function setMulti(array $keys, $expire = 0)
    {
        $results = array();
        foreach ($keys as $key => $value) {
            $results[$key] = $this->set($key, $value, $expire);
        }
        return $results;
    }
643976
public function replace($key, $value, $expire = 0)
    {
        if (false === $this->get($key)) {
            return false;
        }
        return $this->set($key, $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;
    }
121917
public function set($key, $value, $expire = 0)
    {
        $value = json_encode($value, JSON_UNESCAPED_UNICODE);
        if ($expire > 0) {
            return $this->hash($key)->setex($key, $expire, $value);
        } else {
            return $this->hash($key)->set($key, $value);
        }
    }
660432
public function set($name, $value, $expire = 0)
    {
        $cookie_name = $this->getName($name);
        $cookie_expire = time() + ($expire ? $expire : $this->_expire);
        $cookie_value = $this->pack($value, $cookie_expire);
        $cookie_value = $this->authcode($cookie_value, 'ENCODE', $this->_securekey);

        if ($cookie_name && $cookie_value && $cookie_expire) {
            setcookie($cookie_name, $cookie_value, $cookie_expire, '/');
        }

    }