Skip to content

Semantics for SessionStore::save method #182

Answered by maxcountryman
wt asked this question in Q&A
Discussion options

You must be logged in to vote

It's a good question and I thought about this a bit while we considered the collision issue.

Ultimately it's undefined behavior that's left up to the store implementation. It's certainly not wrong to throw an error. (Error::Backend with a meaningful message.) Or issue a warning and save via upsert. Or simply upsert transparently.

If we assume that only tower-sessions is allowed to mutate the persisted session state (which is what we expect) then really it shouldn't be possible to save before create--that could be a bug in the crate.

However, if an application decides to do something else and does mutate that stored state then we really can't make any guarantees.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by maxcountryman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants