Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis error ERR wrong number of arguments for 'hmset'

Tags:

php

redis

yii2

i'm using yiisoft/yii2-redis Yii2 component to interact with Redis and it's working as charm when it comes to retrieving data but i keep getting the following error as i'm trying to use any set like commands!

Redis error: ERR wrong number of arguments for 'hmset' command
Redis command was: hmset userApi:57d120d1d13f4a3e4d1e2217 rateLimit 10 allowance 9 allowance_updated_at 1478594580

Redis error: ERR wrong number of arguments for 'set' command
Redis command was: set x 10

My code is simply:

$redis = Yii::$app->redis;
$redis->hmset('userApi:57d120d1d13f4a3e4d1e2217 rateLimit 10 allowance 9 allowance_updated_at 1478594580');
$redis->set('x 10');

noting that when i just copy any of these commands and paste it to redis-cli it just works!

Is there any clues that i'm missing something?! thanks in advance.

like image 923
Mumen Yassin Avatar asked Oct 16 '25 14:10

Mumen Yassin


1 Answers

Oops! my fault i found that redis command params should be passed as arguments to the command function as follows:

$redis->hmset('userApi:57d120d1d13f4a3e4d1e2217', 'rateLimit', '10', 'allowance', '9', 'allowance_updated_at', '1478594580');
$redis->set('x', '10');
like image 52
Mumen Yassin Avatar answered Oct 18 '25 09:10

Mumen Yassin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!