-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
There are two places in the current persistence setup where I think we can offer more customization for advanced users. All of this are just first ideas and up for discussion. If the dev team doesn't like the (use case value)/(maintenance workload) ratio, I'd be fine with not doing this.
-
Edit: We're dropping
insert/replace_data
see Drop BasePersistence.insert/replace_bot #2882 .Original comment:
We currently pass all data that goes through the persistence setup throughreplace/insert_bot
. While this is the safest way to make sure noBot
instance gets serialized, it can also introduce some overhead which could get noticable when you have large, nested data structures in yourchat/bot/user_data
or are handling many updates. Adanced users will know where in their data they have bot instances that should get replaced. So we could offer settings likereplace_bots_in_chat/bot/user_data
(defaulting to True) and only callreplace/insert_data
when necessary.One should note that we'd have to re-indroduce deepcopy into the built-in persistence classes (depending on the
replace_bots_in_*
settings, that is). See Customize context #2262 (comment) -
Adjust calling of update_persistence #2285 already made an effort to reduce the calls of
Dispatcher.update_persistence
. Still, updating after every update (or even handler call in case you're usingrun_async
) might be unecessary, especially when you're getting updates frequently. Similarly toPicklePersistence.on_flush
which allows users to control how oftenPP
writes to file, we would add a flag tellingDispatcher
to never automatically callDispatcher.update_persistence
at runtime (only on shutdown). Then users can callDispatcher.update_persistence
manually to their liking.