framework icon indicating copy to clipboard operation
framework copied to clipboard

使用 Predis 时模型 save 方法报错 ERR wrong number of arguments for 'del' command

Open ZoftTy opened this issue 11 months ago • 7 comments

所属功能组件

缓存(Cache)

ThinkPHP 版本

8.0.3

操作系统

Centos 7

错误信息

#0 [0]ServerException in Client.php line 416 ERR wrong number of arguments for 'del' command

Call Stack

in Client.php line 416 at Client->onErrorResponse() in Client.php line 385 at Client->executeCommand() in Client.php line 335 at Client->__call() in Redis.php line 207 at Redis->clearTag() in TagSet.php line 113 at TagSet->clear() in PDOConnection.php line 877 at PDOConnection->pdoExecute() in PDOConnection.php line 1167 at PDOConnection->update() in BaseQuery.php line 1260 at BaseQuery->update() in Model.php line 673 at Model->think{closure}() in PDOConnection.php line 1521 at PDOConnection->transaction() in Transaction.php line 47 at BaseQuery->transaction() in Model.php line 665 at Model->updateData() in Model.php line 564 at Model->save() in CaptchaService.php line 130 at CaptchaService->verify() in Customer.php line 28 at Customer->checkCode() at call_user_func_array() in Validate.php line 639 at Validate->checkItem() in Validate.php line 519 at Validate->check() in BaseController.php line 94 at BaseController->validate() in Customer.php line 19 at Customer->captcha() at ReflectionMethod->invokeArgs() in Container.php line 330 at Container->invokeMethod() in Container.php line 363 at Container->invoke() in Callback.php line 27 at Callback->exec() in Dispatch.php line 52 at Dispatch->run() in Route.php line 755 at Route->think{closure}() in Pipeline.php line 59 at Pipeline->think{closure}() in Pipeline.php line 66 at Pipeline->then() in Route.php line 754 at Route->dispatch() in Http.php line 208 at Http->dispatchToRoute() in Http.php line 198 at Http->think{closure}() in Pipeline.php line 59 at Pipeline->think{closure}() in MultiApp.php line 51 at MultiApp->think\app{closure}() in Pipeline.php line 59 at Pipeline->think{closure}() in Pipeline.php line 66 at Pipeline->then() in MultiApp.php line 50 at MultiApp->handle() at call_user_func() in Middleware.php line 134 at Middleware->think{closure}() in Pipeline.php line 85 at Pipeline->think{closure}() in HandleResponse.php line 17 at HandleResponse->handle() at call_user_func() in Middleware.php line 134 at Middleware->think{closure}() in Pipeline.php line 85 at Pipeline->think{closure}() in Auth.php line 30 at Auth->handle() at call_user_func() in Middleware.php line 134 at Middleware->think{closure}() in Pipeline.php line 85 at Pipeline->think{closure}() in LoadLangPack.php line 53 at LoadLangPack->handle() at call_user_func() in Middleware.php line 134 at Middleware->think{closure}() in Pipeline.php line 85 at Pipeline->think{closure}() in TraceDebug.php line 71 at TraceDebug->handle() at call_user_func() in Middleware.php line 134 at Middleware->think{closure}() in Pipeline.php line 85 at Pipeline->think{closure}() in Pipeline.php line 66 at Pipeline->then() in Http.php line 197 at Http->runWithRequest() in Http.php line 162 at Http->run() in index.php line 20

其它说明

predis 版本: v2.2.2 thinkphp 版本: 8.0.3

社区相同问题

https://q.thinkphp.cn/post/1217 https://q.thinkphp.cn/post/2961

ZoftTy avatar Mar 20 '24 03:03 ZoftTy

未复现,是不是 Redis 服务器版本太低。这边用的 Redis Server 7.0.0 测试

big-dream avatar Mar 20 '24 03:03 big-dream

测试代码:

$user = \app\model\User::find(1);
$user->save(['name' => 'jwj01']);

big-dream avatar Mar 20 '24 03:03 big-dream

已复现,代码:

$user = User::cache('key',60,'tagName')->find(1);
$user->save(['name' => 'jwj' . rand(1000, 9999)]);

清除缓存标签时,如果标签内的 keys 为空则会触发报错

big-dream avatar Mar 20 '24 03:03 big-dream

redis version: 7.2.4 删除 phpredis 扩展,使用 https://github.com/predis/predis

使用测试代码

// 模型
class SmsCodeModel extends Model
{
    protected $table = 'sms_code';
}

$code = SmsCodeModel::find(1);

$code->save(['code' => 123456]);

cache 配置

return [
    // 默认缓存驱动
    'default' => 'redis',

    // 缓存连接方式配置
    'stores'  => [
        'file' => [
            // 驱动方式
            'type'       => 'File',
            // 缓存保存目录
            'path'       => '',
            // 缓存前缀
            'prefix'     => '',
            // 缓存有效期 0表示永久缓存
            'expire'     => 0,
            // 缓存标签前缀
            'tag_prefix' => 'tag:',
            // 序列化机制 例如 ['serialize', 'unserialize']
            'serialize'  => [],
        ],
        // 更多的缓存连接
        'redis'   =>  [
            // 驱动方式
            'type'   => 'redis',
            // 服务器地址
            'host'       => env('REDIS_HOST', '127.0.0.1'),
            // 端口
            'port'      => env('REDIS_PORT', 6379),
            // 密码
            'password'  => env('REDIS_PASSWORD', ''),
        ],

    ],
];

ZoftTy avatar Mar 20 '24 03:03 ZoftTy

wontfix 是无法修复的意思嘛

ZoftTy avatar Mar 20 '24 04:03 ZoftTy

wontfix 是无法修复的意思嘛

弄错标签了

big-dream avatar Mar 20 '24 04:03 big-dream

什么时候合并呀呀呀呀

ZoftTy avatar Apr 28 '24 10:04 ZoftTy