Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

缓存组件redis使用长连接后,0号库读写存在问题 #3063

Open
sky66666666 opened this issue Sep 10, 2024 · 0 comments
Open

缓存组件redis使用长连接后,0号库读写存在问题 #3063

sky66666666 opened this issue Sep 10, 2024 · 0 comments
Labels

Comments

@sky66666666
Copy link

sky66666666 commented Sep 10, 2024

所属功能组件

缓存(Cache)

ThinkPHP 版本

6.0

操作系统

Ubuntu

错误信息

cache.php配置如下

return [
    'default' => 'redis',
    'stores'    =>    [
        // 文件缓存
        'file'   =>  [
            // 驱动方式
            'type'   => 'file',
            // 设置不同的缓存保存目录
            'path'   => '../runtime/file/',
        ],
        // redis缓存
        'redis'   =>  [
            // 驱动方式
            'type'   => 'redis',
            // 服务器地址
            'host'       => 'xxx',
            'port'       => '6379',
            'password'       => '',
            'select'       => 1,
            'persistent' => true,
            'prefix'     => '',
            'serialize'  => true,
        ],
        'test00' => [
            'type'       => 'redis',
            'host'       => 'xxx',
            'port'       => 6379,
            'password'   => '',
            'select'     => 0,
            'timeout'    => 0,
            'expire'     => 0,
            'persistent' => true,
            'prefix'     => '',
            'serialize'  => true,
        ]
    ],
];

控制器代码如下:

public function test()
{
    \think\facade\Cache::store('test00')->set('test00', 'test00');
    return 'success';
}

执行控制器代码,此时test00这个key写在了1号库没有按照配置写入0号库
另外修改配置,将persistent都改成false这时候正常写入,又或者将源码中的if判断注释,强制进行select,,则能正常读写
微信截图_20240910152519

其它说明

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant