Skip to content

Commit 6b7d0f4

Browse files
committed
Reduce redis complexity
1 parent f7dd61f commit 6b7d0f4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Symfony/Component/Semaphore/Store/Resources/redis_save.lua

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ redis.call("ZADD", timeKey, now + ttlInSecond, identifier)
3434
redis.call("ZADD", weightKey, weight, identifier)
3535

3636
-- Extend the TTL
37-
local maxExpiration = redis.call("ZREVRANGE", timeKey, 0, 0, "WITHSCORES")[2]
38-
redis.call("EXPIREAT", weightKey, maxExpiration + 10)
39-
redis.call("EXPIREAT", timeKey, maxExpiration + 10)
37+
local curentTtl = redis.call("TTL", weightKey)
38+
if curentTtl < now + ttlInSecond then
39+
redis.call("EXPIRE", weightKey, curentTtl + 10)
40+
redis.call("EXPIRE", timeKey, curentTtl + 10)
41+
end
4042

4143
return true

src/Symfony/Component/Semaphore/Store/StoreFactory.php

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class StoreFactory
2929
{
3030
/**
3131
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|RedisProxy|RedisClusterProxy|string $connection Connection or DSN or Store short name
32-
*
33-
* @return PersistingStoreInterface
3432
*/
3533
public static function createStore($connection): PersistingStoreInterface
3634
{

0 commit comments

Comments
 (0)