Can we have an example persisting the state machine with sqlalchemy or redis/valkey #508
-
Dear python-statemachine developers Many thanks for this library. I am very keen to adapt this library for my project, but I am struggling thinking how I can persist the state machine with redis or valkey. I have found this example in the doc, but it's not very clear to me what's going on there - is I have also found the docs about domain models, and Django integration example that is based on the Mixin which looks very convenient. I don't use Django, but is it right ot assume this can be transferred quite easily to sqlalchemy? If so, would you mind adding some support or an example in the docs? Also wonder if there is an easy way to persist the state with redis or valkey. Many thanks again. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @shun-liang , how are you? Thanks for getting in touch. Do you need any extra information to be persisted or only the current state? |
Beta Was this translation helpful? Give feedback.
For example, a quick way to only persist the current state is to implement the
on_enter_state
hook:Redis persistence state machine using callback hook
Demonstrate a simple way of how to use redis to persist the current state.
This example uses the
start_value
constructor param and theon_enter_state
callback hook.