Code Duplication    Length = 11-11 lines in 2 locations

Classes/RedisLockStrategy.php 2 locations

@@ 227-237 (lines=11) @@
224
     *
225
     * @return boolean TRUE on sucess, FALSE otherwise
226
     */
227
    private function init()
228
    {
229
        $script = '
230
            if not redis.call("EXISTS", KEYS[1], KEYS[2]) then
231
                return redis.call("RPUSH", KEYS[2], ARGV[1]) and redis.call("EXPIRE", KEYS[2], ARGV[2])
232
            else
233
                return 0
234
            fi
235
        ';
236
        return (bool) $this->redis->eval($script, [$this->name, $this->mutex, $this->value, $this->ttl], 2);
237
    }
238
239
    /**
240
     * Try to get the lock
@@ 268-278 (lines=11) @@
265
     *
266
     * @return boolean TRUE on success, FALSE otherwise
267
     */
268
    private function unlockAndSignal()
269
    {
270
        $script = '
271
            if redis.call("GET", KEYS[1]) == ARGV[1] and redis.call("DEL", KEYS[1]) then
272
                return redis.call("RPUSH", KEYS[2], ARGV[1]) and redis.call("EXPIRE", KEYS[2], ARGV[2])
273
            else
274
                return 0
275
            end
276
        ';
277
        return (bool) $this->redis->eval($script, [$this->name, $this->mutex, $this->value, $this->ttl], 2);
278
    }
279
280
}
281