设置
@param $key
@param $value
@param int $expire
@return bool
163337
function set($key, $value, $expire = 0)
    {
        if ($this->memcached)
        {
            return $this->cache->set($key, $value, $expire);
        }
        else
        {
            return $this->cache->set($key, $value, $this->flags, $expire);
        }
    }
20307
public function store($key, $value, $expiration = 0)
    {
        // $this->getTimeout(); Do delete based on the session time out
        $data = [
            'time'   => time(),
            'expire' => $expiration,
            'data'   => $value,
        ];

        if ($this->where == true) {
            $this->setCache($key)
                 ->setPath(CYGNITE_BASE.DS.toPath('public.storage.cache').DS);
        }

        if (is_array($this->getCache())) {
            $array = $this->getCache();
            $array[$key] = $data;
        } else {
            $array = [$key => $data];
        }

        $cacheData = json_encode($array);

        if ($this->getDirectory() == true) {
            @file_put_contents($this->getDirectory(), $cacheData);
        }

        return $this;
    }
391185
public function set($name, $value, $expire = null) {
        if (is_null($expire)) {
            $expire = $this->options['expire'];
        }
        //$key = $name;
        //对数组/对象数据进行缓存处理，保证数据完整性
        $value = (is_object($value) || is_array($value)) ? json_encode($value) : $value;
        if (is_int($expire) && $expire) {
            $result = $this->handler->setex($name, $expire, $value);
        }
        else {
            $result = $this->handler->set($name, $value);
        }
        return $result;
    }
374508
public function set($key, $value = null, $expiration = 0)
    {
        if (apc_store($key, $value, ($expiration ? $expiration : null))) {
            $expiration = (empty ($expiration)) ? 0 : $expiration;

            // Prepare Listing
            $newListing = array(
                'key'        => ( string )$key,
                'expiration' => ( int )$expiration,
                'updated'    => ( string )date('Y-m-d H:i:s')
            );

            if (isset ($this->cacheListing [$key])) {
                $this->cacheListing [$key] = array_merge($this->cacheListing [$key], $newListing);
            } else {
                $newListing ['created']    = $newListing ['updated'];
                $this->cacheListing [$key] = $newListing;
            }

            $this->saveCacheListing();

            return true;
        }

        return false;
    }
785723
public function setRaw(string $value, int $expire = 0): bool
    {
        return parent::setString($value, $expire);
    }
83498
public function decrement($key, $value = 1, $expiration = 0)
    {
        $new = intval($this->get($key));
        $new -= $value;
        $this->set($key, $new, $expiration);
    }
603420
public static function cache($name, $value = '', $expires = 0)
    {
        if (!$name || !is_string($name)) {
            self::setError('参数错误!');

            return false;
        }

        /** @var BaseDriver $cacheDriver */
        static $cacheDriver;

        if (!isset($cacheDriver)) {
            $cacheDriver = __NAMESPACE__ . '\\CacheDriver\\' . self::$CACHE_DRIVER . 'Driver';
            $cacheDriver = new $cacheDriver(__DIR__ . '/Cache/');
        }

        if (!$value && $value !== 0) {
            $value = $cacheDriver->_get($name);
            if (false == $value) {
                $value = null;
            }

            return $value;
        }

        $res = $cacheDriver->_set($name, $value, $expires);

        return $res ? true : false;
    }
144771
public function set(string $key, $value = null, int $expiration = 0) : bool
    {

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

        $this->writeCount++;

        return true;
    }
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);
    }
586689
public function add($key, $value, $expiration = 0)
    {
        return $this->memcached ? $this->memcached->add($key, $value, $expiration) : 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);
        }
    }
1253697
public function add($key, $value, $expiration = null)
    {
        if (null !== $this->logger) {
            $this->logger->startMethod('add', ['key' => $key, 'value' => $value, 'expiration' => $expiration]);
        }

        if (!$this->assertConnected()) {
            $this->setResultFailed(5); // \Memcached::RES_WRITE_FAILURE
            $this->stopMethod();

            return false;
        }

        if (!$this->assertKey($key)) {
            $this->stopMethod();

            return false;
        }

        $key = $this->getPrefix().$key;
        $this->checkForDelayedDelete($key);
        if (!$this->assertHasNotInDeleteQueue($key)) {
            $this->setResultFailed(12); // \Memcached::RES_DATA_EXISTS doc states \Memcached::RES_NOTSTORED :(
            $this->stopMethod();

            return false;
        }

        if (!$this->assertHasNotInCache($key)) {
            $this->setResultFailed(12); // \Memcached::RES_DATA_EXISTS doc states \Memcached::RES_NOTSTORED :(
            $this->stopMethod();

            return false;
        }

        if (!$this->assertValue($value)) {
            $this->stopMethod();

            return false;
        }

        if (!$this->assertExpiration($expiration)) {
            $this->stopMethod();

            return false;
        }

        $this->storeValueInCache($key, $value, $expiration);
        $this->setResultOK();
        $this->stopMethod();

        return true;
    }
362550
public static function set($name, $value, $expire = null){
        return self::driver()->set($name,$value,$expire);
    }
1049324
public function set(string $key, $value, int $expire = null): bool {
		if ($value instanceof Closure) {
			$value = $value();
		}
		return $this->driver->set($key, static::serialize($value), $expire ?? $this->expire);
	}
1143030
protected function setCookie($key, $value = null, $expire = 0)
    {
        if ($value === null) {
            Arr::forget($_COOKIE, $key);
        } else {
            if ($this->defaults['encrypt']) {
                $value = $this->getEncryption()->encryptBase64($value);
            }

            Arr::set($_COOKIE, $key, $value);
        }

        setcookie(
            $key,
            $value,
            $expire,
            $this->defaults['path'],
            $this->defaults['domain'],
            $this->defaults['secure'],
            $this->defaults['httponly']
        );
    }
1259513
protected function appendValue($key, $value, $expiration = 0)
    {
        if ($this->redis->exists($key)) {
            $this->redis->append($key, $value);

            return $this->redis->expire($key, $expiration);
        }

        return $this->redis->setex($key, $expiration, $value);
    }
1109951
public function set(string $field, string $key, $data, int $expire = 0): bool
    {
        // 缓存数据
        $this->doSet($key, $data, $expire);

        //记录调试信息
        self::debugSet($field . ':' . $key, $data);

        //生成FIELD对象
        $field = Redis::list(self::PREFIX . self::PREFIX_FIELD . $field);

        //向FIELD中增加一个键
        $field->append($key);
        return true;
    }