File tree Expand file tree Collapse file tree 2 files changed +25
-15
lines changed Expand file tree Collapse file tree 2 files changed +25
-15
lines changed Original file line number Diff line number Diff line change @@ -111,9 +111,9 @@ RedisLock::unlock($payload);
111111// Determine a lock if it still effective.
112112RedisLock::verify($payload);
113113
114- // Delay a lock if it still effective.
114+ // Reset a lock if it still effective.
115115// The 'expire' param is same to use RedisLock::lock()
116- RedisLock::delay ($payload, 100000);
116+ RedisLock::relock ($payload, 100000);
117117
118118/////////////////////
119119// Special usages: //
Original file line number Diff line number Diff line change @@ -144,26 +144,36 @@ public function unlock(array $payload): bool
144144 }
145145
146146 /**
147- * Delay a lock if it still effective.
147+ * Reset a lock if it still effective.
148148 *
149149 * @param array $payload
150150 * @param int $expire
151- * @return bool
151+ * @return array
152+ * - Not empty for relock success.
153+ * - Empty for cant relock.
152154 */
153- public function delay (array $ payload , int $ expire ): bool
155+ public function relock (array $ payload , int $ expire ): array
154156 {
155- if (! isset ($ payload ['key ' ], $ payload ['token ' ])) {
156- return false ;
157+ if (
158+ isset ($ payload ['key ' ], $ payload ['token ' ])
159+ && 1 === $ this ->client ->eval (
160+ $ this ->expireType === self ::EXPIRE_TIME_MILLISECONDS ?
161+ LuaScripts::pexpire () : LuaScripts::expire (),
162+ 1 ,
163+ self ::KEY_PREFIX . $ payload ['key ' ],
164+ $ payload ['token ' ],
165+ $ expire
166+ )
167+ ) {
168+ return [
169+ 'key ' => $ payload ['key ' ],
170+ 'token ' => $ payload ['token ' ],
171+ 'expire ' => $ expire ,
172+ 'expire_type ' => $ this ->expireType ,
173+ ];
157174 }
158175
159- return 1 === $ this ->client ->eval (
160- $ this ->expireType === self ::EXPIRE_TIME_MILLISECONDS ?
161- LuaScripts::pexpire () : LuaScripts::expire (),
162- 1 ,
163- self ::KEY_PREFIX . $ payload ['key ' ],
164- $ payload ['token ' ],
165- $ expire
166- );
176+ return [];
167177 }
168178
169179 /**
You can’t perform that action at this time.
0 commit comments