mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 04:35:24 +00:00
Allow to specify a limit to message cache size
This commit is contained in:
parent
0b83b1d55b
commit
fd5d19dab1
@ -190,6 +190,10 @@ class Client(Methods):
|
||||
A value that is too high may result in network related issues.
|
||||
Defaults to 1.
|
||||
|
||||
max_message_cache_size (``int``, *optional*):
|
||||
Set the maximum size of the message cache.
|
||||
Defaults to 10000.
|
||||
|
||||
storage_engine (:obj:`~pyrogram.storage.Storage`, *optional*):
|
||||
Pass an instance of your own implementation of session storage engine.
|
||||
Useful when you want to store your session in databases like Mongo, Redis, etc.
|
||||
@ -217,6 +221,7 @@ class Client(Methods):
|
||||
UPDATES_WATCHDOG_INTERVAL = 15 * 60
|
||||
|
||||
MAX_CONCURRENT_TRANSMISSIONS = 1
|
||||
MAX_MESSAGE_CACHE_SIZE = 10000
|
||||
|
||||
mimetypes = MimeTypes()
|
||||
mimetypes.readfp(StringIO(mime_types))
|
||||
@ -251,6 +256,7 @@ class Client(Methods):
|
||||
sleep_threshold: int = Session.SLEEP_THRESHOLD,
|
||||
hide_password: bool = False,
|
||||
max_concurrent_transmissions: int = MAX_CONCURRENT_TRANSMISSIONS,
|
||||
max_message_cache_size: int = MAX_MESSAGE_CACHE_SIZE,
|
||||
storage_engine: Storage = None,
|
||||
init_connection_params: "raw.base.JSONValue" = None
|
||||
):
|
||||
@ -284,6 +290,7 @@ class Client(Methods):
|
||||
self.sleep_threshold = sleep_threshold
|
||||
self.hide_password = hide_password
|
||||
self.max_concurrent_transmissions = max_concurrent_transmissions
|
||||
self.max_message_cache_size = max_message_cache_size
|
||||
self.init_connection_params = init_connection_params
|
||||
|
||||
self.executor = ThreadPoolExecutor(self.workers, thread_name_prefix="Handler")
|
||||
@ -320,7 +327,7 @@ class Client(Methods):
|
||||
|
||||
self.me: Optional[User] = None
|
||||
|
||||
self.message_cache = Cache(10000)
|
||||
self.message_cache = Cache(self.max_message_cache_size)
|
||||
|
||||
# Sometimes, for some reason, the server will stop sending updates and will only respond to pings.
|
||||
# This watchdog will invoke updates.GetState in order to wake up the server and enable it sending updates again
|
||||
|
Loading…
Reference in New Issue
Block a user