upd
This commit is contained in:
parent
f30ccf3622
commit
12206aa9b1
@ -15,8 +15,8 @@ class TranscriptionDict:
|
||||
def __len__(self):
|
||||
return len(self._dict)
|
||||
|
||||
def get(self, key):
|
||||
return self._dict[key]['value']
|
||||
def get(self, key, default=None):
|
||||
return self._dict.get(key, {'value': default})['value']
|
||||
|
||||
def set(self, key, value):
|
||||
self._dict[key] = {'value': value, 'timestamp': time.time()}
|
||||
@ -28,7 +28,7 @@ class TranscriptionDict:
|
||||
|
||||
def _clean_expired_items(self):
|
||||
now = time.time()
|
||||
expired_items = [k for k, v in self._dict.items() if now - v[1] >= 180] # 180 seconds = 3 minutes
|
||||
expired_items = [k for k, v in self._dict.items() if now - v['timestamp'] >= 180] # 180 seconds = 3 minutes
|
||||
for key in expired_items:
|
||||
del self._dict[key]
|
||||
print(f"Cleaned {len(expired_items)} expired items from the cache")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user