Kekik 1.6.7__py3-none-any.whl → 1.6.9__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.
Potentially problematic release.
This version of Kekik might be problematic. Click here for more details.
- Kekik/cache.py +27 -10
- {Kekik-1.6.7.dist-info → Kekik-1.6.9.dist-info}/METADATA +1 -1
- {Kekik-1.6.7.dist-info → Kekik-1.6.9.dist-info}/RECORD +7 -7
- {Kekik-1.6.7.dist-info → Kekik-1.6.9.dist-info}/LICENSE +0 -0
- {Kekik-1.6.7.dist-info → Kekik-1.6.9.dist-info}/WHEEL +0 -0
- {Kekik-1.6.7.dist-info → Kekik-1.6.9.dist-info}/entry_points.txt +0 -0
- {Kekik-1.6.7.dist-info → Kekik-1.6.9.dist-info}/top_level.txt +0 -0
Kekik/cache.py
CHANGED
|
@@ -174,28 +174,41 @@ async def make_cache_key(args, kwargs, is_fastapi=False):
|
|
|
174
174
|
def kekik_cache(ttl=UNLIMITED, unless=None, is_fastapi=False):
|
|
175
175
|
"""
|
|
176
176
|
Bir fonksiyon veya coroutine'in sonucunu cache'ler.
|
|
177
|
-
|
|
178
|
-
:param ttl: Cache’in geçerlilik süresi (saniye). UNLIMITED ise süresizdir.
|
|
179
|
-
:param unless: Fonksiyonun sonucunu argüman olarak alan bir callable.
|
|
180
|
-
Eğer True dönerse, sonuç cache'e alınmaz.
|
|
181
|
-
:param is_fastapi: Eğer True ise, cache key'i oluştururken FastAPI request nesnesine özel şekilde davranır.
|
|
182
177
|
|
|
183
|
-
|
|
178
|
+
Args:
|
|
179
|
+
ttl (int, optional): Cache’in geçerlilik süresi (saniye).
|
|
180
|
+
Eğer `UNLIMITED` ise süresizdir. Varsayılan olarak `UNLIMITED`'dir.
|
|
181
|
+
unless (callable, optional): Fonksiyonun sonucunu argüman olarak alan bir callable.
|
|
182
|
+
Eğer `True` dönerse, sonuç cache'e alınmaz. Varsayılan olarak `None`'dır.
|
|
183
|
+
is_fastapi (bool, optional): Eğer `True` ise, cache key'i oluştururken FastAPI request nesnesine özel şekilde davranır.
|
|
184
|
+
Varsayılan olarak `False`'tır.
|
|
185
|
+
|
|
186
|
+
Notlar:
|
|
187
|
+
-------
|
|
188
|
+
Normalde yalnızca Redis cache kullanılmak istenir.
|
|
189
|
+
Ancak Redis'e ulaşılamayan durumlarda RAM fallback kullanılır.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
Örn.:
|
|
184
194
|
|
|
185
|
-
@kekik_cache(ttl=15, unless=lambda
|
|
195
|
+
@kekik_cache(ttl=15, unless=lambda sonuc: bool(sonuc is None))
|
|
186
196
|
async def bakalim(param):
|
|
187
|
-
|
|
197
|
+
# Burada cache işlemi yapılır.
|
|
198
|
+
return param
|
|
188
199
|
"""
|
|
189
200
|
# Parametresiz kullanıldığında
|
|
190
201
|
if callable(ttl):
|
|
191
202
|
return kekik_cache(UNLIMITED, unless=unless, is_fastapi=is_fastapi)(ttl)
|
|
192
203
|
|
|
193
204
|
def decorator(func):
|
|
194
|
-
func.__cache = AsyncCache(ttl)
|
|
195
|
-
|
|
196
205
|
if asyncio.iscoroutinefunction(func):
|
|
197
206
|
@wraps(func)
|
|
198
207
|
async def async_wrapper(*args, **kwargs):
|
|
208
|
+
# Lazy initialization: İlk çağrıda cache oluşturuluyor
|
|
209
|
+
if not hasattr(func, "__cache"):
|
|
210
|
+
func.__cache = AsyncCache(ttl)
|
|
211
|
+
|
|
199
212
|
key = await make_cache_key(args, kwargs, is_fastapi)
|
|
200
213
|
|
|
201
214
|
try:
|
|
@@ -207,6 +220,10 @@ def kekik_cache(ttl=UNLIMITED, unless=None, is_fastapi=False):
|
|
|
207
220
|
else:
|
|
208
221
|
@wraps(func)
|
|
209
222
|
def sync_wrapper(*args, **kwargs):
|
|
223
|
+
# Lazy initialization: İlk çağrıda cache oluşturuluyor
|
|
224
|
+
if not hasattr(func, "__cache"):
|
|
225
|
+
func.__cache = AsyncCache(ttl)
|
|
226
|
+
|
|
210
227
|
key = (args, tuple(sorted(kwargs.items())))
|
|
211
228
|
|
|
212
229
|
try:
|
|
@@ -2,7 +2,7 @@ Kekik/BIST.py,sha256=gFvEFdLGgsxUq33AkqOr5pVGsSm9jR0v6DVwoSzhX7w,1375
|
|
|
2
2
|
Kekik/Domain2IP.py,sha256=dMDatPElTMfLORzC_QN9znex8Se1eid3EPsxAe5S1aQ,4851
|
|
3
3
|
Kekik/Nesne.py,sha256=33pp49cZkRCoa0aUFfzVMpx5FSJchSdiKhm97Nkol1Q,7020
|
|
4
4
|
Kekik/__init__.py,sha256=Iy-O4c_DuY2ttQJv6j7xoVk3IS9EcC0Aqx3vhFvCgd8,1057
|
|
5
|
-
Kekik/cache.py,sha256=
|
|
5
|
+
Kekik/cache.py,sha256=I_ThRqrqstsNw9MB8RY7r_yJs88WIW6S44L_nKg6YC4,8657
|
|
6
6
|
Kekik/cli.py,sha256=I--MV8-okBSUYAaV4fRsMeB2n57OJITrgbEnK1OdTPY,3648
|
|
7
7
|
Kekik/csv2dict.py,sha256=HO0AgREXE0yM7cL4OwqpkCGm2pz31RTb0mhnTg6gdwo,423
|
|
8
8
|
Kekik/dict2csv.py,sha256=AcGvEg9i5MXtwMwg7WiDxOj8h9LldNjjcRiWFwA9XJU,560
|
|
@@ -34,9 +34,9 @@ Kekik/kisi_ver/__init__.py,sha256=gH613YZC3ziE7f67dViefRSuwDwsHyVvXHpM5CzZ2q4,13
|
|
|
34
34
|
Kekik/kisi_ver/biyografiler.py,sha256=5Xv1ixaDGHGtl5Nf92jo9dPgF3jDXOGEPmWgoEsn9j8,189486
|
|
35
35
|
Kekik/kisi_ver/isimler.py,sha256=zHVimWL_4TvoLE3qzWQslDBc8-IJZSB02s0vRwsVM1g,88066
|
|
36
36
|
Kekik/kisi_ver/soyisimler.py,sha256=YQJYp2SjENgwOaCa9mmShxPYeeUll2cq8Vox-d8_kB8,78485
|
|
37
|
-
Kekik-1.6.
|
|
38
|
-
Kekik-1.6.
|
|
39
|
-
Kekik-1.6.
|
|
40
|
-
Kekik-1.6.
|
|
41
|
-
Kekik-1.6.
|
|
42
|
-
Kekik-1.6.
|
|
37
|
+
Kekik-1.6.9.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
38
|
+
Kekik-1.6.9.dist-info/METADATA,sha256=vK0fxtk8HFZ8GG_gxRQ20Uh8zH-rkqrazlvLAQBGnfY,43959
|
|
39
|
+
Kekik-1.6.9.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
40
|
+
Kekik-1.6.9.dist-info/entry_points.txt,sha256=yjBifxtRlqfg8lPkH4Bu-urSa5ecptCHsuth-DcyWcg,59
|
|
41
|
+
Kekik-1.6.9.dist-info/top_level.txt,sha256=NotddscfgxawvuRyAa7xkgnMhyteFDcBxb5aU5GY3BM,6
|
|
42
|
+
Kekik-1.6.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|