File tree Expand file tree Collapse file tree 1 file changed +3
-12
lines changed Expand file tree Collapse file tree 1 file changed +3
-12
lines changed Original file line number Diff line number Diff line change @@ -22,15 +22,6 @@ class Processor
2222 // Redis key prefix
2323 const KEY_PREFIX = 'mutex-lock: ' ;
2424
25- // Response string from redis cmd: set
26- const LOCK_SUCCESS = 'OK ' ;
27-
28- // Response int from redis lua script: redis.call('del', KEY)
29- const UNLOCK_SUCCESS = 1 ;
30-
31- // Params for cmd: set
32- const IF_NOT_EXIST = 'NX ' ;
33-
3425 // Expire type: seconds
3526 const EXPIRE_TIME_SECONDS = 'EX ' ;
3627
@@ -144,7 +135,7 @@ public function unlock(array $payload): bool
144135 return false ;
145136 }
146137
147- return self :: UNLOCK_SUCCESS === $ this ->client ->eval (
138+ return 1 === $ this ->client ->eval (
148139 LuaScripts::del (),
149140 1 ,
150141 self ::KEY_PREFIX . $ payload ['key ' ],
@@ -201,12 +192,12 @@ public function verify(array $payload): bool
201192 protected function hit (string $ key , int $ expire ): array
202193 {
203194
204- if (self :: LOCK_SUCCESS === (string ) $ this ->client ->set (
195+ if (' OK ' === (string ) $ this ->client ->set (
205196 self ::KEY_PREFIX . $ key ,
206197 $ token = uniqid (mt_rand ()),
207198 $ this ->expireType ,
208199 $ expire ,
209- self :: IF_NOT_EXIST
200+ ' NX '
210201 )) {
211202 return [
212203 'key ' => $ key ,
You can’t perform that action at this time.
0 commit comments