fastapi-cachex 0.2.9__tar.gz → 0.2.11__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 (32) hide show
  1. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/PKG-INFO +2 -2
  2. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/backends/memory.py +9 -1
  3. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/backends/redis.py +13 -2
  4. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/proxy.py +1 -1
  5. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/pyproject.toml +1 -1
  6. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/README.md +0 -0
  7. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/__init__.py +0 -0
  8. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/backends/__init__.py +0 -0
  9. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/backends/base.py +0 -0
  10. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/backends/config.py +0 -0
  11. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/backends/memcached.py +0 -0
  12. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/cache.py +0 -0
  13. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/dependencies.py +0 -0
  14. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/directives.py +0 -0
  15. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/exceptions.py +0 -0
  16. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/py.typed +0 -0
  17. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/routes.py +0 -0
  18. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/session/__init__.py +0 -0
  19. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/session/config.py +0 -0
  20. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/session/dependencies.py +0 -0
  21. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/session/exceptions.py +0 -0
  22. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/session/manager.py +0 -0
  23. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/session/middleware.py +0 -0
  24. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/session/models.py +0 -0
  25. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/session/proxy.py +0 -0
  26. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/session/security.py +0 -0
  27. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/session/token_serializers.py +0 -0
  28. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/state/__init__.py +0 -0
  29. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/state/exceptions.py +0 -0
  30. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/state/manager.py +0 -0
  31. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/state/models.py +0 -0
  32. {fastapi_cachex-0.2.9 → fastapi_cachex-0.2.11}/fastapi_cachex/types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-cachex
3
- Version: 0.2.9
3
+ Version: 0.2.11
4
4
  Summary: A caching library for FastAPI with support for Cache-Control, ETag, and multiple backends.
5
5
  Keywords: fastapi,cache,etag,cache-control,redis,memcached,in-memory
6
6
  Author: allen0099
@@ -27,8 +27,8 @@ Requires-Dist: redis[hiredis] ; extra == 'redis'
27
27
  Requires-Dist: orjson ; extra == 'redis'
28
28
  Requires-Python: >=3.10
29
29
  Project-URL: Homepage, https://github.com/allen0099/FastAPI-CacheX
30
- Project-URL: Issues, https://github.com/allen0099/FastAPI-CacheX/issues
31
30
  Project-URL: Repository, https://github.com/allen0099/FastAPI-CacheX.git
31
+ Project-URL: Issues, https://github.com/allen0099/FastAPI-CacheX/issues
32
32
  Provides-Extra: jwt
33
33
  Provides-Extra: memcache
34
34
  Provides-Extra: redis
@@ -134,10 +134,18 @@ class MemoryBackend(BaseCacheBackend):
134
134
  parts = key.split(CACHE_KEY_SEPARATOR, _MAX_KEY_PARTS)
135
135
  if len(parts) >= _MIN_KEY_PARTS:
136
136
  cache_path = parts[2]
137
- has_params = len(parts) > _MIN_KEY_PARTS
137
+ # A key always has 4 parts (method|||host|||path|||query);
138
+ # an empty query string means no real query params.
139
+ has_params = len(parts) > _MIN_KEY_PARTS and bool(
140
+ parts[_MIN_KEY_PARTS]
141
+ )
138
142
  if cache_path == path and (include_params or not has_params):
139
143
  keys_to_delete.append(key)
140
144
  cleared_count += 1
145
+ elif key == path:
146
+ # Direct key match (custom key format without separators)
147
+ keys_to_delete.append(key)
148
+ cleared_count += 1
141
149
 
142
150
  for key in keys_to_delete:
143
151
  del self.cache[key]
@@ -219,8 +219,13 @@ class AsyncRedisCacheBackend(BaseCacheBackend):
219
219
  f"{self.key_prefix}*{CACHE_KEY_SEPARATOR}{path}{CACHE_KEY_SEPARATOR}*"
220
220
  )
221
221
  else:
222
- # Clear only exact path (no query params): *|||path
223
- pattern = f"{self.key_prefix}*{CACHE_KEY_SEPARATOR}{path}"
222
+ # Clear only exact path (no query params): *|||path|||
223
+ # The trailing separator is required because default_key_builder
224
+ # always appends a separator after the path (before query_params),
225
+ # so keys with empty query params end with "|||".
226
+ pattern = (
227
+ f"{self.key_prefix}*{CACHE_KEY_SEPARATOR}{path}{CACHE_KEY_SEPARATOR}"
228
+ )
224
229
 
225
230
  cursor = 0
226
231
  batch_size = 100
@@ -239,6 +244,12 @@ class AsyncRedisCacheBackend(BaseCacheBackend):
239
244
  if cursor == 0:
240
245
  break
241
246
 
247
+ # Also match direct keys (custom key formats without separators)
248
+ # e.g. key_prefix + "gitlab:template" stored directly via backend.set()
249
+ direct_key = self._make_key(path)
250
+ if await self.client.exists(direct_key):
251
+ keys_to_delete.append(direct_key)
252
+
242
253
  # Delete all collected keys in batches
243
254
  if keys_to_delete:
244
255
  for i in range(0, len(keys_to_delete), batch_size):
@@ -48,7 +48,7 @@ class ProxyBase(Generic[ProxyInstance], metaclass=ProxyMeta):
48
48
  Args:
49
49
  instance: The instance to set, or None to clear
50
50
  """
51
- logger.info(
51
+ logger.debug(
52
52
  "Setting instance to: <%s>",
53
53
  instance.__class__.__name__ if instance else "None",
54
54
  )
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fastapi-cachex"
3
- version = "0.2.9"
3
+ version = "0.2.11"
4
4
  description = "A caching library for FastAPI with support for Cache-Control, ETag, and multiple backends."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"