redis-allocator 0.5.0__tar.gz → 0.5.1__tar.gz

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.
Files changed (22) hide show
  1. {redis_allocator-0.5.0/redis_allocator.egg-info → redis_allocator-0.5.1}/PKG-INFO +1 -1
  2. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/pyproject.toml +1 -1
  3. redis_allocator-0.5.1/redis_allocator/_version.py +1 -0
  4. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/redis_allocator/allocator.py +13 -5
  5. {redis_allocator-0.5.0 → redis_allocator-0.5.1/redis_allocator.egg-info}/PKG-INFO +1 -1
  6. redis_allocator-0.5.0/redis_allocator/_version.py +0 -1
  7. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/LICENSE +0 -0
  8. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/README.md +0 -0
  9. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/redis_allocator/__init__.py +0 -0
  10. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/redis_allocator/lock.py +0 -0
  11. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/redis_allocator/task_queue.py +0 -0
  12. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/redis_allocator.egg-info/SOURCES.txt +0 -0
  13. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/redis_allocator.egg-info/dependency_links.txt +0 -0
  14. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/redis_allocator.egg-info/requires.txt +0 -0
  15. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/redis_allocator.egg-info/top_level.txt +0 -0
  16. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/setup.cfg +0 -0
  17. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/setup.py +0 -0
  18. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/tests/__init__.py +0 -0
  19. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/tests/conftest.py +0 -0
  20. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/tests/test_allocator.py +0 -0
  21. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/tests/test_lock.py +0 -0
  22. {redis_allocator-0.5.0 → redis_allocator-0.5.1}/tests/test_task_queue.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: redis-allocator
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: Redis-based resource allocation system.
5
5
  Home-page: https://github.com/invoker-bot/RedisAllocator-python
6
6
  Author: Invoker Bot
@@ -4,7 +4,7 @@ build-backend = 'setuptools.build_meta'
4
4
 
5
5
  [tool.commitizen]
6
6
  name = "cz_conventional_commits"
7
- version = "0.5.0"
7
+ version = "0.5.1"
8
8
  tag_format = "v$version"
9
9
 
10
10
  [tool.commitizen.version_files]
@@ -0,0 +1 @@
1
+ __version__ = '0.5.1'
@@ -411,6 +411,7 @@ class DefaultRedisAllocatorPolicy(RedisAllocatorPolicy[U]):
411
411
  atexit.register(lambda: self.finalize(self._allocator()))
412
412
 
413
413
  def refresh_pool_all(self, allocator: 'RedisAllocator[U]'):
414
+ allocator.clear()
414
415
  for _ in range(self.updater.params):
415
416
  self.refresh_pool(allocator)
416
417
 
@@ -833,6 +834,18 @@ class RedisAllocator(RedisLockPool, Generic[U]):
833
834
  end
834
835
  '''
835
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
+
836
849
  @cached_property
837
850
  def _extend_script(self):
838
851
  """Cached Lua script to add or update keys in the pool.
@@ -975,11 +988,6 @@ class RedisAllocator(RedisLockPool, Generic[U]):
975
988
  """
976
989
  return f'{self.prefix}|{self.suffix}-cache'
977
990
 
978
- def clear(self):
979
- """Clear all resources from the allocation pool and cache."""
980
- super().clear()
981
- self.redis.delete(self._cache_str)
982
-
983
991
  def _soft_bind_name(self, name: str) -> str:
984
992
  """Get the Redis key for a soft binding.
985
993
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: redis-allocator
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: Redis-based resource allocation system.
5
5
  Home-page: https://github.com/invoker-bot/RedisAllocator-python
6
6
  Author: Invoker Bot
@@ -1 +0,0 @@
1
- __version__ = '0.5.0'
File without changes