Reset lifetime of a cached file
@param mixed $key
@param int $expiration
@return sFire\Cache\Cache
485943
public function touch($key, $expiration = null) {

    	if(null !== $expiration && false === ('-' . intval($expiration) == '-' . $expiration)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($expiration)), E_USER_ERROR);
		}

		$this -> call() -> touch($key, $expiration);
		return $this;
    }
186398
public function cache($context, string $key, $value = '', int $expire = 0)
    {
        if ($value === '') {
            $commandData = [$context, $key];
            $command = 'get';
        } else {
            if (!empty($expire)) {
                $command = 'setex';
                $commandData = [$context, $key, $expire, $value];
            } else {
                $command = 'set';
                $commandData = [$context, $key, $value];
            }
        }

        return $this->__call($command, $commandData);
    }
259490
public function set($key, $value, $expiration = 0)
    {
        $key = $this->createKey($key);
        $this->instance->set($key, $value, $expiration);
        return $this;
    }
313601
public function set($key, $value, $expire = 0)
    {
        ($expire == 0) && $expire = null;
        return apc_store($this->conf['prefix'] . $key, $value, $expire);
    }
889181
public function expire(Memento\Key $key = null)
    {
        $expiresFile = $this->getExpiresPath($key) . DIRECTORY_SEPARATOR . self::FILENAME_EXPIRES;

        $bytes = 0;
        $now = time();
        $expires = $now;
        if (file_exists(dirname($expiresFile))) {
            $bytes = file_put_contents($expiresFile, $expires, LOCK_EX);
        }

        return ($bytes > 0);
    }
1057436
public function set($key, $value, $expiration = 0)
    {
        $file = $this->cacheDir . $this->getDir($key) . $this->getFile($key);

        if (!file_exists(dirname($file))) {
            mkdir(dirname($file), 0755, true);
        }

        $return = file_put_contents($file, $value);
        touch($file, time() + $expiration);

        return $return;
    }
983231
public function openCache($expire = 3600) {
        $this->allowCache = $expire !== false;
        $this->cacheLife = $expire;
        return $this;
    }
918586
public function cache($key=true,$expire=null,$type=''){
        // 增加快捷调用方式 cache(10) 等同于 cache(true, 10)
        if(is_numeric($key) && is_null($expire)){
            $expire = $key;
            $key    = true;
        }
        if(false !== $key)
            $this->options['cache']  =  array('key'=>$key,'expire'=>$expire,'type'=>$type);
        return $this;
    }
1333420
public function setMulti($items, $expiration = 0)
    {
        return $this->memcached ? $this->memcached->setMulti($items, $expiration) : false;
    }
265302
public function file_cache($key,$value=null,$expire=70,$prefix=''){
        if (empty($key)) return false;
        $option = array(
            'type'=>'File',
            'prefix'=>$prefix,
            'path'=>CACHE_PATH,
        );
        $expire = empty($expire)?0:$expire;
        $cache = \think\Cache::connect($option);
        if ($value){
            return $cache->set($key,$value,$expire);
        }else{
            return $cache->rm($key);
        }
    }
150723
public function set($key, $content, $expiry = 0)
    {
        $cacheObj = new \stdClass();

        if (!is_string($content)) {
            $content = serialize($content);
        }

        $cacheObj->content = $content;

        if (!$expiry) {
            // If no expiry specified, set to 'Never' expire timestamp (+10 years)
            $cacheObj->expiryTimestamp = time() + 315360000;
        } elseif ($expiry > 2592000) {
            // For value greater than 30 days, interpret as timestamp
            $cacheObj->expiryTimestamp = $expiry;
        } else {
            // Else, interpret as number of seconds
            $cacheObj->expiryTimestamp = time() + $expiry;
        }

        // Do not save if cache has already expired
        if ($cacheObj->expiryTimestamp < time()) {
            $this->delete($key);

            return false;
        }

        $cacheFileData = json_encode($cacheObj);

        if ($this->config['gzipCompression']) {
            $cacheFileData = gzcompress($cacheFileData);
        }

        $filePath = $this->getFilePathFromKey($key);
        $result = file_put_contents($filePath, $cacheFileData);

        return $result ? true : false;
    }
586689
public function add($key, $value, $expiration = 0)
    {
        return $this->memcached ? $this->memcached->add($key, $value, $expiration) : false;
    }
761904
public static function set(string $key, $value = null, int $expiration = 0): ?Cache
    {
        if (!self::$instance) {
            return null;
        }

        self::$instance->engine->set($key, $value, $expiration);

        return self::$instance;
    }
296336
public function setCache($key, $data, $lifetimeInSeconds = false)
    {
        if ($this->sqlInitialized()) {
            if ($this->sql) {
                /* escape query data */
                $_key = $this->sql->real_escape_string($key);
                $_data = $this->sql->real_escape_string(serialize($data));
                $_expire = $this->getExpirationTimestamp($lifetimeInSeconds);

                $response = $this->sql->query("
                    SELECT *
                        FROM `{$this->table}`
                        WHERE
                            `{$this->key}` = '$_key'
                ");
                if ($response->fetch_assoc()) {
                    if ($this->sql->query("
                        UPDATE
                            `{$this->table}`
                            SET
                                `{$this->cache}` = '$_data',
                                `expire` = " . ($_expire === false ? 'NULL' : "'$_expire'") . "
                            WHERE
                                `{$this->key}` = '$_key'
                    ")) {
                        return true;
                    } else {
                        throw new SimpleCache_Exception(
                            'Could not update existing cache data. ' . $this->sql->error,
                            SimpleCache_Exception::CACHE_WRITE
                        );
                    }
                } elseif ($this->sql->query("
                    INSERT
                        INTO `{$this->table}`
                        (
                            `{$this->key}`,
                            `{$this->cache}`
                            " . ($_expire === false ? '' : ", `expire`") . "
                        ) VALUES (
                            '$_key',
                            '$_data'
                            " . ($_expire === false ? '' : ", '$_expire'") . "
                        )
                ")) {
                    return true;
                } else {
                    throw new SimpleCache_Exception(
                        'Could not insert new cache data. ' . $this->sql->error,
                        SimpleCache_Exception::CACHE_WRITE
                    );
                }
            }
            return false;
        }
    }
884127
protected function doSet(string $key, $data, int $expire = self::EXPIRE): bool
    {
        /**
         * @var $handle \Memcache|\Memcached
         */
        $handle = $this->_handle;

        // 缓存数据
        return $handle->set($key, $data, MEMCACHE_COMPRESSED, $expire);
    }
111151
public function add($key, $value, $expiration = null)
    {

        return $this->set($key, $value, $expiration);
    }
284821
public static function expire(string $key)
        {
            if (($cacheValue = self::GetInstance()->get("\$vxnKey:{$key}")) === false) {
                return false;
            }

            return $cacheValue['$_expire'];
        }