yiisoft / yii2-redis

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

Error with never blocking mutex #187

Closed RomanRabirokh closed 5 years ago

RomanRabirokh commented 5 years ago

https://github.com/yiisoft/yii2-redis/blob/332f2efd09830e4c4c6cff405dfb2f75859eea29/src/Mutex.php#L113

maybe I don’t understand the mutex mechanism

But redis allows you to create keys with the same name.

that is, the installation will always be performed on this line.

such a command can be executed as many as you want without errors. SET mykey "Hello" ex 100

Based on this, the lock will never work.

rob006 commented 5 years ago

This command uses 'NX' option:

NX -- Only set the key if it does not already exist.

In this case null will be returned:

Simple string reply: OK if SET was executed correctly. Null reply: a Null Bulk Reply is returned if the SET operation was not performed because the user specified the NX or XX option but the condition was not met.

https://redis.io/commands/set

RomanRabirokh commented 5 years ago

@rob006 Sorry)You're right)