如果缓存类型是 redis可以获取redis 使用完成后请记得释放
@return null|\Redis
353955
public static function redis() {
        $redisCache = self::getCache();
        if ($redisCache instanceof RedisCache) {
            $redisCache->open();
            return $redisCache->redis;
        }
        return null;
    }
1159195
protected function redis($redis = '')
    {
        $redis = $redis ? $redis : $this->use_redis;

        return Redis::getInstance($redis);
    }
981780
public function getBytes()
    {
        if ($this->isDirty && $this->bytes) {
            return $this->bytes;
        }
        if ($this->isDirty && $this->filename) {
            return file_get_contents($this->filename);
        }
        if ($this->mongoGridFSFile instanceof \MongoGridFSFile) {
            return $this->mongoGridFSFile->getBytes();
        }
        return null;
    }
937049
public static function getBackend()
	{
		if(self::$backend === null) {
			require  dirname(__FILE__) . '/Failure/Redis.php';
			self::$backend = 'Resque_Failure_Redis';
		}

		return self::$backend;
	}
725125
protected function hitRedis()
    {
        $lua = 'local v = redis.call(\'incr\', KEYS[1]) '.
               'if v>1 then return v '.
               'else redis.call(\'setex\', KEYS[1], ARGV[1], 1) return 1 end';

        $this->number = $this->store->connection()->eval($lua, 1, $this->computeRedisKey(), $this->time * 60);

        return $this;
    }
361566
public function connect() {
        $count = 0;
        do {
            $count += 1;
            try {
                if ($this->isPersistent()) {
                    $result = $this->Redis->pconnect($this->getHost(), $this->getPort(), $this->getConnectTimeout());
                } else {
                    $result = $this->Redis->connect($this->getHost(), $this->getPort(), $this->getConnectTimeout());
                }
            } catch (RedisException $ex) {
                throw new ConnectException();
            }
            if ($result === true) {
                return true;
            }
        } while ($count < $this->getConnectTries());

        $this->Redis = null;
        throw new TriesOverConnectException();
    }
441688
public function index()
    {
        return Admin::content(function (Content $content) {
            $content->header('Redis manager');
            $content->description('Connections');
            $content->breadcrumb(['text' => 'Redis manager']);

            $connection = request('conn', 'default');

            $manager = $this->manager();

            $variables = [
                'conn'        => $connection,
                'info'        => $manager->getInformation(),
                'connections' => $manager->getConnections(),
                'keys'        => $manager->scan(
                    request('pattern', '*'),
                    request('count', 50)
                ),
            ];

            $content->body(view('laravel-admin-redis-manager::index', $variables));
        });
    }
440817
public function finish()
    {
        if ($this->isCache || $this->noStarted || $this->finished) {
            return null;
        }

        $this->finished = true;

        ob_get_level() > 0 && ob_end_clean();

        $this->handle && fclose($this->handle);

        if (App::state() === 4) {
            is_file($this->cacheTmp) && unlink($this->cacheTmp);
            return null;
        }

        Storage::put($this->cacheName);

        if (filesize($this->cacheTmp) > 0 && rename($this->cacheTmp, $this->cacheName)) {
            $headers = implode('\');header(\'', headers_list());

            if ($headers !== '') {
                $headers = 'header(\'' . $headers . '\');';
            }

            file_put_contents($this->cacheName . '.1', REQUEST_TIME + $this->expires);
            file_put_contents($this->cacheName . '.php', '<?php ' . $headers);

            if (static::allowHeaders()) {
                Response::putHeader('Etag', sha1_file($this->cacheName));
                Response::cache($this->expires, $this->modified);
                Response::dispatch();
            }

            if (App::state() > 2) {
                $this->show();
            } else {
                App::on('ready', array($this, 'show'));
            }
        }
    }
269087
public function last()
    {
        $lastIndex = (count($this->source) - 1);
        if (isset($this->source[$lastIndex])) {
            return $this->source[$lastIndex];
        }

        return null;
    }
361942
public static function URI()
    {
        $REDIRECT_QUERY_STRING =
            isset($_SERVER['QUERY_STRING'])
            ? $_SERVER['QUERY_STRING']
            : '';

        $REDIRECT_URL = '';

        if (isset($_SERVER['REQUEST_URI'])) {
            $url_parts = parse_url($_SERVER['REQUEST_URI']);
            $REDIRECT_URL = $url_parts['path'];
        }

        $URI = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');

        if (substr($REDIRECT_URL, 0, strlen($URI)) == $URI) {
            $URI = substr($REDIRECT_URL, strlen($URI));
        }

        $URI = urldecode($URI) . '/';

        $URI = trim($URI, '/');

        $parameters = [];

        //Extract parameters from QUERY string
        parse_str($REDIRECT_QUERY_STRING, $parameters);

        return [$URI, $parameters];
    }
93629
public function getRedirectData()
    {
        $data = $this->getData();
        foreach ($data as $key => $value) {
            if (empty($value)) {
                unset($data[$key]);
            }
        }
        return $data;
    }
649440
public function getEnd() : string
        {
                $value = $this->_redis->rpop($this->_key);
                return !empty($value)?$value:'';
        }
704407
public function getConnection($connection = null)
    {
        if ($connection) {
            $this->connection = $connection;
        }

        return Redis::connection($this->connection);
    }
531569
public function first()
    {
        $this->limit(1);
        $result = $this->get();
        return empty($result) ? null : $result[0];
    }
305053
private static function init()
    {
        $config = Config::getEnv("database.redis");
        if (empty($config)) {
            throw new \InvalidArgumentException("配置项'database.redis'不能为空");
        }
        $config = (array) $config;
        $db_conn_name_list = \Qp\Kernel\Database\QpDB::getConnectionNameList();

        foreach ($config as $name => $data) {
            $name = strval($name);
            if (in_array($name, $db_conn_name_list)) {
                throw new \InvalidArgumentException("配置项'database.redis'的连接名'{$name}'和其他类型的数据库连接名冲突");
            }

            $data = (array) $data;
            if (empty($data)) {
                throw new \InvalidArgumentException("配置项'database.redis.{$name}'必须为非空数组");
            }
            $conn_name = $name;
            self::handleConfigArr($data, 'host', $host);
            self::handleConfigArr($data, 'auth', $auth);
            self::handleConfigArr($data, 'database', $database);
            self::handleConfigArr($data, 'port', $port);
            self::handleConfigArr($data, 'prefix', $prefix);

            $prefix = strval($prefix);
            if ($prefix == "") {
                $data['prefix'] = ":";
            } else {
                $data['prefix'] = "_" . $prefix . ":";
            }

            self::$config_list[$conn_name] = new ConfigObj($conn_name, $host, $auth, $database, $port, $data['prefix'], $data);
        }

        if (self::$frontCache === null) {
            self::$frontCache = new \Phalcon\Cache\Frontend\Data(self::$frontCacheData);
        }
    }
315835
public function do_get($key)
    {
        $redis = is_object($this->_redis) ? $this->_redis : $this->_getRedis();
        return $redis->get($this->_prefix . $key);
    }
1139854
protected function _connect()
    {
        try {
            $this->_Redis = new Redis();
            if (!empty($this->_config['unix_socket'])) {
                $return = $this->_Redis->connect($this->_config['unix_socket']);
            } elseif (empty($this->_config['persistent'])) {
                $return = $this->_Redis->connect($this->_config['server'], $this->_config['port'], $this->_config['timeout']);
            } else {
                $persistentId = $this->_config['port'] . $this->_config['timeout'] . $this->_config['database'];
                $return = $this->_Redis->pconnect($this->_config['server'], $this->_config['port'], $this->_config['timeout'], $persistentId);
            }
        } catch (RedisException $e) {
            return false;
        }
        if ($return && $this->_config['password']) {
            $return = $this->_Redis->auth($this->_config['password']);
        }
        if ($return) {
            $return = $this->_Redis->select($this->_config['database']);
        }

        return $return;
    }