Redis facade in Laravel 9 HSET does not allow multiple fields/values to be passed
1. Try to pass multiple fields/values based on the Redis facade Hset, the code is implemented as follows
$cache_list_key = sprintf('order:batch:%s_list', $batch_id);
Redis::hset($cache_list_key, 'key', $key, 'result', $result, 'message', $message);
Redis::expire($cache_list_key, 86400);
2. Error during operation: local.error: err wrong number of arguments forhsetcommand. as shown in Figure 1
[2024-03-28 08:09:35] local.ERROR: ERR wrong number of arguments for 'hset' command {"exception":"[object] (Predis\\Response\\ServerException(code: 0): ERR wrong number of arguments for 'hset' command at E:\\wwwroot\\object\\vendor\\predis\\predis\\src\\Client.php:384)
[stacktrace]
3. However, starting from Redis 4.0, HSET can set one or more field/value pairs at a time. Since Redis 4.0.0, HMSET is discarded, please use HSET instead.
4. Reference: Redis Facade HSet DoesnT allow passing multiple fields/values . The final decision is still to use HSET, and only one field is passed at a time, and it is executed multiple times. The code is implemented as follows
$cache_list_key = sprintf('order:batch:%s_list', $batch_id);
Redis::hset($cache_list_key, 'key', $key);
Redis::hset($cache_list_key, 'result', $result);
Redis::hset($cache_list_key, 'message', $message);
Redis::expire($cache_list_key, 86400);
5. No more errors, check the structure in Redis, which is in line with expectations. as shown in Figure 2

