设置一个键值
@param $value string 值
@param int $expire 生存期
@return bool 成功否
438137
public function setString(string $value, int $expire = 0): bool
    {
        $handle = $this->handle;

        //覆盖并设置生存时间
        if ($expire) {
            return $handle->setex($this->name, $expire, $value);
        }

        //仅覆盖
        return $handle->set($this->name, $value);
    }
669649
protected static function setWithLock($handle, string $value, int $expire): int {
		$data = "<?php\n//" . sprintf('%012d', $expire) . sprintf('%012d', time()) . $value . "\n?>";
		rewind($handle);  // 重置指针
		ftruncate($handle, 0); // 清空文件
		return fwrite($handle, $data);
	}
496559
public function set($name, $value, $expire = null) {
        if (is_null($expire)) {
            $expire = $this->options['expire'];
        }
        //if ($this->tag && !$this->has($name)) {
        //    $first = true;
        //}
        //$key = $this->getCacheKey($name);
        $expire = 0 == $expire ? 0 : $_SERVER['REQUEST_TIME'] + $expire;
        if ($this->handler->set($name, $value, $expire)) {
            //isset($first) && $this->setTagItem($name);
            return true;
        }
        return false;
    }
1145340
public function setWithExpire($key, $value, $expire)
    {
        if (setcookie($key, $value, time() + $expire, '/', '', false, true)) {
            return true;
        }
        return false;
    }
1030785
public function setExpire($expire)
    {
        if (null !== $expire) {
            $this->expire = (int) $expire;
        } else {
            $this->expire = $expire;
        }

        return $this;
    }
1300883
public function set($key, $value, $expire = 0)
    {
        // 如果expire为0时，设为长期有效。
        if ($expire != 0) {
            $expire = time() + $expire;
        } else {
            $expire = time() * 2;
        }

        $value = '<?php exit;?>' . $expire . serialize($value);

        // 检查目录可写否
        $cachedir = APP_PATH . '/' . Config::get("cache_dir");
        if (!is_writeable($cachedir)) {
            \show_error('ERROR: ' . $cachedir . ' is not writeable!');
        }

        return file_put_contents($this->_filename($key), $value);
    }
474271
public static function set( $key, $value, $expire = 0 ) {
		
		// set the expire date 
		if ( $expire > 0 ) {
			
			if ( $expire < time() ) {
				$expire = time() + $expire;
			}
		}
		
		CCServer::$_instance->COOKIE[$key] = $value;
		
		/*
		 * Finally set the cookie
		 * @toDo: just at the cookie to an array an set the set cookie header from the CCResponse
		 */
		return setcookie( 
			$key, 
			$value, 
			$expire, 
			static::$path, 
			static::$domain, 
			static::$secure, 
			static::$httponly 
		);
	}
643976
public function replace($key, $value, $expire = 0)
    {
        if (false === $this->get($key)) {
            return false;
        }
        return $this->set($key, $value, $expire);
    }
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);
        }
    }
144771
public function set(string $key, $value = null, int $expiration = 0) : bool
    {

        $this->updateMetaData($key, $expiration);
        $this->store[$key] = $value;

        $this->writeCount++;

        return true;
    }
1037541
public function set($key, $value, $expire = 0)
    {
        $value = '<?php exit;?>' . time() . "($expire)" . serialize($value);

        if ($this->lock) {//自增自减
            fseek($this->lock, 0);
            $return = fwrite($this->lock, $value);
            flock($this->lock, LOCK_UN);
            fclose($this->lock);
            $this->lock = false;
        } else {
            $fileName = $this->getFileName($key);
            $return = file_put_contents($fileName, $value, LOCK_EX);
        }
        $return && clearstatcache();
        return $return;
    }
287171
public function setBytes(array $value, int $expire = 0): bool
    {
        return $this->setRaw(pack('C*', $value), $expire);
    }
927450
protected function getExpireTime($expire)
    {
        if ($expire instanceof \DateTime) {
            $expire = $expire->getTimestamp() - time();
        }

        return (int) $expire;
    }
586689
public function add($key, $value, $expiration = 0)
    {
        return $this->memcached ? $this->memcached->add($key, $value, $expiration) : false;
    }
176975
public function setExpire($expire)
    {
        // 一年内认为是相对时间
        if ($expire < 31536001 && $expire != 0) {
            $expire += time();
        }

        $this->expire = $expire;
        return $this;
    }
111151
public function add($key, $value, $expiration = null)
    {

        return $this->set($key, $value, $expiration);
    }
1371909
public function set($name, $value, $expires = null)
    {
        $name = $this->getFullName($name);

        if (!is_array($value)) {
            $value = ['value' => (string) $value];
        }

        if (isset($expires)) {
            $value['expires'] = $expires;
        }

        parent::set($name, $value);

        return $this;
    }