redis-allocator 0.3.1__py3-none-any.whl → 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- redis_allocator/_version.py +1 -1
- redis_allocator/allocator.py +5 -2
- {redis_allocator-0.3.1.dist-info → redis_allocator-0.3.2.dist-info}/METADATA +1 -1
- {redis_allocator-0.3.1.dist-info → redis_allocator-0.3.2.dist-info}/RECORD +8 -8
- tests/conftest.py +1 -11
- {redis_allocator-0.3.1.dist-info → redis_allocator-0.3.2.dist-info}/WHEEL +0 -0
- {redis_allocator-0.3.1.dist-info → redis_allocator-0.3.2.dist-info}/licenses/LICENSE +0 -0
- {redis_allocator-0.3.1.dist-info → redis_allocator-0.3.2.dist-info}/top_level.txt +0 -0
redis_allocator/_version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '0.3.
|
1
|
+
__version__ = '0.3.2'
|
redis_allocator/allocator.py
CHANGED
@@ -550,6 +550,9 @@ class RedisAllocator(RedisLockPool, Generic[U]):
|
|
550
550
|
"""
|
551
551
|
return f'''
|
552
552
|
{super()._lua_required_string}
|
553
|
+
local function time()
|
554
|
+
return tonumber(redis.call("TIME")[1])
|
555
|
+
end
|
553
556
|
local function pool_pointer_str(head)
|
554
557
|
local pointer_type = 'head'
|
555
558
|
if not head then
|
@@ -584,10 +587,10 @@ class RedisAllocator(RedisLockPool, Generic[U]):
|
|
584
587
|
if timeout == nil or timeout <= 0 then
|
585
588
|
return -1
|
586
589
|
end
|
587
|
-
return
|
590
|
+
return time() + timeout
|
588
591
|
end
|
589
592
|
local function is_expiry_invalid(expiry)
|
590
|
-
return expiry ~= nil and expiry > 0 and expiry <=
|
593
|
+
return expiry ~= nil and expiry > 0 and expiry <= time()
|
591
594
|
end
|
592
595
|
local function is_expired(value)
|
593
596
|
local _, _, expiry = split_pool_value(value)
|
@@ -1,15 +1,15 @@
|
|
1
1
|
redis_allocator/__init__.py,sha256=TVjUm-8YEu_MQD_PkfeIKiVknpCJBrUY9cWN1LlaZcU,1016
|
2
|
-
redis_allocator/_version.py,sha256=
|
3
|
-
redis_allocator/allocator.py,sha256=
|
2
|
+
redis_allocator/_version.py,sha256=bqu4G7Is-8Were-hMi-SthEalL7QW-PAbKWGZ9pVB6U,22
|
3
|
+
redis_allocator/allocator.py,sha256=Q0oDhUyjlpk6WoibvmlFS0pEmxk3qwLUHB277P3EMrE,47120
|
4
4
|
redis_allocator/lock.py,sha256=fqf6WUWHKYenEArWopMIF6kWEnDfADC-bZvnQImsQVo,27400
|
5
5
|
redis_allocator/task_queue.py,sha256=8DjNr2uxhzCsHatV_CHOeGh7_K9pqQZFApSbe2blRO0,14989
|
6
|
-
redis_allocator-0.3.
|
6
|
+
redis_allocator-0.3.2.dist-info/licenses/LICENSE,sha256=Wt4X1rHpffQfEiyWcDUx8BMLjXxfPqaiYZ7Lgsj7L4c,1068
|
7
7
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
tests/conftest.py,sha256=
|
8
|
+
tests/conftest.py,sha256=1QA3fxdX2XmVDEXY9L9D6NAWlAxlyifK8W9rnO24ig8,3947
|
9
9
|
tests/test_allocator.py,sha256=hFKgLe_yONtEjjm6zssUnhK0tzihG_1xZMziztHmqqA,22404
|
10
10
|
tests/test_lock.py,sha256=MDMRNN46VhWqkHUIhYOMEDgZkFFCW_WjwRLTOjkFF-Q,46952
|
11
11
|
tests/test_task_queue.py,sha256=Fh5naikFajfOvL6GngEy_TPfOYCYZolZfVwtR6T4dTY,31710
|
12
|
-
redis_allocator-0.3.
|
13
|
-
redis_allocator-0.3.
|
14
|
-
redis_allocator-0.3.
|
15
|
-
redis_allocator-0.3.
|
12
|
+
redis_allocator-0.3.2.dist-info/METADATA,sha256=H_C0Um1MegEzuo6A_UhgWkIN0SsQA_CScHhfwqatfw0,21653
|
13
|
+
redis_allocator-0.3.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
14
|
+
redis_allocator-0.3.2.dist-info/top_level.txt,sha256=0hXzU7sK5FCeSolTEYxThOt3HOybnwaXv1FLRJvHVgI,22
|
15
|
+
redis_allocator-0.3.2.dist-info/RECORD,,
|
tests/conftest.py
CHANGED
@@ -127,16 +127,6 @@ def test_updater() -> _TestUpdater:
|
|
127
127
|
return _TestUpdater([["key1", "key2"], ["key4", "key5", "key6"], ["key7", "key8", "key9"]])
|
128
128
|
|
129
129
|
|
130
|
-
class _TestRedisAllocator(RedisAllocator):
|
131
|
-
|
132
|
-
@property
|
133
|
-
def _lua_required_string(self):
|
134
|
-
return f'''
|
135
|
-
os.time = function() return tonumber(redis.call("TIME")[1]) end
|
136
|
-
{super()._lua_required_string}
|
137
|
-
'''
|
138
|
-
|
139
|
-
|
140
130
|
@pytest.fixture(params=[False, True])
|
141
131
|
def allocator_with_policy(redis_client: Redis, test_updater: _TestUpdater, request: pytest.FixtureRequest) -> RedisAllocator:
|
142
132
|
"""Create a RedisAllocator with a default policy."""
|
@@ -147,7 +137,7 @@ def allocator_with_policy(redis_client: Redis, test_updater: _TestUpdater, reque
|
|
147
137
|
updater=test_updater
|
148
138
|
)
|
149
139
|
|
150
|
-
alloc =
|
140
|
+
alloc = RedisAllocator(
|
151
141
|
redis_client,
|
152
142
|
'test-policy',
|
153
143
|
'alloc-lock',
|
File without changes
|
File without changes
|
File without changes
|