Closed BUTURUM closed 1 year ago
The conversations plugin doesn't do this. The session plugin calls write for all session parts as soon as it's done handling an update.
The conversations plugin has to serialise the entire session so that it can replay old session data as necessary. The session plugin sees that someone has accessed the session, but it has no way to determine whether or not it was modified, so it needs to write back the data.
This is therefore the expected behaviour.
Thanks for explanation @KnorpelSenf. Now this behaviour for me isn't unexpected, but unwanted. I don't want to request database after literally every message inside conversation, when nothing in database supposed to be changed. In my opinion it wastes machine's resources and harms application's logic. How to avoid it?
Well the solution was lazy sessions. Thanks everybody for help.
I am sorry, propably I closed issue too early. I found out that there no way to lazy multi sessions! Despite I solved my own issue, I assume that respond to my question could be useful for other people. So how to use lazy sessions in order to allow request to database only if it reasonable change, but conversation plugin's data?
conversation.external
calls which temporarily copy the data to the session again in order to avoid logic errors.@BUTURUM Is your issue resolved?
Closing due to inactivity.
I use two sessions in my bot: one with external storage, one with memory storage (for conversations).
I am traking when different methods of storage was called and was suprised when I found that each time when user enters the conversation
profile
storage'swrite
method is called with no changes. I didn't expect such behaviour and still don't understand it. Encoding to documentation conversation should only use session provided for them (conversation
session).