Kekik 1.7.2__tar.gz → 1.7.3__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.

Files changed (48) hide show
  1. {kekik-1.7.2 → kekik-1.7.3}/Kekik/cache.py +89 -7
  2. {kekik-1.7.2 → kekik-1.7.3}/Kekik.egg-info/PKG-INFO +1 -1
  3. {kekik-1.7.2 → kekik-1.7.3}/PKG-INFO +1 -1
  4. {kekik-1.7.2 → kekik-1.7.3}/setup.py +1 -1
  5. {kekik-1.7.2 → kekik-1.7.3}/Kekik/BIST.py +0 -0
  6. {kekik-1.7.2 → kekik-1.7.3}/Kekik/Domain2IP.py +0 -0
  7. {kekik-1.7.2 → kekik-1.7.3}/Kekik/Nesne.py +0 -0
  8. {kekik-1.7.2 → kekik-1.7.3}/Kekik/Sifreleme/AESManager.py +0 -0
  9. {kekik-1.7.2 → kekik-1.7.3}/Kekik/Sifreleme/CryptoJS.py +0 -0
  10. {kekik-1.7.2 → kekik-1.7.3}/Kekik/Sifreleme/HexCodec.py +0 -0
  11. {kekik-1.7.2 → kekik-1.7.3}/Kekik/Sifreleme/NaysHash.py +0 -0
  12. {kekik-1.7.2 → kekik-1.7.3}/Kekik/Sifreleme/Packer.py +0 -0
  13. {kekik-1.7.2 → kekik-1.7.3}/Kekik/Sifreleme/StringCodec.py +0 -0
  14. {kekik-1.7.2 → kekik-1.7.3}/Kekik/Sifreleme/__init__.py +0 -0
  15. {kekik-1.7.2 → kekik-1.7.3}/Kekik/__init__.py +0 -0
  16. {kekik-1.7.2 → kekik-1.7.3}/Kekik/cli.py +0 -0
  17. {kekik-1.7.2 → kekik-1.7.3}/Kekik/csv2dict.py +0 -0
  18. {kekik-1.7.2 → kekik-1.7.3}/Kekik/dict2csv.py +0 -0
  19. {kekik-1.7.2 → kekik-1.7.3}/Kekik/dict2json.py +0 -0
  20. {kekik-1.7.2 → kekik-1.7.3}/Kekik/dosya2set.py +0 -0
  21. {kekik-1.7.2 → kekik-1.7.3}/Kekik/dosya_indir.py +0 -0
  22. {kekik-1.7.2 → kekik-1.7.3}/Kekik/hwid_kontrol.py +0 -0
  23. {kekik-1.7.2 → kekik-1.7.3}/Kekik/kisi_ver/__init__.py +0 -0
  24. {kekik-1.7.2 → kekik-1.7.3}/Kekik/kisi_ver/biyografiler.py +0 -0
  25. {kekik-1.7.2 → kekik-1.7.3}/Kekik/kisi_ver/isimler.py +0 -0
  26. {kekik-1.7.2 → kekik-1.7.3}/Kekik/kisi_ver/soyisimler.py +0 -0
  27. {kekik-1.7.2 → kekik-1.7.3}/Kekik/link_islemleri.py +0 -0
  28. {kekik-1.7.2 → kekik-1.7.3}/Kekik/list2html.py +0 -0
  29. {kekik-1.7.2 → kekik-1.7.3}/Kekik/liste_fetis.py +0 -0
  30. {kekik-1.7.2 → kekik-1.7.3}/Kekik/mail_gonder.py +0 -0
  31. {kekik-1.7.2 → kekik-1.7.3}/Kekik/okunabilir_byte.py +0 -0
  32. {kekik-1.7.2 → kekik-1.7.3}/Kekik/proxy_ver.py +0 -0
  33. {kekik-1.7.2 → kekik-1.7.3}/Kekik/qr_ver.py +0 -0
  34. {kekik-1.7.2 → kekik-1.7.3}/Kekik/ses_fetis.py +0 -0
  35. {kekik-1.7.2 → kekik-1.7.3}/Kekik/slugify.py +0 -0
  36. {kekik-1.7.2 → kekik-1.7.3}/Kekik/terminal_baslik.py +0 -0
  37. {kekik-1.7.2 → kekik-1.7.3}/Kekik/txt_fetis.py +0 -0
  38. {kekik-1.7.2 → kekik-1.7.3}/Kekik/unicode_tr.py +0 -0
  39. {kekik-1.7.2 → kekik-1.7.3}/Kekik/zaman_donustur.py +0 -0
  40. {kekik-1.7.2 → kekik-1.7.3}/Kekik.egg-info/SOURCES.txt +0 -0
  41. {kekik-1.7.2 → kekik-1.7.3}/Kekik.egg-info/dependency_links.txt +0 -0
  42. {kekik-1.7.2 → kekik-1.7.3}/Kekik.egg-info/entry_points.txt +0 -0
  43. {kekik-1.7.2 → kekik-1.7.3}/Kekik.egg-info/requires.txt +0 -0
  44. {kekik-1.7.2 → kekik-1.7.3}/Kekik.egg-info/top_level.txt +0 -0
  45. {kekik-1.7.2 → kekik-1.7.3}/LICENSE +0 -0
  46. {kekik-1.7.2 → kekik-1.7.3}/MANIFEST.in +0 -0
  47. {kekik-1.7.2 → kekik-1.7.3}/README.md +0 -0
  48. {kekik-1.7.2 → kekik-1.7.3}/setup.cfg +0 -0
@@ -9,13 +9,19 @@ import threading
9
9
  import asyncio
10
10
  import pickle
11
11
 
12
- # Redis için asenkron client (Redis yoksa fallback yapılacak)
13
- import redis.asyncio as redis
12
+ # Redis client (Redis yoksa fallback yapılacak)
13
+ import redis.asyncio as redisAsync
14
+ import redis as redis
14
15
 
15
16
  # -----------------------------------------------------
16
17
  # Sabitler ve Yardımcı Fonksiyonlar
17
18
  # -----------------------------------------------------
18
- UNLIMITED = None
19
+ UNLIMITED = None
20
+
21
+ REDIS_HOST = "127.0.0.1"
22
+ REDIS_PORT = 6379
23
+ REDIS_DB = 0
24
+ REDIS_PASS = None
19
25
 
20
26
  def normalize_for_key(value):
21
27
  """
@@ -147,6 +153,80 @@ class SyncCache:
147
153
  if self._ttl is not UNLIMITED:
148
154
  self._times[key] = time.time()
149
155
 
156
+ class HybridSyncCache:
157
+ """
158
+ Senkron işlemler için, öncelikle Redis cache kullanılmaya çalışılır.
159
+ Redis'ten veri alınamazsa ya da hata oluşursa, SyncCache (in-memory) fallback uygulanır.
160
+ """
161
+ def __init__(self, ttl=None):
162
+ self._ttl = ttl
163
+
164
+ try:
165
+ self.redis = redis.Redis(
166
+ host = REDIS_HOST,
167
+ port = REDIS_PORT,
168
+ db = REDIS_DB,
169
+ password = REDIS_PASS,
170
+ decode_responses = False
171
+ )
172
+ self.redis.ping()
173
+ except Exception:
174
+ self.redis = None
175
+
176
+ self.memory = SyncCache(ttl)
177
+
178
+ def get(self, key):
179
+ # Önce Redis ile deniyoruz:
180
+ if self.redis:
181
+ try:
182
+ data = self.redis.get(key)
183
+ except Exception:
184
+ data = None
185
+ if data is not None:
186
+ try:
187
+ result = pickle.loads(data)
188
+ # konsol.log(f"[yellow][~] {key}")
189
+ return result
190
+ except Exception:
191
+ # Deserialize hatası durumunda fallback'e geç
192
+ pass
193
+
194
+ # Redis'te veri yoksa, yerel cache'ten alıyoruz.
195
+ try:
196
+ return self.memory[key]
197
+ except KeyError:
198
+ raise KeyError(key)
199
+
200
+ def set(self, key, value):
201
+ try:
202
+ ser = pickle.dumps(value)
203
+ except Exception:
204
+ # Serialization hatası durumunda yerel cache'e yazalım.
205
+ self.memory[key] = value
206
+ return
207
+
208
+ if self.redis:
209
+ try:
210
+ if self._ttl is not None:
211
+ self.redis.set(key, ser, ex=self._ttl)
212
+ else:
213
+ self.redis.set(key, ser)
214
+ return
215
+ except Exception:
216
+ # Redis'e yazılamazsa yerel cache'e geçelim.
217
+ self.memory[key] = value
218
+ return
219
+ else:
220
+ # Redis kullanılmıyorsa direkt yerel cache'e yaz.
221
+ self.memory[key] = value
222
+
223
+ # HybridSyncCache'in subscriptable olması için:
224
+ def __getitem__(self, key):
225
+ return self.get(key)
226
+
227
+ def __setitem__(self, key, value):
228
+ self.set(key, value)
229
+
150
230
  # -----------------------------------------------------
151
231
  # Asenkron Cache (In-Memory) ve Redis Hybrid Cache
152
232
  # -----------------------------------------------------
@@ -244,9 +324,11 @@ class HybridAsyncCache:
244
324
  self._ttl = ttl
245
325
 
246
326
  try:
247
- self.redis = redis.Redis(
248
- host = "127.0.0.1",
249
- port = 6379,
327
+ self.redis = redisAsync.Redis(
328
+ host = REDIS_HOST,
329
+ port = REDIS_PORT,
330
+ db = REDIS_DB,
331
+ password = REDIS_PASS,
250
332
  decode_responses = False
251
333
  )
252
334
  except Exception:
@@ -392,7 +474,7 @@ def kekik_cache(ttl=UNLIMITED, unless=None, is_fastapi=False, use_redis=True):
392
474
  return async_wrapper
393
475
  else:
394
476
  # Senkron fonksiyonlar için
395
- func.__cache = SyncCache(ttl)
477
+ func.__cache = HybridSyncCache(ttl) if use_redis else SyncCache(ttl)
396
478
 
397
479
  @wraps(func)
398
480
  def sync_wrapper(*args, **kwargs):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: Kekik
3
- Version: 1.7.2
3
+ Version: 1.7.3
4
4
  Summary: İşlerimizi kolaylaştıracak fonksiyonların el altında durduğu kütüphane..
5
5
  Home-page: https://github.com/keyiflerolsun/Kekik
6
6
  Author: keyiflerolsun
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: Kekik
3
- Version: 1.7.2
3
+ Version: 1.7.3
4
4
  Summary: İşlerimizi kolaylaştıracak fonksiyonların el altında durduğu kütüphane..
5
5
  Home-page: https://github.com/keyiflerolsun/Kekik
6
6
  Author: keyiflerolsun
@@ -6,7 +6,7 @@ from io import open
6
6
  setup(
7
7
  # ? Genel Bilgiler
8
8
  name = "Kekik",
9
- version = "1.7.2",
9
+ version = "1.7.3",
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