zxin/think-redis

think redis

v2.0.0 2023-08-11 14:16 UTC

This package is auto-updated.

Last update: 2024-04-11 15:40:26 UTC


README

Latest Stable Version License workflows coverage

快速使用

安装

composer require zxin/think-redis

普通环境下直接使用。

\Zxin\Think\Redis\RedisManager::store()->get('xxxx');

协程环境下使用方法与普通环境一致,但为了更优雅的退出,在workerStopworkerExit下调用以下代码。

\Zxin\Think\Redis\RedisManager::destroy();

替换Cache中的redis驱动以提供全局redis管理服务

  1. 先在config/redis.php配置文件声明一个连接
  2. config/cache.php配置文件中需要提供redis连接的位置替换驱动
[
    'default' => 'test',
    'stores' => [
        'test' => [
            'type' => \Zxin\Think\Redis\CacheDriver::class,
            'connection' => 'main_redis', // 在redis统一配置中声明的有效连接
            ...
        ],
        ...
    ]
]