hishel 1.0.0.dev3__py3-none-any.whl → 1.1.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hishel
3
- Version: 1.0.0.dev3
3
+ Version: 1.1.1
4
4
  Summary: Elegant HTTP Caching for Python
5
5
  Project-URL: Homepage, https://hishel.com
6
6
  Project-URL: Source, https://github.com/karpetrosyan/hishel
@@ -82,9 +82,10 @@ Description-Content-Type: text/markdown
82
82
  - 🔄 **Async & Sync** - Full support for both synchronous and asynchronous workflows
83
83
  - 🎨 **Type Safe** - Fully typed with comprehensive type hints
84
84
  - 🧪 **Well Tested** - Extensive test coverage and battle-tested
85
- - 🎛️ **Configurable** - Fine-grained control over caching behavior
86
- - **Memory Efficient** - Streaming support prevents loading large payloads into memory
85
+ - 🎛️ **Configurable** - Fine-grained control over caching behavior with flexible policies
86
+ - 💨 **Memory Efficient** - Streaming support prevents loading large payloads into memory
87
87
  - 🌐 **Universal** - Works with any ASGI application (Starlette, Litestar, BlackSheep, etc.)
88
+ - 🎯 **GraphQL Support** - Cache GraphQL queries with body-sensitive content caching
88
89
 
89
90
  ## 📦 Installation
90
91
 
@@ -175,12 +176,14 @@ from hishel.asgi import ASGICacheMiddleware
175
176
  app = ASGICacheMiddleware(app)
176
177
 
177
178
  # Or configure with options
178
- from hishel import AsyncSqliteStorage, CacheOptions
179
+ from hishel import AsyncSqliteStorage, CacheOptions, SpecificationPolicy
179
180
 
180
181
  app = ASGICacheMiddleware(
181
182
  app,
182
183
  storage=AsyncSqliteStorage(),
183
- cache_options=CacheOptions(shared=True)
184
+ policy=SpecificationPolicy(
185
+ cache_options=CacheOptions(shared=True)
186
+ ),
184
187
  )
185
188
  ```
186
189
 
@@ -225,21 +228,49 @@ async def get_data():
225
228
 
226
229
  ## 🎛️ Advanced Configuration
227
230
 
228
- ### Custom Cache Options
231
+ ### Caching Policies
232
+
233
+ Hishel supports two types of caching policies:
234
+
235
+ **SpecificationPolicy** - RFC 9111 compliant HTTP caching (default):
229
236
 
230
237
  ```python
231
- from hishel import CacheOptions
238
+ from hishel import CacheOptions, SpecificationPolicy
232
239
  from hishel.httpx import SyncCacheClient
233
240
 
234
241
  client = SyncCacheClient(
235
- cache_options=CacheOptions(
236
- shared=False, # Use as private cache (browser-like)
237
- supported_methods=["GET", "HEAD", "POST"], # Cache GET, HEAD, and POST
238
- allow_stale=True # Allow serving stale responses
242
+ policy=SpecificationPolicy(
243
+ cache_options=CacheOptions(
244
+ shared=False, # Use as private cache (browser-like)
245
+ supported_methods=["GET", "HEAD", "POST"], # Cache GET, HEAD, and POST
246
+ allow_stale=True # Allow serving stale responses
247
+ )
248
+ )
249
+ )
250
+ ```
251
+
252
+ **FilterPolicy** - Custom filtering logic for fine-grained control:
253
+
254
+ ```python
255
+ from hishel import FilterPolicy, BaseFilter, Request
256
+ from hishel.httpx import AsyncCacheClient
257
+
258
+ class CacheOnlyAPIRequests(BaseFilter[Request]):
259
+ def needs_body(self) -> bool:
260
+ return False
261
+
262
+ def apply(self, item: Request, body: bytes | None) -> bool:
263
+ return "/api/" in str(item.url)
264
+
265
+ client = AsyncCacheClient(
266
+ policy=FilterPolicy(
267
+ request_filters=[CacheOnlyAPIRequests()]
239
268
  )
240
269
  )
241
270
  ```
242
271
 
272
+ [Learn more about policies →](https://hishel.com/dev/policies/)
273
+
243
274
  ### Custom Storage Backend
244
275
 
245
276
  ```python
@@ -255,6 +286,60 @@ storage = SyncSqliteStorage(
255
286
  client = SyncCacheClient(storage=storage)
256
287
  ```
257
288
 
289
+ ### GraphQL and Body-Sensitive Caching
290
+
291
+ Cache GraphQL queries and other POST requests by including the request body in the cache key.
292
+
293
+ **Using per-request header:**
294
+
295
+ ```python
296
+ from hishel import FilterPolicy
297
+ from hishel.httpx import SyncCacheClient
298
+
299
+ client = SyncCacheClient(
300
+ policy=FilterPolicy()
301
+ )
302
+
303
+ # Cache GraphQL queries - different queries get different cache entries
304
+ graphql_query = """
305
+ query GetUser($id: ID!) {
306
+ user(id: $id) {
307
+ name
308
+ email
309
+ }
310
+ }
311
+ """
312
+
313
+ response = client.post(
314
+ "https://api.example.com/graphql",
315
+ json={"query": graphql_query, "variables": {"id": "123"}},
316
+ headers={"X-Hishel-Body-Key": "true"} # Enable body-based caching
317
+ )
318
+
319
+ # Different query will be cached separately
320
+ response = client.post(
321
+ "https://api.example.com/graphql",
322
+ json={"query": graphql_query, "variables": {"id": "456"}},
323
+ headers={"X-Hishel-Body-Key": "true"}
324
+ )
325
+ ```
326
+
327
+ **Using global configuration:**
328
+
329
+ ```python
330
+ from hishel.httpx import SyncCacheClient
331
+ from hishel import FilterPolicy
332
+
333
+ # Enable body-based caching for all requests
334
+ client = SyncCacheClient(policy=FilterPolicy(use_body_key=True))
335
+
336
+ # All POST requests automatically include body in cache key
337
+ response = client.post(
338
+ "https://api.example.com/graphql",
339
+ json={"query": graphql_query, "variables": {"id": "123"}}
340
+ )
341
+ ```
342
+
258
343
  ## 🏗️ Architecture
259
344
 
260
345
  Hishel uses a **sans-I/O state machine** architecture that separates HTTP caching logic from I/O operations:
@@ -266,13 +351,11 @@ Hishel uses a **sans-I/O state machine** architecture that separates HTTP cachin
266
351
 
267
352
  ## 🔮 Roadmap
268
353
 
269
- While Hishel currently supports HTTPX and Requests, we're actively working on:
354
+ We're actively working on:
270
355
 
271
- - 🎯 Additional HTTP client integrations
272
- - 🎯 Server-side caching support
273
- - 🎯 More storage backends
274
- - 🎯 Advanced caching strategies
275
356
  - 🎯 Performance optimizations
357
+ - 🎯 More integrations
358
+ - 🎯 Partial responses support
276
359
 
277
360
  ## 📚 Documentation
278
361
 
@@ -284,6 +367,7 @@ Comprehensive documentation is available at [https://hishel.com/dev](https://his
284
367
  - [ASGI Integration](https://hishel.com/dev/asgi)
285
368
  - [FastAPI Integration](https://hishel.com/dev/fastapi)
286
369
  - [BlackSheep Integration](https://hishel.com/dev/integrations/blacksheep)
370
+ - [GraphQL Integration](https://hishel.com/dev/integrations/graphql)
287
371
  - [Storage Backends](https://hishel.com/dev/storages)
288
372
  - [Request/Response Metadata](https://hishel.com/dev/metadata)
289
373
  - [RFC 9111 Specification](https://hishel.com/dev/specification)
@@ -326,6 +410,45 @@ Hishel is inspired by and builds upon the excellent work in the Python HTTP ecos
326
410
 
327
411
  All notable changes to this project will be documented in this file.
328
412
 
413
+ ## 1.1.1 - 2025-11-01
414
+ ### ⚙️ Miscellaneous Tasks
415
+ - Bump the python-packages group with 10 updates (#396)
416
+
417
+ ### 📦 Dependencies
418
+ - Bump actions/upload-artifact from 4 to 5 (#395)
419
+ - Bump actions/download-artifact from 4 to 6 (#394)
420
+ - Bump astral-sh/setup-uv from 5 to 7 (#393)
421
+
422
+ ## 1.1.0 - 2025-10-31
423
+ ### ⚙️ Miscellaneous Tasks
424
+ - Add in memory example
425
+
426
+ ### 🐛 Bug Fixes
427
+ - Pass any response with non-expected status code on revalidation to client
428
+ - Pass any response with non-expected status code on revalidation to client
429
+
430
+ ### 🚀 Features
431
+ - Allow setting storage base with via `database_path` for sqlite storage
432
+
433
+ ## 1.0.0 - 2025-10-28
434
+ ### ⚙️ Miscellaneous Tasks
435
+ - Add examples, improve docs
436
+
437
+ ## 1.0.0b1 - 2025-10-28
438
+ ### ♻️ Refactoring
439
+ - Add policies
440
+
441
+ ### ⚙️ Miscellaneous Tasks
442
+ - Improve sans-io diagram colors
443
+ - Add graphql docs
444
+
445
+ ### 🐛 Bug Fixes
446
+ - Body-sensitive responses caching
447
+ - Filter out `Transfer-Encoding` header for asgi responses
448
+
449
+ ### 🚀 Features
450
+ - Add global `use_body_key` setting
451
+
329
452
  ## 1.0.0.dev3 - 2025-10-26
330
453
  ### ♻️ Refactoring
331
454
  - Replace pairs with entries, simplify storage API
@@ -0,0 +1,24 @@
1
+ hishel/__init__.py,sha256=XYnAlT2Wkrg0Cw5u4DLJAsC3TjWDOQJr5kqQMuXxEJI,1796
2
+ hishel/_async_cache.py,sha256=4wm6YBL9ClNOg4WbEkALTJVCIXuzQU80MVem2C3hHrQ,8785
3
+ hishel/_async_httpx.py,sha256=WB35o7CseRDz89dpqoWNLXYEkDxqeSo709eR3oPXP7Q,7536
4
+ hishel/_policies.py,sha256=1ae_rmDF7oaG91-lQyOGVaTrRX8uI2GImmu5gN6WJa4,1135
5
+ hishel/_sync_cache.py,sha256=k0AN0M--yR4Jc6SiAreaxPUFiwEt5Dx7wi9jqW9sy50,8510
6
+ hishel/_sync_httpx.py,sha256=FbnJrdoLftPDVNUzYkAtz-JOTNtiBPJ2c1ZOcU0JnmE,7368
7
+ hishel/_utils.py,sha256=kR7RnhFqLzFRmB-YNnZteQVP0iDPUouCscA0_FHHFls,3837
8
+ hishel/asgi.py,sha256=ocXzqrrYGazeJxlKFcz1waoKvKGOqJ7YBEAmly4Towk,14998
9
+ hishel/fastapi.py,sha256=CVWCyXTxBPwG_XALo-Oldekv4lqMgH2-W-PPZ9rZjXg,10826
10
+ hishel/httpx.py,sha256=99a8X9COPiPHSgGW61O2uMWMZB7dY93Ty9DTCJ9C18Q,467
11
+ hishel/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ hishel/requests.py,sha256=FbOBMvgNSWkH0Bh0qZdr-dhCYG6siR5Lmxcu5eMay3s,6409
13
+ hishel/_core/_headers.py,sha256=hGaT6o1F-gs1pm5RpdGb0IMQL3uJYDH1xpwJLy28Cys,17514
14
+ hishel/_core/_spec.py,sha256=YfZfMYS4--o0v-AQZ37vVzHfc-Mh-SEHcl9SrBM9Y7Y,102963
15
+ hishel/_core/models.py,sha256=EabP2qnjYVzhPWhQer3QFmdDE6TDbqEBEqPHzv25VnA,7978
16
+ hishel/_core/_storages/_async_base.py,sha256=iZ6Mb30P0ho5h4UU5bgOrcsSMZ1427j9tht-tupZs68,2106
17
+ hishel/_core/_storages/_async_sqlite.py,sha256=QZEWroGZKGhCMf7CcYpZfKZdKd88R8elQCoPge0Khxc,15674
18
+ hishel/_core/_storages/_packing.py,sha256=mC8LMFQ5uPfFOgingKm2WKFO_DwcZ1OjTgI6xc0hfJI,3708
19
+ hishel/_core/_storages/_sync_base.py,sha256=qfOvcFY5qvrzSh4ztV2Trlxft-BF7An5SFsLlEb8EeE,2075
20
+ hishel/_core/_storages/_sync_sqlite.py,sha256=P3vIp636tTtM553-sBTZkam3-sNv0EEkh1rRSd1Qw90,15167
21
+ hishel-1.1.1.dist-info/METADATA,sha256=-asM9uMqOksQJV8PucbLYqdeY5MPMz54d0bGwAsCs6E,16115
22
+ hishel-1.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ hishel-1.1.1.dist-info/licenses/LICENSE,sha256=1qQj7pE0V2O9OIedvyOgLGLvZLaPd3nFEup3IBEOZjQ,1493
24
+ hishel-1.1.1.dist-info/RECORD,,
@@ -1,23 +0,0 @@
1
- hishel/__init__.py,sha256=HqU6RUrtlvEMTo5i7WbdSJvYoLQiyqkMJVbXrefd6Ww,1566
2
- hishel/_async_cache.py,sha256=He_wRJYMSy0aLinzlgQ76ohOos15Bbw3N2uu6cLGkZk,7216
3
- hishel/_async_httpx.py,sha256=e8JO37K6fF4UZlTGeMpsmMJtLLhGfdWQNLIhPahlbkU,7894
4
- hishel/_sync_cache.py,sha256=zYNrRoOeBUta-GO0yNRs7n-PQ4WglQLEzvbY5N9oZCU,6962
5
- hishel/_sync_httpx.py,sha256=eQlIwb3RrJNV3CEqs3xGQJByVOO3C_DXK8W5x60HZlQ,7726
6
- hishel/_utils.py,sha256=kD5ki4PKeYsNBMh3tAjsXggF2-_oeNz6aVlARxyl0H0,3842
7
- hishel/asgi.py,sha256=mbYFJHQJCRE6w0KcZiSe9qIHHPgRFuCwAwg9haJoMWI,14983
8
- hishel/fastapi.py,sha256=CVWCyXTxBPwG_XALo-Oldekv4lqMgH2-W-PPZ9rZjXg,10826
9
- hishel/httpx.py,sha256=99a8X9COPiPHSgGW61O2uMWMZB7dY93Ty9DTCJ9C18Q,467
10
- hishel/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- hishel/requests.py,sha256=Bi0_1O2xgFlWqG1g6OR1gpb5MY8CKJmgLPDEG6bhuXM,6533
12
- hishel/_core/_headers.py,sha256=hGaT6o1F-gs1pm5RpdGb0IMQL3uJYDH1xpwJLy28Cys,17514
13
- hishel/_core/_spec.py,sha256=yJsOmNU5dMXXBw80ZLnse9Tl4UGkHmiyyfjv1Q0eP9w,103871
14
- hishel/_core/models.py,sha256=YBXpk5GRWsB8ppksehTaIDJ_V5KAENKspSj-kLvJUPY,5169
15
- hishel/_core/_storages/_async_base.py,sha256=iZ6Mb30P0ho5h4UU5bgOrcsSMZ1427j9tht-tupZs68,2106
16
- hishel/_core/_storages/_async_sqlite.py,sha256=QNo5oWnnHAU0rTPJJbE9d6__xG_jWrG3-atoyE2j3q0,15555
17
- hishel/_core/_storages/_packing.py,sha256=mC8LMFQ5uPfFOgingKm2WKFO_DwcZ1OjTgI6xc0hfJI,3708
18
- hishel/_core/_storages/_sync_base.py,sha256=qfOvcFY5qvrzSh4ztV2Trlxft-BF7An5SFsLlEb8EeE,2075
19
- hishel/_core/_storages/_sync_sqlite.py,sha256=A-L6fDU1JvVDzHNzV396V3U3sFPLycrxSnD00DHrTvs,15048
20
- hishel-1.0.0.dev3.dist-info/METADATA,sha256=CLK-XP376Y4IuDGQgYxzRhJhfoi9Z281HlZccTOVXqE,12884
21
- hishel-1.0.0.dev3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
22
- hishel-1.0.0.dev3.dist-info/licenses/LICENSE,sha256=1qQj7pE0V2O9OIedvyOgLGLvZLaPd3nFEup3IBEOZjQ,1493
23
- hishel-1.0.0.dev3.dist-info/RECORD,,