mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-11-15 21:30:45 +00:00
Use the new in-memory entity cache
This should avoid a disk access every time an input entity is needed, which is very often. Another step for #1141.
This commit is contained in:
@@ -235,7 +235,6 @@ class TelegramBaseClient(abc.ABC):
|
||||
#
|
||||
# The session files only wants the entities to persist
|
||||
# them to disk, and to save additional useful information.
|
||||
# TODO Make use of _entity_cache
|
||||
# TODO Session should probably return all cached
|
||||
# info of entities, not just the input versions
|
||||
self.session = session
|
||||
|
||||
@@ -308,8 +308,8 @@ class UserMethods(TelegramBaseClient):
|
||||
|
||||
try:
|
||||
# First try to get the entity from cache, otherwise figure it out
|
||||
return self.session.get_input_entity(peer)
|
||||
except ValueError:
|
||||
return self._entity_cache[peer]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
if isinstance(peer, str):
|
||||
|
||||
Reference in New Issue
Block a user