cachify 0.3.0__py3-none-any.whl → 0.3.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.
- cachify/redis/config.py +15 -10
- {cachify-0.3.0.dist-info → cachify-0.3.1.dist-info}/METADATA +2 -2
- {cachify-0.3.0.dist-info → cachify-0.3.1.dist-info}/RECORD +6 -6
- {cachify-0.3.0.dist-info → cachify-0.3.1.dist-info}/WHEEL +1 -1
- {cachify-0.3.0.dist-info → cachify-0.3.1.dist-info}/entry_points.txt +0 -0
- {cachify-0.3.0.dist-info → cachify-0.3.1.dist-info}/licenses/LICENSE +0 -0
cachify/redis/config.py
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
-
from typing import TYPE_CHECKING, Literal, get_args, overload
|
|
4
|
+
from typing import TYPE_CHECKING, Literal, TypeAlias, get_args, overload
|
|
5
5
|
|
|
6
6
|
if TYPE_CHECKING:
|
|
7
7
|
from redis import Redis
|
|
8
8
|
from redis.asyncio import Redis as AsyncRedis
|
|
9
|
+
from redis.cluster import RedisCluster
|
|
10
|
+
from redis.asyncio.cluster import RedisCluster as AsyncRedisCluster
|
|
11
|
+
|
|
12
|
+
SyncRedisClient: TypeAlias = "Redis | RedisCluster"
|
|
13
|
+
AsyncRedisClient: TypeAlias = "AsyncRedis | AsyncRedisCluster"
|
|
9
14
|
|
|
10
15
|
OnErrorType = Literal["silent", "raise"]
|
|
11
16
|
|
|
12
|
-
DEFAULT_KEY_PREFIX = "cachify"
|
|
17
|
+
DEFAULT_KEY_PREFIX = "{cachify}"
|
|
13
18
|
DEFAULT_LOCK_TIMEOUT = 10
|
|
14
19
|
|
|
15
20
|
|
|
@@ -17,19 +22,19 @@ DEFAULT_LOCK_TIMEOUT = 10
|
|
|
17
22
|
class RedisConfig:
|
|
18
23
|
"""Configuration for Redis cache backend."""
|
|
19
24
|
|
|
20
|
-
sync_client:
|
|
21
|
-
async_client:
|
|
25
|
+
sync_client: SyncRedisClient | None
|
|
26
|
+
async_client: AsyncRedisClient | None
|
|
22
27
|
key_prefix: str
|
|
23
28
|
lock_timeout: int
|
|
24
29
|
on_error: OnErrorType
|
|
25
30
|
|
|
26
31
|
@overload
|
|
27
|
-
def get_client(self, is_async: Literal[True]) ->
|
|
32
|
+
def get_client(self, is_async: Literal[True]) -> AsyncRedisClient: ...
|
|
28
33
|
|
|
29
34
|
@overload
|
|
30
|
-
def get_client(self, is_async: Literal[False]) ->
|
|
35
|
+
def get_client(self, is_async: Literal[False]) -> SyncRedisClient: ...
|
|
31
36
|
|
|
32
|
-
def get_client(self, is_async: bool) ->
|
|
37
|
+
def get_client(self, is_async: bool) -> SyncRedisClient | AsyncRedisClient:
|
|
33
38
|
"""Get the appropriate Redis client based on is_async flag."""
|
|
34
39
|
if is_async:
|
|
35
40
|
client = self.async_client
|
|
@@ -49,8 +54,8 @@ _redis_config: RedisConfig | None = None
|
|
|
49
54
|
|
|
50
55
|
|
|
51
56
|
def setup_redis_config(
|
|
52
|
-
sync_client:
|
|
53
|
-
async_client:
|
|
57
|
+
sync_client: SyncRedisClient | None = None,
|
|
58
|
+
async_client: AsyncRedisClient | None = None,
|
|
54
59
|
key_prefix: str = DEFAULT_KEY_PREFIX,
|
|
55
60
|
lock_timeout: int = DEFAULT_LOCK_TIMEOUT,
|
|
56
61
|
on_error: OnErrorType = "silent",
|
|
@@ -64,7 +69,7 @@ def setup_redis_config(
|
|
|
64
69
|
Args:
|
|
65
70
|
sync_client: Redis sync client instance (redis.Redis)
|
|
66
71
|
async_client: Redis async client instance (redis.asyncio.Redis)
|
|
67
|
-
key_prefix: Prefix for all cache keys in Redis (default: "
|
|
72
|
+
key_prefix: Prefix for all cache keys in Redis (default: "{cachify}")
|
|
68
73
|
lock_timeout: Timeout in seconds for distributed locks (default: 10)
|
|
69
74
|
on_error: Error handling mode - "silent" treats errors as cache miss,
|
|
70
75
|
"raise" propagates exceptions (default: "silent")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cachify
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: A simple cache library with sync/async support, Memory and Redis backend
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -135,7 +135,7 @@ from cachify import setup_redis_config, rcache
|
|
|
135
135
|
# Configure Redis (call once at startup)
|
|
136
136
|
setup_redis_config(
|
|
137
137
|
sync_client=redis.from_url("redis://localhost:6379/0"),
|
|
138
|
-
key_prefix="myapp", # default: "cachify", prefix searchable on redis "PREFIX:*"
|
|
138
|
+
key_prefix="{myapp}", # default: "{cachify}", prefix searchable on redis "PREFIX:*"
|
|
139
139
|
lock_timeout=10, # default: 10, maximum lock lifetime in seconds
|
|
140
140
|
on_error="silent", # "silent" (default) or "raise" in case of redis errors
|
|
141
141
|
)
|
|
@@ -5,7 +5,7 @@ cachify/features/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
|
5
5
|
cachify/features/never_die.py,sha256=virRY8788D1fGmwQQYmbMhLIKRkWVYNPywR-kl18u9c,7105
|
|
6
6
|
cachify/memory_cache.py,sha256=Ge1yU6fJfv_o3aCgU7ky5pHxvDSmfQ0xBFnJeC61jLQ,1485
|
|
7
7
|
cachify/redis/__init__.py,sha256=geuYVjwJdddlhrnt45cHzkJ7Anrhttm2F3Q3r0TTMLk,410
|
|
8
|
-
cachify/redis/config.py,sha256=
|
|
8
|
+
cachify/redis/config.py,sha256=QUlsZS5vOXZzyGjN75Lq2kkszPrV1U6e_mRUgyC5JFM,3870
|
|
9
9
|
cachify/redis/lock.py,sha256=XbE5GHZIWUs9gqyfgle3Bur5CfKJ1pLhgtLctmZLB94,7281
|
|
10
10
|
cachify/redis_cache.py,sha256=s9Uf2DdBwoZAFSld0fK18S70gz7B4APUB701_mfL-2A,917
|
|
11
11
|
cachify/storage/__init__.py,sha256=8FJOYwjg8LHVoNkyupdgKOR61LPfX5Bpz_mvnn-T-oU,250
|
|
@@ -17,8 +17,8 @@ cachify/utils/arguments.py,sha256=UJhcC8erS9h8sJTNlILK3uvr6Mg1BWkaI-2esV7-LNs,18
|
|
|
17
17
|
cachify/utils/errors.py,sha256=IuPQuOV0rfzeHUoLi5DrdmGSz3YnB1OF4URPdIy6qQI,42
|
|
18
18
|
cachify/utils/functions.py,sha256=AA1GXJEEBsIr2NX9h6AslAdmqKaWUcjnf1q5kA216uY,312
|
|
19
19
|
cachify/utils/hash.py,sha256=L95dFggFMKa-fQXXIwlRtPsJfWYKFlWzvbfTKlHR-o0,558
|
|
20
|
-
cachify-0.3.
|
|
21
|
-
cachify-0.3.
|
|
22
|
-
cachify-0.3.
|
|
23
|
-
cachify-0.3.
|
|
24
|
-
cachify-0.3.
|
|
20
|
+
cachify-0.3.1.dist-info/METADATA,sha256=dFcWvVCi8X4SSOVvpSGm8s5VvM_gVX59-MvXvonk5IY,7598
|
|
21
|
+
cachify-0.3.1.dist-info/WHEEL,sha256=kJCRJT_g0adfAJzTx2GUMmS80rTJIVHRCfG0DQgLq3o,88
|
|
22
|
+
cachify-0.3.1.dist-info/entry_points.txt,sha256=a8B7GSYgDPfUClqct0o7yyBbJ61AWgSSy1idL6YZLUM,45
|
|
23
|
+
cachify-0.3.1.dist-info/licenses/LICENSE,sha256=zUzOFiuoPIQzGktjk4kL78hpi57iWD6-Kug_96OgUO0,1071
|
|
24
|
+
cachify-0.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|