redis-allocator 0.4.6__py3-none-any.whl → 0.5.1__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 +25 -8
- {redis_allocator-0.4.6.dist-info → redis_allocator-0.5.1.dist-info}/METADATA +1 -1
- {redis_allocator-0.4.6.dist-info → redis_allocator-0.5.1.dist-info}/RECORD +7 -7
- {redis_allocator-0.4.6.dist-info → redis_allocator-0.5.1.dist-info}/WHEEL +0 -0
- {redis_allocator-0.4.6.dist-info → redis_allocator-0.5.1.dist-info}/licenses/LICENSE +0 -0
- {redis_allocator-0.4.6.dist-info → redis_allocator-0.5.1.dist-info}/top_level.txt +0 -0
redis_allocator/_version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '0.
|
1
|
+
__version__ = '0.5.1'
|
redis_allocator/allocator.py
CHANGED
@@ -304,6 +304,11 @@ class RedisAllocatorPolicy(ABC, Generic[U]):
|
|
304
304
|
"""
|
305
305
|
pass
|
306
306
|
|
307
|
+
@abstractmethod
|
308
|
+
def refresh_pool_all(self, allocator: 'RedisAllocator[U]'):
|
309
|
+
"""Refresh the allocation pool."""
|
310
|
+
pass
|
311
|
+
|
307
312
|
def check_health_once(self, r_obj: RedisAllocatorObject[U], duration: int = 3600) -> bool:
|
308
313
|
"""Check the health of the object."""
|
309
314
|
with contextlib.closing(r_obj.open()):
|
@@ -405,6 +410,11 @@ class DefaultRedisAllocatorPolicy(RedisAllocatorPolicy[U]):
|
|
405
410
|
self._update_lock_key = f"{allocator._pool_str()}|policy_update_lock"
|
406
411
|
atexit.register(lambda: self.finalize(self._allocator()))
|
407
412
|
|
413
|
+
def refresh_pool_all(self, allocator: 'RedisAllocator[U]'):
|
414
|
+
allocator.clear()
|
415
|
+
for _ in range(self.updater.params):
|
416
|
+
self.refresh_pool(allocator)
|
417
|
+
|
408
418
|
def malloc(self, allocator: 'RedisAllocator[U]', timeout: Timeout = 120,
|
409
419
|
obj: Optional[U] = None, params: Optional[dict] = None,
|
410
420
|
cache_timeout: Timeout = 3600) -> Optional[RedisAllocatorObject[U]]:
|
@@ -786,9 +796,9 @@ class RedisAllocator(RedisLockPool, Generic[U]):
|
|
786
796
|
push_to_tail(itemName, expiry)
|
787
797
|
end
|
788
798
|
else
|
789
|
-
if locked then
|
790
|
-
|
791
|
-
end
|
799
|
+
-- if locked then
|
800
|
+
-- set_item_allocated(itemName, value)
|
801
|
+
-- end
|
792
802
|
end
|
793
803
|
end
|
794
804
|
|
@@ -824,6 +834,18 @@ class RedisAllocator(RedisLockPool, Generic[U]):
|
|
824
834
|
end
|
825
835
|
'''
|
826
836
|
|
837
|
+
@cached_property
|
838
|
+
def _clear_script(self):
|
839
|
+
return self.redis.register_script(f'''
|
840
|
+
{self._lua_required_string}
|
841
|
+
redis.call("DEL", poolItemsKey)
|
842
|
+
redis.call("SET", headKey, "")
|
843
|
+
redis.call("SET", tailKey, "")
|
844
|
+
''')
|
845
|
+
|
846
|
+
def clear(self):
|
847
|
+
self._clear_script()
|
848
|
+
|
827
849
|
@cached_property
|
828
850
|
def _extend_script(self):
|
829
851
|
"""Cached Lua script to add or update keys in the pool.
|
@@ -966,11 +988,6 @@ class RedisAllocator(RedisLockPool, Generic[U]):
|
|
966
988
|
"""
|
967
989
|
return f'{self.prefix}|{self.suffix}-cache'
|
968
990
|
|
969
|
-
def clear(self):
|
970
|
-
"""Clear all resources from the allocation pool and cache."""
|
971
|
-
super().clear()
|
972
|
-
self.redis.delete(self._cache_str)
|
973
|
-
|
974
991
|
def _soft_bind_name(self, name: str) -> str:
|
975
992
|
"""Get the Redis key for a soft binding.
|
976
993
|
|
@@ -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=s8Yq9Om1yBxrMA7xYQ5Y13Paeuxnq99NxhyjuPlnH6A,22
|
3
|
+
redis_allocator/allocator.py,sha256=TTjr8jcQpJt96RJkssRU60z0m1aUsqBlEud87W4DCkY,53414
|
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.
|
6
|
+
redis_allocator-0.5.1.dist-info/licenses/LICENSE,sha256=Wt4X1rHpffQfEiyWcDUx8BMLjXxfPqaiYZ7Lgsj7L4c,1068
|
7
7
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
8
|
tests/conftest.py,sha256=Ts82uylQSzP_GcaN0E02o3xcFdjw20cXNzh3RAdYKW4,3967
|
9
9
|
tests/test_allocator.py,sha256=zOBdaOhlpLsv63J4QZ9vOhL1k1gu_vO68x4CpPDa9_4,23350
|
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.
|
13
|
-
redis_allocator-0.
|
14
|
-
redis_allocator-0.
|
15
|
-
redis_allocator-0.
|
12
|
+
redis_allocator-0.5.1.dist-info/METADATA,sha256=yI2vLDxF_5JULEbkUZ5XkVsIriC8qEwtLjbGDmp6Neg,21727
|
13
|
+
redis_allocator-0.5.1.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
14
|
+
redis_allocator-0.5.1.dist-info/top_level.txt,sha256=0hXzU7sK5FCeSolTEYxThOt3HOybnwaXv1FLRJvHVgI,22
|
15
|
+
redis_allocator-0.5.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|