Kekik 1.6.3__tar.gz → 1.6.5__tar.gz
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-1.6.3 → kekik-1.6.5}/Kekik/cache.py +46 -14
- {kekik-1.6.3 → kekik-1.6.5}/Kekik.egg-info/PKG-INFO +1 -1
- {kekik-1.6.3 → kekik-1.6.5}/PKG-INFO +1 -1
- {kekik-1.6.3 → kekik-1.6.5}/setup.py +1 -1
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/BIST.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/Domain2IP.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/Nesne.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/Sifreleme/AESManager.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/Sifreleme/CryptoJS.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/Sifreleme/HexCodec.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/Sifreleme/NaysHash.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/Sifreleme/Packer.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/Sifreleme/StringCodec.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/Sifreleme/__init__.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/__init__.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/cli.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/csv2dict.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/dict2csv.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/dict2json.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/dosya2set.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/dosya_indir.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/hwid_kontrol.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/kisi_ver/__init__.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/kisi_ver/biyografiler.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/kisi_ver/isimler.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/kisi_ver/soyisimler.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/link_islemleri.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/list2html.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/liste_fetis.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/mail_gonder.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/okunabilir_byte.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/proxy_ver.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/qr_ver.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/ses_fetis.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/slugify.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/terminal_baslik.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/txt_fetis.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/unicode_tr.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik/zaman_donustur.py +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik.egg-info/SOURCES.txt +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik.egg-info/dependency_links.txt +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik.egg-info/entry_points.txt +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik.egg-info/requires.txt +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/Kekik.egg-info/top_level.txt +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/LICENSE +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/MANIFEST.in +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/README.md +0 -0
- {kekik-1.6.3 → kekik-1.6.5}/setup.cfg +0 -0
|
@@ -11,7 +11,7 @@ UNLIMITED = None
|
|
|
11
11
|
class Cache:
|
|
12
12
|
"""
|
|
13
13
|
Basit in-memory cache yapısı.
|
|
14
|
-
TTL (time-to-live) süresi dolan veriler otomatik olarak temizlenir.
|
|
14
|
+
TTL (time-to-live) süresi dolan veriler otomatik olarak temizlenir (get/erişim anında kontrol edilir).
|
|
15
15
|
"""
|
|
16
16
|
def __init__(self, ttl=UNLIMITED):
|
|
17
17
|
self._data = {}
|
|
@@ -49,11 +49,34 @@ class AsyncCache(Cache):
|
|
|
49
49
|
"""
|
|
50
50
|
Asenkron işlemleri destekleyen cache yapısı.
|
|
51
51
|
Aynı key için gelen eşzamanlı çağrılar, futures kullanılarak tek sonuç üzerinden paylaşılır.
|
|
52
|
+
Ek olarak, belirli aralıklarla cache’i kontrol edip, süresi dolmuş verileri temizleyen otomatik temizleme görevi çalışır.
|
|
52
53
|
"""
|
|
53
|
-
def __init__(self, ttl=UNLIMITED):
|
|
54
|
+
def __init__(self, ttl=UNLIMITED, cleanup_interval=60 * 60):
|
|
55
|
+
"""
|
|
56
|
+
:param ttl: Her entry için geçerli süre (saniye). Örneğin 3600 saniye 1 saattir.
|
|
57
|
+
:param cleanup_interval: Otomatik temizleme görevinin kaç saniyede bir çalışacağını belirler.
|
|
58
|
+
"""
|
|
54
59
|
super().__init__(ttl)
|
|
55
60
|
self.futures = {}
|
|
56
61
|
|
|
62
|
+
if ttl is not UNLIMITED:
|
|
63
|
+
# TTL geçerli bir sayı olduğunda cleanup interval, ttl ile cleanup_interval'ın max'ı olarak ayarlanır.
|
|
64
|
+
self._cleanup_interval = max(ttl, cleanup_interval)
|
|
65
|
+
else:
|
|
66
|
+
# TTL tanımsız (UNLIMITED) ise cleanup_interval doğrudan kullanılır.
|
|
67
|
+
self._cleanup_interval = cleanup_interval
|
|
68
|
+
|
|
69
|
+
self._cleanup_task = asyncio.create_task(self._auto_cleanup())
|
|
70
|
+
|
|
71
|
+
async def _auto_cleanup(self):
|
|
72
|
+
"""Belirlenen aralıklarla cache içerisindeki süresi dolmuş entry'leri temizler."""
|
|
73
|
+
while True:
|
|
74
|
+
await asyncio.sleep(self._cleanup_interval)
|
|
75
|
+
# _data kopyasını almak, üzerinde dönüp silme yaparken hata almamak için.
|
|
76
|
+
keys = list(self._data.keys())
|
|
77
|
+
for key in keys:
|
|
78
|
+
self.remove_if_expired(key)
|
|
79
|
+
|
|
57
80
|
async def get(self, key):
|
|
58
81
|
"""
|
|
59
82
|
Belirtilen key için cache'de saklanan değeri asenkron olarak döndürür.
|
|
@@ -89,29 +112,38 @@ def _sync_maybe_cache(func, key, result, unless):
|
|
|
89
112
|
|
|
90
113
|
async def _async_compute_and_cache(func, key, unless, *args, **kwargs):
|
|
91
114
|
"""
|
|
92
|
-
Asenkron fonksiyon
|
|
93
|
-
|
|
115
|
+
Asenkron fonksiyon sonucunu hesaplar ve cache'e ekler.
|
|
116
|
+
Aynı key için işlem devam ediyorsa, mevcut sonucu bekler.
|
|
117
|
+
Sonuç, unless(result) True değilse cache'e eklenir.
|
|
94
118
|
"""
|
|
95
|
-
cache
|
|
119
|
+
# __cache'den cache nesnesini alıyoruz.
|
|
120
|
+
cache = func.__cache
|
|
121
|
+
|
|
122
|
+
# Aynı key için aktif bir future varsa, onun sonucunu döndür.
|
|
123
|
+
if key in cache.futures:
|
|
124
|
+
return await cache.futures[key]
|
|
125
|
+
|
|
126
|
+
# Yeni future oluşturuluyor ve cache.futures'e ekleniyor.
|
|
96
127
|
future = asyncio.Future()
|
|
97
128
|
cache.futures[key] = future
|
|
98
129
|
|
|
99
130
|
try:
|
|
131
|
+
# Asenkron fonksiyonu çalıştır ve sonucu elde et.
|
|
100
132
|
result = await func(*args, **kwargs)
|
|
133
|
+
future.set_result(result)
|
|
134
|
+
|
|
135
|
+
# unless koşuluna göre cache'e ekleme yap.
|
|
136
|
+
if unless is None or not unless(result):
|
|
137
|
+
await cache.set(key, result)
|
|
138
|
+
|
|
139
|
+
return result
|
|
101
140
|
except Exception as exc:
|
|
102
|
-
cache.futures.pop(key, None)
|
|
103
141
|
future.cancel()
|
|
104
142
|
raise exc
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if unless is None or not unless(result):
|
|
109
|
-
cache[key] = result
|
|
110
|
-
else:
|
|
143
|
+
finally:
|
|
144
|
+
# İşlem tamamlandığında future'ı temizle.
|
|
111
145
|
cache.futures.pop(key, None)
|
|
112
146
|
|
|
113
|
-
return result
|
|
114
|
-
|
|
115
147
|
async def make_cache_key(args, kwargs, is_fastapi=False):
|
|
116
148
|
"""
|
|
117
149
|
Cache key'ini oluşturur.
|
|
@@ -6,7 +6,7 @@ from io import open
|
|
|
6
6
|
setup(
|
|
7
7
|
# ? Genel Bilgiler
|
|
8
8
|
name = "Kekik",
|
|
9
|
-
version = "1.6.
|
|
9
|
+
version = "1.6.5",
|
|
10
10
|
url = "https://github.com/keyiflerolsun/Kekik",
|
|
11
11
|
description = "İşlerimizi kolaylaştıracak fonksiyonların el altında durduğu kütüphane..",
|
|
12
12
|
keywords = ["Kekik", "KekikAkademi", "keyiflerolsun"],
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|