mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-03 14:04:51 +00:00
Allow to specify a limit to message cache size
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
c394a3ea3a
commit
8584ea3599
1 changed files with 9 additions and 2 deletions
|
|
@ -203,6 +203,10 @@ class Client(Methods):
|
||||||
A value that is too high may result in network related issues.
|
A value that is too high may result in network related issues.
|
||||||
Defaults to 1.
|
Defaults to 1.
|
||||||
|
|
||||||
|
max_message_cache_size (``int``, *optional*):
|
||||||
|
Set the maximum size of the message cache.
|
||||||
|
Defaults to 10000.
|
||||||
|
|
||||||
client_platform (:obj:`~pyrogram.enums.ClientPlatform`, *optional*):
|
client_platform (:obj:`~pyrogram.enums.ClientPlatform`, *optional*):
|
||||||
The platform where this client is running.
|
The platform where this client is running.
|
||||||
Defaults to 'other'
|
Defaults to 'other'
|
||||||
|
|
@ -224,6 +228,7 @@ class Client(Methods):
|
||||||
UPDATES_WATCHDOG_INTERVAL = 15 * 60
|
UPDATES_WATCHDOG_INTERVAL = 15 * 60
|
||||||
|
|
||||||
MAX_CONCURRENT_TRANSMISSIONS = 1
|
MAX_CONCURRENT_TRANSMISSIONS = 1
|
||||||
|
MAX_MESSAGE_CACHE_SIZE = 10000
|
||||||
|
|
||||||
mimetypes = MimeTypes()
|
mimetypes = MimeTypes()
|
||||||
mimetypes.readfp(StringIO(mime_types))
|
mimetypes.readfp(StringIO(mime_types))
|
||||||
|
|
@ -259,7 +264,8 @@ class Client(Methods):
|
||||||
sleep_threshold: int = Session.SLEEP_THRESHOLD,
|
sleep_threshold: int = Session.SLEEP_THRESHOLD,
|
||||||
hide_password: Optional[bool] = False,
|
hide_password: Optional[bool] = False,
|
||||||
max_concurrent_transmissions: int = MAX_CONCURRENT_TRANSMISSIONS,
|
max_concurrent_transmissions: int = MAX_CONCURRENT_TRANSMISSIONS,
|
||||||
client_platform: "enums.ClientPlatform" = enums.ClientPlatform.OTHER
|
client_platform: "enums.ClientPlatform" = enums.ClientPlatform.OTHER,
|
||||||
|
max_message_cache_size: int = MAX_MESSAGE_CACHE_SIZE
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
|
@ -292,6 +298,7 @@ class Client(Methods):
|
||||||
self.hide_password = hide_password
|
self.hide_password = hide_password
|
||||||
self.max_concurrent_transmissions = max_concurrent_transmissions
|
self.max_concurrent_transmissions = max_concurrent_transmissions
|
||||||
self.client_platform = client_platform
|
self.client_platform = client_platform
|
||||||
|
self.max_message_cache_size = max_message_cache_size
|
||||||
|
|
||||||
self.executor = ThreadPoolExecutor(self.workers, thread_name_prefix="Handler")
|
self.executor = ThreadPoolExecutor(self.workers, thread_name_prefix="Handler")
|
||||||
|
|
||||||
|
|
@ -341,7 +348,7 @@ class Client(Methods):
|
||||||
|
|
||||||
self.me: Optional[User] = None
|
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.
|
# 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
|
# This watchdog will invoke updates.GetState in order to wake up the server and enable it sending updates again
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue