Kekik 1.7.2__tar.gz → 1.7.4__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.7.2 → kekik-1.7.4}/Kekik/cache.py +89 -7
- {kekik-1.7.2 → kekik-1.7.4}/Kekik.egg-info/PKG-INFO +21 -1
- {kekik-1.7.2 → kekik-1.7.4}/PKG-INFO +21 -1
- {kekik-1.7.2 → kekik-1.7.4}/README.md +20 -0
- {kekik-1.7.2 → kekik-1.7.4}/setup.py +1 -1
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/BIST.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/Domain2IP.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/Nesne.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/Sifreleme/AESManager.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/Sifreleme/CryptoJS.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/Sifreleme/HexCodec.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/Sifreleme/NaysHash.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/Sifreleme/Packer.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/Sifreleme/StringCodec.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/Sifreleme/__init__.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/__init__.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/cli.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/csv2dict.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/dict2csv.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/dict2json.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/dosya2set.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/dosya_indir.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/hwid_kontrol.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/kisi_ver/__init__.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/kisi_ver/biyografiler.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/kisi_ver/isimler.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/kisi_ver/soyisimler.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/link_islemleri.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/list2html.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/liste_fetis.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/mail_gonder.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/okunabilir_byte.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/proxy_ver.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/qr_ver.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/ses_fetis.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/slugify.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/terminal_baslik.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/txt_fetis.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/unicode_tr.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik/zaman_donustur.py +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik.egg-info/SOURCES.txt +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik.egg-info/dependency_links.txt +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik.egg-info/entry_points.txt +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik.egg-info/requires.txt +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/Kekik.egg-info/top_level.txt +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/LICENSE +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/MANIFEST.in +0 -0
- {kekik-1.7.2 → kekik-1.7.4}/setup.cfg +0 -0
|
@@ -9,13 +9,19 @@ import threading
|
|
|
9
9
|
import asyncio
|
|
10
10
|
import pickle
|
|
11
11
|
|
|
12
|
-
# Redis
|
|
13
|
-
import redis.asyncio as
|
|
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
|
|
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 =
|
|
248
|
-
host =
|
|
249
|
-
port =
|
|
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.
|
|
3
|
+
Version: 1.7.4
|
|
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
|
|
@@ -367,6 +367,26 @@ print(NaysHash().generate_xtoken(
|
|
|
367
367
|
# EygcmEIe3aU0TWIubaQTuBwbrqpY7HFcNDajlSKCT5c=
|
|
368
368
|
```
|
|
369
369
|
|
|
370
|
+
### **[kekik_cache](https://github.com/keyiflerolsun/Kekik/blob/main/Kekik/cache.py)**
|
|
371
|
+
```python
|
|
372
|
+
import Kekik.cache as cache
|
|
373
|
+
cache.REDIS_HOST = "127.0.0.1"
|
|
374
|
+
cache.REDIS_PORT = 6379
|
|
375
|
+
cache.REDIS_DB = 0
|
|
376
|
+
cache.REDIS_PASS = None
|
|
377
|
+
kekik_cache = cache.kekik_cache
|
|
378
|
+
|
|
379
|
+
@kekik_cache(ttl=5)
|
|
380
|
+
def sync_func(x, y):
|
|
381
|
+
time.sleep(1)
|
|
382
|
+
return x + y
|
|
383
|
+
|
|
384
|
+
@kekik_cache(ttl=5)
|
|
385
|
+
async def async_func(x, y):
|
|
386
|
+
await asyncio.sleep(1)
|
|
387
|
+
return x * y
|
|
388
|
+
```
|
|
389
|
+
|
|
370
390
|
### **[dict2json](https://github.com/keyiflerolsun/Kekik/blob/main/Kekik/dict2json.py)**
|
|
371
391
|
### **[dosya_indir](https://github.com/keyiflerolsun/Kekik/blob/main/Kekik/dosya_indir.py)**
|
|
372
392
|
### **[benim_hwid](https://github.com/keyiflerolsun/Kekik/blob/main/Kekik/hwid_kontrol.py)**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: Kekik
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.4
|
|
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
|
|
@@ -367,6 +367,26 @@ print(NaysHash().generate_xtoken(
|
|
|
367
367
|
# EygcmEIe3aU0TWIubaQTuBwbrqpY7HFcNDajlSKCT5c=
|
|
368
368
|
```
|
|
369
369
|
|
|
370
|
+
### **[kekik_cache](https://github.com/keyiflerolsun/Kekik/blob/main/Kekik/cache.py)**
|
|
371
|
+
```python
|
|
372
|
+
import Kekik.cache as cache
|
|
373
|
+
cache.REDIS_HOST = "127.0.0.1"
|
|
374
|
+
cache.REDIS_PORT = 6379
|
|
375
|
+
cache.REDIS_DB = 0
|
|
376
|
+
cache.REDIS_PASS = None
|
|
377
|
+
kekik_cache = cache.kekik_cache
|
|
378
|
+
|
|
379
|
+
@kekik_cache(ttl=5)
|
|
380
|
+
def sync_func(x, y):
|
|
381
|
+
time.sleep(1)
|
|
382
|
+
return x + y
|
|
383
|
+
|
|
384
|
+
@kekik_cache(ttl=5)
|
|
385
|
+
async def async_func(x, y):
|
|
386
|
+
await asyncio.sleep(1)
|
|
387
|
+
return x * y
|
|
388
|
+
```
|
|
389
|
+
|
|
370
390
|
### **[dict2json](https://github.com/keyiflerolsun/Kekik/blob/main/Kekik/dict2json.py)**
|
|
371
391
|
### **[dosya_indir](https://github.com/keyiflerolsun/Kekik/blob/main/Kekik/dosya_indir.py)**
|
|
372
392
|
### **[benim_hwid](https://github.com/keyiflerolsun/Kekik/blob/main/Kekik/hwid_kontrol.py)**
|
|
@@ -327,6 +327,26 @@ print(NaysHash().generate_xtoken(
|
|
|
327
327
|
# EygcmEIe3aU0TWIubaQTuBwbrqpY7HFcNDajlSKCT5c=
|
|
328
328
|
```
|
|
329
329
|
|
|
330
|
+
### **[kekik_cache](https://github.com/keyiflerolsun/Kekik/blob/main/Kekik/cache.py)**
|
|
331
|
+
```python
|
|
332
|
+
import Kekik.cache as cache
|
|
333
|
+
cache.REDIS_HOST = "127.0.0.1"
|
|
334
|
+
cache.REDIS_PORT = 6379
|
|
335
|
+
cache.REDIS_DB = 0
|
|
336
|
+
cache.REDIS_PASS = None
|
|
337
|
+
kekik_cache = cache.kekik_cache
|
|
338
|
+
|
|
339
|
+
@kekik_cache(ttl=5)
|
|
340
|
+
def sync_func(x, y):
|
|
341
|
+
time.sleep(1)
|
|
342
|
+
return x + y
|
|
343
|
+
|
|
344
|
+
@kekik_cache(ttl=5)
|
|
345
|
+
async def async_func(x, y):
|
|
346
|
+
await asyncio.sleep(1)
|
|
347
|
+
return x * y
|
|
348
|
+
```
|
|
349
|
+
|
|
330
350
|
### **[dict2json](https://github.com/keyiflerolsun/Kekik/blob/main/Kekik/dict2json.py)**
|
|
331
351
|
### **[dosya_indir](https://github.com/keyiflerolsun/Kekik/blob/main/Kekik/dosya_indir.py)**
|
|
332
352
|
### **[benim_hwid](https://github.com/keyiflerolsun/Kekik/blob/main/Kekik/hwid_kontrol.py)**
|
|
@@ -6,7 +6,7 @@ from io import open
|
|
|
6
6
|
setup(
|
|
7
7
|
# ? Genel Bilgiler
|
|
8
8
|
name = "Kekik",
|
|
9
|
-
version = "1.7.
|
|
9
|
+
version = "1.7.4",
|
|
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
|