Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush() or Delete() doesn't work in mysql #30

Open
mavidser opened this issue Aug 2, 2019 · 2 comments
Open

Flush() or Delete() doesn't work in mysql #30

mavidser opened this issue Aug 2, 2019 · 2 comments
Labels

Comments

@mavidser
Copy link

mavidser commented Aug 2, 2019

memory provider works fine, but if I use mysql - it basically seems to be a no-op with no queries executed. The session is changed in memory, but doesn't write to the database.

Currently using Set('key', '') and Destory(ctx) to perform these operations, but doesn't seem to be the right way.

@mavidser
Copy link
Author

mavidser commented Aug 2, 2019

Reading through the code, it looks like Release() checks if len(s.data) == 0 { return nil }

So, if I just had one key which I deleted, it doesn't get persisted.

Same case for Flush() too probably; unless, I have the wrong idea of what Flush() is supposed to do.

This issue seems to be a thing among other providers too. If confirmed, I can probably start working on a PR in the coming week.

@unknwon unknwon added the bug label Aug 4, 2019
@unknwon
Copy link
Contributor

unknwon commented Aug 4, 2019

Thanks for the feedback!

I think you're right, probably just remove code block that checks for len(s.data) == 0?

session/mysql/mysql.go

Lines 80 to 83 in d2c984b

// Skip encoding if the data is empty
if len(s.data) == 0 {
return nil
}

Flush() is meant to remove every key but still need to wait until Release to save to its persistent location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants