cachify 0.1.0__py3-none-any.whl → 0.2.0__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,44 +1,44 @@
1
- import inspect
2
- from typing import Callable
3
-
4
- from cachify._async import async_decorator
5
- from cachify._sync import sync_decorator
6
- from cachify.types import CacheConfig, CacheKeyFunction, F, Number
7
-
8
-
9
- def create_cache_decorator(
10
- ttl: Number,
11
- never_die: bool,
12
- cache_key_func: CacheKeyFunction | None,
13
- ignore_fields: tuple[str, ...],
14
- config: CacheConfig,
15
- ) -> Callable[[F], F]:
16
- """
17
- Create a cache decorator with the given configuration.
18
-
19
- This is a shared factory used by both memory_cache and redis_cache
20
- to avoid code duplication.
21
- """
22
- if cache_key_func and ignore_fields:
23
- raise ValueError("Either cache_key_func or ignore_fields can be provided, but not both")
24
-
25
- def decorator(function: F) -> F:
26
- if inspect.iscoroutinefunction(function):
27
- return async_decorator(
28
- function=function,
29
- ttl=ttl,
30
- never_die=never_die,
31
- cache_key_func=cache_key_func,
32
- ignore_fields=ignore_fields,
33
- config=config,
34
- )
35
- return sync_decorator(
36
- function=function,
37
- ttl=ttl,
38
- never_die=never_die,
39
- cache_key_func=cache_key_func,
40
- ignore_fields=ignore_fields,
41
- config=config,
42
- )
43
-
44
- return decorator
1
+ import inspect
2
+ from typing import Callable
3
+
4
+ from cachify._async import async_decorator
5
+ from cachify._sync import sync_decorator
6
+ from cachify.types import CacheConfig, CacheKeyFunction, F, Number
7
+
8
+
9
+ def create_cache_decorator(
10
+ ttl: Number,
11
+ never_die: bool,
12
+ cache_key_func: CacheKeyFunction | None,
13
+ ignore_fields: tuple[str, ...],
14
+ config: CacheConfig,
15
+ ) -> Callable[[F], F]:
16
+ """
17
+ Create a cache decorator with the given configuration.
18
+
19
+ This is a shared factory used by both memory_cache and redis_cache
20
+ to avoid code duplication.
21
+ """
22
+ if cache_key_func and ignore_fields:
23
+ raise ValueError("Either cache_key_func or ignore_fields can be provided, but not both")
24
+
25
+ def decorator(function: F) -> F:
26
+ if inspect.iscoroutinefunction(function):
27
+ return async_decorator(
28
+ function=function,
29
+ ttl=ttl,
30
+ never_die=never_die,
31
+ cache_key_func=cache_key_func,
32
+ ignore_fields=ignore_fields,
33
+ config=config,
34
+ )
35
+ return sync_decorator(
36
+ function=function,
37
+ ttl=ttl,
38
+ never_die=never_die,
39
+ cache_key_func=cache_key_func,
40
+ ignore_fields=ignore_fields,
41
+ config=config,
42
+ )
43
+
44
+ return decorator
@@ -1,10 +1,10 @@
1
- import functools
2
- from typing import Any, Callable
3
-
4
-
5
- @functools.cache
6
- def get_function_id(function: Callable[..., Any]) -> str:
7
- """
8
- Returns the unique identifier for the function, which is a combination of its module and qualified name.
9
- """
10
- return f"{function.__module__}.{function.__qualname__}"
1
+ import functools
2
+ from typing import Any, Callable
3
+
4
+
5
+ @functools.cache
6
+ def get_function_id(function: Callable[..., Any]) -> str:
7
+ """
8
+ Returns the unique identifier for the function, which is a combination of its module and qualified name.
9
+ """
10
+ return f"{function.__module__}.{function.__qualname__}"
cachify/utils/locks.py CHANGED
@@ -1,6 +1,6 @@
1
- import asyncio
2
- import threading
3
- from collections import defaultdict
4
-
5
- ASYNC_LOCKS: defaultdict[str, asyncio.Lock] = defaultdict(asyncio.Lock)
6
- SYNC_LOCKS: defaultdict[str, threading.Lock] = defaultdict(threading.Lock)
1
+ import asyncio
2
+ import threading
3
+ from collections import defaultdict
4
+
5
+ ASYNC_LOCKS: defaultdict[str, asyncio.Lock] = defaultdict(asyncio.Lock)
6
+ SYNC_LOCKS: defaultdict[str, threading.Lock] = defaultdict(threading.Lock)
@@ -1,9 +1,9 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: cachify
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A simple cache library with sync/async support, Memory and Redis backend
5
- Home-page: https://github.com/PulsarDataSolutions/cachify
6
5
  License: MIT
6
+ License-File: LICENSE
7
7
  Keywords: cachify,cache,caching,redis,async,decorator,memoization
8
8
  Author: dynalz
9
9
  Author-email: git@pulsar.finance
@@ -20,6 +20,7 @@ Classifier: Programming Language :: Python :: 3.14
20
20
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
21
  Classifier: Typing :: Typed
22
22
  Requires-Dist: redis[hiredis] (>5.0.0)
23
+ Project-URL: Homepage, https://github.com/PulsarDataSolutions/cachify
23
24
  Project-URL: Repository, https://github.com/PulsarDataSolutions/cachify
24
25
  Description-Content-Type: text/markdown
25
26
 
@@ -0,0 +1,24 @@
1
+ cachify/__init__.py,sha256=6nMXo3w8LCkcgsT7-60FLxRZvwL5ZU4FjmQ51nKiXZ8,582
2
+ cachify/cache.py,sha256=zJM9J4DdBXyGquQUTDJJ_voC51p-RM_CQcC-4DM92Gg,4021
3
+ cachify/config/__init__.py,sha256=ZvLLEsprTbKai3-uUTbZ6Axbgf-xw-7sxmz8Y62YdT4,98
4
+ cachify/features/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ cachify/features/never_die.py,sha256=NJvCJhHMjxxaVZCC5xrUATcBBm4OXXHdipOg6wjOfV4,7111
6
+ cachify/memory_cache.py,sha256=2UEnYXSJJ0XlqVM7sJ2GkPW1reU7DRtfifHEdbJQrYY,1328
7
+ cachify/redis/__init__.py,sha256=geuYVjwJdddlhrnt45cHzkJ7Anrhttm2F3Q3r0TTMLk,410
8
+ cachify/redis/config.py,sha256=Gvlj_hrUlsIGYqu50dghrv83R5UEOMJa4jVeK-nBAOs,3558
9
+ cachify/redis/lock.py,sha256=XbE5GHZIWUs9gqyfgle3Bur5CfKJ1pLhgtLctmZLB94,7281
10
+ cachify/redis_cache.py,sha256=WVc26EpAVSyQptD3guDD2LuPDgnuL72BCvhln-n84hc,873
11
+ cachify/storage/__init__.py,sha256=8FJOYwjg8LHVoNkyupdgKOR61LPfX5Bpz_mvnn-T-oU,250
12
+ cachify/storage/memory_storage.py,sha256=rsQqoymWczzkfXisF-9Tc9UGQem936U6_vd9Uo-sWnU,1481
13
+ cachify/storage/redis_storage.py,sha256=wZaKg7h98cmESpqiOmh906D5wfNBxYN80x-LQDLtb-c,4767
14
+ cachify/types/__init__.py,sha256=OataAgBEQXxpc376uZFM6cmdzJLUkzkj_H8XiKq5zpU,2641
15
+ cachify/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ cachify/utils/arguments.py,sha256=7NcuntqxK7G1UV4wrIaLNfxE0E7Gr-MmPWi9U-JyQ9o,2000
17
+ cachify/utils/decorator_factory.py,sha256=brraPKR7ZJqdTbp8s5tEk6D517CKOlo9z1ZLoqhoz_s,1325
18
+ cachify/utils/functions.py,sha256=AA1GXJEEBsIr2NX9h6AslAdmqKaWUcjnf1q5kA216uY,312
19
+ cachify/utils/locks.py,sha256=7x-4XK27NiM_Eu04pftUgEgu91w8B3rE15jjAl0g1AE,216
20
+ cachify-0.2.0.dist-info/METADATA,sha256=_6x4eITA6xnzD6AEvW9SvzqTMPQ8TyWjFIeyup15lZ0,5374
21
+ cachify-0.2.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
22
+ cachify-0.2.0.dist-info/entry_points.txt,sha256=a8B7GSYgDPfUClqct0o7yyBbJ61AWgSSy1idL6YZLUM,45
23
+ cachify-0.2.0.dist-info/licenses/LICENSE,sha256=7skG67r9ikSVcEHmj9WXaDmxm8uqHIU5HWDza5LB6JQ,1071
24
+ cachify-0.2.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: poetry-core 2.2.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Pulsar Finance
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Pulsar Finance
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,24 +0,0 @@
1
- cachify/__init__.py,sha256=5Q5eK7Pyty7-eSF99DBSa79FnKq27MGNiCYPkhY3uxo,553
2
- cachify/cache.py,sha256=Y1hh3t9DlcaG8KoVi3gZHevPzZf59WPIdDb_VsooHqo,4137
3
- cachify/config/__init__.py,sha256=xWH80AN6A2O2DlrY3ITkLYEkqnNv8WqGWhNAszVZq5w,102
4
- cachify/features/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- cachify/features/never_die.py,sha256=A8sVAgVP-s6hlEs8FqrmHFg_-TJ8Bu8E8M_d3gwBpdg,7330
6
- cachify/memory_cache.py,sha256=9bDgV0Lb7ZB_ieARQmiKyi0nrn7E-cqQX9lH4d9xFFk,1365
7
- cachify/redis/__init__.py,sha256=4ZCbpo1tfU1O06pvIjerCuSR7XfopJly7mWgp9NZ_tg,429
8
- cachify/redis/config.py,sha256=ShaNvP6-vRnxWtFk3cD6lzMcPigpCM8FnFVBv21jxk4,3673
9
- cachify/redis/lock.py,sha256=NwrCa-z9fcXLvuaUrTsdCeNqoHIhR-Rm0J56fZ_0kT4,7513
10
- cachify/redis_cache.py,sha256=roQ3ENdqUe6n03nX4RFB0wrOKowUEcEY96BJV48hzRQ,900
11
- cachify/storage/__init__.py,sha256=p62r3EJPidhkHtw2OgV-gAH4U-wDtB8ZU_IbE5e3CdQ,259
12
- cachify/storage/memory_storage.py,sha256=lwSbCYqT4NyRwgPs8TMSjHIp5aTJs6bXmQmMKFOIhVM,1533
13
- cachify/storage/redis_storage.py,sha256=NOwWaSjca6591pMbLaHMmtelutXkAhxuWbFkoWChRnA,4905
14
- cachify/types/__init__.py,sha256=VpDvMLFAxVo-J9MISzE-liT-wiZzo4AYHG7cQgVi-TI,2736
15
- cachify/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- cachify/utils/arguments.py,sha256=m4TMXmZ5nC9tDyS4BBDjsW41Q7L2LOx6zEWFN70ux70,2065
17
- cachify/utils/decorator_factory.py,sha256=5Cqz_QQDc7jVvVb_yscF41EC5o8mOda2nDeR6NvPGh8,1369
18
- cachify/utils/functions.py,sha256=QqpdJVvmwkPtHnPhFj5xpouJL_jQ29ySOjPkgvNg-Y0,322
19
- cachify/utils/locks.py,sha256=nvNnFuu3ooGpptH4-5tpaUU2YJmXlVqZ_GTQRWmKX7g,222
20
- cachify-0.1.0.dist-info/entry_points.txt,sha256=a8B7GSYgDPfUClqct0o7yyBbJ61AWgSSy1idL6YZLUM,45
21
- cachify-0.1.0.dist-info/LICENSE,sha256=nOY-lEC7Zaqf05sDxPYQ8iOGaShYMB2zf1Kr-M5hE-w,1092
22
- cachify-0.1.0.dist-info/METADATA,sha256=pkPXhJ5vOrtH8qi56CaESR_gI4B7c_iaZbg-ZNrlNVc,5340
23
- cachify-0.1.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
24
- cachify-0.1.0.dist-info/RECORD,,