fast-cache-middleware 0.0.2__py3-none-any.whl → 0.0.3__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.
@@ -62,5 +62,5 @@ class CacheDropConfig(BaseCacheConfigDepends):
62
62
 
63
63
  def __init__(self, paths: list[str | re.Pattern]) -> None:
64
64
  self.paths: list[re.Pattern] = [
65
- p if isinstance(p, re.Pattern) else re.compile(f"^{p}$") for p in paths
65
+ p if isinstance(p, re.Pattern) else re.compile(f"^{p}") for p in paths
66
66
  ]
@@ -112,6 +112,12 @@ async def send_with_callbacks(
112
112
  await app(scope, receive, response_builder)
113
113
 
114
114
 
115
+ def _build_scope_hash_key(scope: Scope) -> str:
116
+ path = get_route_path(scope)
117
+ method = scope["method"].upper()
118
+ return f"{path}/{method}"
119
+
120
+
115
121
  class FastCacheMiddleware:
116
122
  """Middleware for caching responses in ASGI applications.
117
123
 
@@ -201,7 +207,7 @@ class FastCacheMiddleware:
201
207
 
202
208
  @cachetools.cached(
203
209
  cache=cachetools.LRUCache(maxsize=10**3),
204
- key=lambda _, request, __: get_route_path(request.scope),
210
+ key=lambda _, request, __: _build_scope_hash_key(request.scope),
205
211
  )
206
212
  def _find_matching_route(
207
213
  self, request: Request, routes_info: list[RouteInfo]
@@ -215,6 +221,8 @@ class FastCacheMiddleware:
215
221
  RouteInfo if matching route found, otherwise None
216
222
  """
217
223
  for route_info in routes_info:
224
+ if request.method not in route_info.methods:
225
+ continue
218
226
  match_mode, _ = route_info.route.matches(request.scope)
219
227
  if match_mode == routing.Match.FULL:
220
228
  return route_info
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: fast-cache-middleware
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: Интеллектуальное middleware для кеширования ответов FastAPI
5
5
  License: MIT
6
6
  Author: Your Name
@@ -1,11 +1,11 @@
1
1
  fast_cache_middleware/__init__.py,sha256=0wuBPKrzjyBA2K9Fnm-xzC1mYSXCMuYr1uPutNXCI5Y,983
2
2
  fast_cache_middleware/controller.py,sha256=Y0StElopHiBHa-TjLqi1yoldWkcGZubcCgT2xj2zpEI,7181
3
- fast_cache_middleware/depends.py,sha256=3xWI5sZk994gmqMtloLb6t0VrVKP8aB7i6Uunkvi8sw,1868
3
+ fast_cache_middleware/depends.py,sha256=00ShPXlG0A_Ylj0ypLGU0hgSNeLxHeI3PGi8Fo35wko,1867
4
4
  fast_cache_middleware/exceptions.py,sha256=lv3p2-wAj6UZI7czVSy91eZtuXItr1hZHW2LDz8fI9s,109
5
- fast_cache_middleware/middleware.py,sha256=HnAXDiRfHS0Wn70TkzfuPHR1QOjPqew_wkbjUGTWQVU,9522
5
+ fast_cache_middleware/middleware.py,sha256=a80t7jL0CgSmtXaEgrZW-7i6IrggNlTsHGyL1Ri8Oxw,9761
6
6
  fast_cache_middleware/schemas.py,sha256=uOceBR4_itlj1NG3xszyLbE96bS_W6t6BGmPPkNkoqA,610
7
7
  fast_cache_middleware/serializers.py,sha256=jf308cez8jVzTikK6BhzHhvuIrGkA8Vdn_Gopd6dfyM,2907
8
8
  fast_cache_middleware/storages.py,sha256=GEeA-I0QvK6M_mAub08npxylLQ_WEBGyrjt9Zhe_r6A,7611
9
- fast_cache_middleware-0.0.2.dist-info/METADATA,sha256=j0fL9aTnQD_POhw32XpKagcTWWx3qOHwmHyumcN7LF4,13704
10
- fast_cache_middleware-0.0.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
- fast_cache_middleware-0.0.2.dist-info/RECORD,,
9
+ fast_cache_middleware-0.0.3.dist-info/METADATA,sha256=GPYuWY3YHPjjqhp2xSp7xgUQgoEmZ33EOjntmSvQkOE,13704
10
+ fast_cache_middleware-0.0.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
+ fast_cache_middleware-0.0.3.dist-info/RECORD,,