mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2026-09-06 17:02:07 +00:00
Flush in-memory cache to session after a limit is reached
Should fully close #3989. Should help with #3235.
This commit is contained in:
@@ -52,3 +52,9 @@ class EntityCache:
|
||||
|
||||
def put(self, entity):
|
||||
self.hash_map[entity.id] = (entity.hash, entity.ty)
|
||||
|
||||
def retain(self, filter):
|
||||
self.hash_map = {k: v for k, v in self.hash_map.items() if filter(k)}
|
||||
|
||||
def __len__(self):
|
||||
return len(self.hash_map)
|
||||
|
||||
Reference in New Issue
Block a user