hishel 0.1.4__py3-none-any.whl → 1.0.0.dev0__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.
Files changed (42) hide show
  1. hishel/__init__.py +55 -53
  2. hishel/{beta/_async_cache.py → _async_cache.py} +3 -3
  3. hishel/{beta → _core}/__init__.py +6 -6
  4. hishel/{beta/_core → _core}/_async/_storages/_sqlite.py +3 -3
  5. hishel/{beta/_core → _core}/_base/_storages/_base.py +13 -1
  6. hishel/{beta/_core → _core}/_base/_storages/_packing.py +5 -5
  7. hishel/_core/_headers.py +636 -0
  8. hishel/{beta/_core → _core}/_spec.py +89 -2
  9. hishel/{beta/_core → _core}/_sync/_storages/_sqlite.py +3 -3
  10. hishel/{beta/_core → _core}/models.py +1 -1
  11. hishel/{beta/_sync_cache.py → _sync_cache.py} +3 -3
  12. hishel/{beta/httpx.py → httpx.py} +18 -7
  13. hishel/{beta/requests.py → requests.py} +15 -10
  14. hishel-1.0.0.dev0.dist-info/METADATA +321 -0
  15. hishel-1.0.0.dev0.dist-info/RECORD +19 -0
  16. hishel/_async/__init__.py +0 -5
  17. hishel/_async/_client.py +0 -30
  18. hishel/_async/_mock.py +0 -43
  19. hishel/_async/_pool.py +0 -201
  20. hishel/_async/_storages.py +0 -768
  21. hishel/_async/_transports.py +0 -282
  22. hishel/_controller.py +0 -581
  23. hishel/_exceptions.py +0 -10
  24. hishel/_files.py +0 -54
  25. hishel/_headers.py +0 -215
  26. hishel/_lfu_cache.py +0 -71
  27. hishel/_lmdb_types_.pyi +0 -53
  28. hishel/_s3.py +0 -122
  29. hishel/_serializers.py +0 -329
  30. hishel/_sync/__init__.py +0 -5
  31. hishel/_sync/_client.py +0 -30
  32. hishel/_sync/_mock.py +0 -43
  33. hishel/_sync/_pool.py +0 -201
  34. hishel/_sync/_storages.py +0 -768
  35. hishel/_sync/_transports.py +0 -282
  36. hishel/_synchronization.py +0 -37
  37. hishel/beta/_core/__init__.py +0 -0
  38. hishel/beta/_core/_headers.py +0 -301
  39. hishel-0.1.4.dist-info/METADATA +0 -404
  40. hishel-0.1.4.dist-info/RECORD +0 -41
  41. {hishel-0.1.4.dist-info → hishel-1.0.0.dev0.dist-info}/WHEEL +0 -0
  42. {hishel-0.1.4.dist-info → hishel-1.0.0.dev0.dist-info}/licenses/LICENSE +0 -0
hishel/__init__.py CHANGED
@@ -1,57 +1,59 @@
1
- import httpx
2
-
3
- from ._async import *
4
- from ._controller import *
5
- from ._exceptions import *
6
- from ._headers import *
7
- from ._serializers import *
8
- from ._sync import *
9
- from ._lfu_cache import *
1
+ from hishel._core._async._storages._sqlite import AsyncSqliteStorage
2
+ from hishel._core._base._storages._base import (
3
+ AsyncBaseStorage as AsyncBaseStorage,
4
+ SyncBaseStorage as SyncBaseStorage,
5
+ )
6
+ from hishel._core._headers import Headers as Headers
7
+ from hishel._core._spec import (
8
+ AnyState as AnyState,
9
+ CacheMiss as CacheMiss,
10
+ CacheOptions as CacheOptions,
11
+ CouldNotBeStored as CouldNotBeStored,
12
+ FromCache as FromCache,
13
+ IdleClient as IdleClient,
14
+ NeedRevalidation as NeedRevalidation,
15
+ NeedToBeUpdated as NeedToBeUpdated,
16
+ State as State,
17
+ StoreAndUse as StoreAndUse,
18
+ create_idle_state as create_idle_state,
19
+ )
20
+ from hishel._core._sync._storages._sqlite import SyncSqliteStorage
21
+ from hishel._core.models import (
22
+ CompletePair as CompletePair,
23
+ IncompletePair as IncompletePair,
24
+ Pair as Pair,
25
+ PairMeta as PairMeta,
26
+ Request as Request,
27
+ Response,
28
+ )
10
29
 
11
30
  __all__ = (
12
- # Old API
13
- "AsyncCacheClient",
14
- "MockAsyncConnectionPool",
15
- "MockAsyncTransport",
16
- "AsyncCacheConnectionPool",
31
+ # New API
32
+ ## States
33
+ "AnyState",
34
+ "IdleClient",
35
+ "CacheMiss",
36
+ "FromCache",
37
+ "NeedRevalidation",
38
+ "AnyState",
39
+ "CacheOptions",
40
+ "NeedToBeUpdated",
41
+ "State",
42
+ "StoreAndUse",
43
+ "CouldNotBeStored",
44
+ "create_idle_state",
45
+ ## Models
46
+ "Request",
47
+ "Response",
48
+ "Pair",
49
+ "IncompletePair",
50
+ "CompletePair",
51
+ "PairMeta",
52
+ ## Headers
53
+ "Headers",
54
+ ## Storages
55
+ "SyncBaseStorage",
17
56
  "AsyncBaseStorage",
18
- "AsyncFileStorage",
19
- "AsyncInMemoryStorage",
20
- "AsyncRedisStorage",
21
- "AsyncS3Storage",
22
- "AsyncSQLiteStorage",
23
- "AsyncCacheTransport",
24
- "HEURISTICALLY_CACHEABLE_STATUS_CODES",
25
- "Controller",
26
- "CacheControlError",
27
- "ParseError",
28
- "ValidationError",
29
- "CacheControl",
30
- "Vary",
31
- "BaseSerializer",
32
- "JSONSerializer",
33
- "Metadata",
34
- "PickleSerializer",
35
- "YAMLSerializer",
36
- "clone_model",
37
- "CacheClient",
38
- "MockConnectionPool",
39
- "MockTransport",
40
- "CacheConnectionPool",
41
- "BaseStorage",
42
- "FileStorage",
43
- "InMemoryStorage",
44
- "RedisStorage",
45
- "S3Storage",
46
- "SQLiteStorage",
47
- "CacheTransport",
48
- "LFUCache",
57
+ "SyncSqliteStorage",
58
+ "AsyncSqliteStorage",
49
59
  )
50
-
51
- def install_cache() -> None: # pragma: no cover
52
- httpx.AsyncClient = AsyncCacheClient # type: ignore
53
- httpx.Client = CacheClient # type: ignore
54
-
55
-
56
- __version__ = "0.1.4"
57
-
@@ -8,7 +8,7 @@ from typing import AsyncIterator, Awaitable, Callable
8
8
 
9
9
  from typing_extensions import assert_never
10
10
 
11
- from hishel.beta import (
11
+ from hishel import (
12
12
  AnyState,
13
13
  AsyncBaseStorage,
14
14
  AsyncSqliteStorage,
@@ -24,8 +24,8 @@ from hishel.beta import (
24
24
  StoreAndUse,
25
25
  create_idle_state,
26
26
  )
27
- from hishel.beta._core._spec import InvalidatePairs, vary_headers_match
28
- from hishel.beta._core.models import CompletePair
27
+ from hishel._core._spec import InvalidatePairs, vary_headers_match
28
+ from hishel._core.models import CompletePair
29
29
 
30
30
  logger = logging.getLogger("hishel.integrations.clients")
31
31
 
@@ -1,10 +1,10 @@
1
- from hishel.beta._core._async._storages._sqlite import AsyncSqliteStorage
2
- from hishel.beta._core._base._storages._base import (
1
+ from hishel._core._async._storages._sqlite import AsyncSqliteStorage
2
+ from hishel._core._base._storages._base import (
3
3
  AsyncBaseStorage as AsyncBaseStorage,
4
4
  SyncBaseStorage as SyncBaseStorage,
5
5
  )
6
- from hishel.beta._core._headers import Headers as Headers
7
- from hishel.beta._core._spec import (
6
+ from hishel._core._headers import Headers as Headers
7
+ from hishel._core._spec import (
8
8
  AnyState as AnyState,
9
9
  CacheMiss as CacheMiss,
10
10
  CacheOptions as CacheOptions,
@@ -17,8 +17,8 @@ from hishel.beta._core._spec import (
17
17
  StoreAndUse as StoreAndUse,
18
18
  create_idle_state as create_idle_state,
19
19
  )
20
- from hishel.beta._core._sync._storages._sqlite import SyncSqliteStorage
21
- from hishel.beta._core.models import (
20
+ from hishel._core._sync._storages._sqlite import SyncSqliteStorage
21
+ from hishel._core.models import (
22
22
  CompletePair as CompletePair,
23
23
  IncompletePair as IncompletePair,
24
24
  Pair as Pair,
@@ -15,9 +15,9 @@ from typing import (
15
15
 
16
16
  import anysqlite
17
17
 
18
- from hishel.beta._core._base._storages._base import AsyncBaseStorage, ensure_cache_dict
19
- from hishel.beta._core._base._storages._packing import pack, unpack
20
- from hishel.beta._core.models import (
18
+ from hishel._core._base._storages._base import AsyncBaseStorage, ensure_cache_dict
19
+ from hishel._core._base._storages._packing import pack, unpack
20
+ from hishel._core.models import (
21
21
  CompletePair,
22
22
  IncompletePair,
23
23
  Pair,
@@ -7,7 +7,7 @@ import uuid
7
7
  from abc import ABC
8
8
  from pathlib import Path
9
9
 
10
- from hishel.beta._core.models import CompletePair, IncompletePair, Request, Response
10
+ from hishel._core.models import CompletePair, IncompletePair, Request, Response
11
11
 
12
12
 
13
13
  class SyncBaseStorage(ABC):
@@ -87,6 +87,12 @@ class SyncBaseStorage(ABC):
87
87
  """
88
88
  raise NotImplementedError()
89
89
 
90
+ def close(self) -> None:
91
+ """
92
+ Close any resources held by the storage backend.
93
+ """
94
+ pass
95
+
90
96
  def is_soft_deleted(self, pair: IncompletePair | CompletePair) -> bool:
91
97
  """
92
98
  Check if a pair is soft deleted based on its metadata.
@@ -205,6 +211,12 @@ class AsyncBaseStorage(ABC):
205
211
  """
206
212
  raise NotImplementedError()
207
213
 
214
+ async def close(self) -> None:
215
+ """
216
+ Close any resources held by the storage backend.
217
+ """
218
+ pass
219
+
208
220
  def is_soft_deleted(self, pair: IncompletePair | CompletePair) -> bool:
209
221
  """
210
222
  Check if a pair is soft deleted based on its metadata.
@@ -6,8 +6,8 @@ from typing import TYPE_CHECKING, Any, Mapping, Optional, Union, overload
6
6
  import msgpack
7
7
  from typing_extensions import Literal, cast
8
8
 
9
- from hishel.beta._core._headers import Headers
10
- from hishel.beta._core.models import PairMeta, Request, Response
9
+ from hishel._core._headers import Headers
10
+ from hishel._core.models import PairMeta, Request, Response
11
11
 
12
12
 
13
13
  def filter_out_hishel_metadata(data: Mapping[str, Any]) -> dict[str, Any]:
@@ -15,7 +15,7 @@ def filter_out_hishel_metadata(data: Mapping[str, Any]) -> dict[str, Any]:
15
15
 
16
16
 
17
17
  if TYPE_CHECKING:
18
- from hishel.beta import CompletePair, IncompletePair
18
+ from hishel import CompletePair, IncompletePair
19
19
 
20
20
 
21
21
  @overload
@@ -39,7 +39,7 @@ def pack(
39
39
  /,
40
40
  kind: Literal["pair", "entry_db_key_index"],
41
41
  ) -> bytes:
42
- from hishel.beta import CompletePair, IncompletePair
42
+ from hishel import CompletePair, IncompletePair
43
43
 
44
44
  if kind == "entry_db_key_index":
45
45
  assert isinstance(value, uuid.UUID)
@@ -115,7 +115,7 @@ def unpack(
115
115
  /,
116
116
  kind: Literal["pair", "entry_db_key_index"],
117
117
  ) -> Union["CompletePair", "IncompletePair", uuid.UUID, None]:
118
- from hishel.beta import CompletePair, IncompletePair
118
+ from hishel import CompletePair, IncompletePair
119
119
 
120
120
  if value is None:
121
121
  return None