yiisoft / yii2-redis

Yii 2 Redis extension.
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
451 stars 184 forks source link

Call for HSET got HMSET instead #229

Closed Stairdeck closed 3 years ago

Stairdeck commented 3 years ago

If I use this:

$redis->executeCommand('HSET', [
    'mail_tokens', $user->id, $token, 'EX' => 60*60*24
]);

Got this:

{
    "name": "Database Exception",
    "message": "Redis error: ERR wrong number of arguments for HMSET\nRedis command was: HSET mail_tokens 3 QXY_7-kn2NbN4NQXo0mS5CwdG3oPJNU- 86400",
    "code": "",
    "type": "yii\\db\\Exception",
    "file": "C:\\OpenServer\\domains\\c\\vendor\\yiisoft\\yii2-redis\\src\\Connection.php",
    "line": 828,
    "stack-trace": [
        "#0 C:\\OpenServer\\domains\\c\\vendor\\yiisoft\\yii2-redis\\src\\Connection.php(796): yii\\redis\\Connection->parseResponse()",
        "#1 C:\\OpenServer\\domains\\c\\vendor\\yiisoft\\yii2-redis\\src\\Connection.php(779): yii\\redis\\Connection->sendCommandInternal()",
        "#2 C:\\OpenServer\\domains\\c\\models\\forms\\RegistrationForm.php(86): yii\\redis\\Connection->executeCommand()",
...
Q A
Yii vesion 2.0.14
PHP version 7.4.14
Operating system Windows 10 (Open Server 5.3.8)
samdark commented 3 years ago

Looks like a pure bug 👍

samdark commented 3 years ago

Hmm... wait. Redis command was: HSET mail_tokens 3 QXY_7-kn2NbN4NQXo0mS5CwdG3oPJNU- 86400 means the correct command was issued.

Stairdeck commented 3 years ago

Hmm... wait. Redis command was: HSET mail_tokens 3 QXY_7-kn2NbN4NQXo0mS5CwdG3oPJNU- 86400 means the correct command was issued.

Yes, but exception throws and redis empty

samdark commented 3 years ago

Would you please try HSET mail_tokens 3 QXY_7-kn2NbN4NQXo0mS5CwdG3oPJNU- 86400 directly on Redis without using PHP?

Stairdeck commented 3 years ago

All is ok, problem was with ttl. Redis does not support this on hashes only if it not top. Sorry for wasting time.

samdark commented 3 years ago

No problem. You're welcome.