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

theoretically bug in db.set method? #136

Open
qyuzh opened this issue Oct 25, 2023 · 2 comments
Open

theoretically bug in db.set method? #136

qyuzh opened this issue Oct 25, 2023 · 2 comments

Comments

@qyuzh
Copy link
Contributor

qyuzh commented Oct 25, 2023

theoretically bug in db.set method when current expire equal previous.

Is this code Better?

        if let Some(prev) = prev {
            if let Some(when) = prev.expires_at {
                if expires_at.is_none() || when != expires_at.unwrap() {
                    state.expirations.remove(&(when, key));
                }
            }
        }

than

        if let Some(prev) = prev {
            if let Some(when) = prev.expires_at {
                // clear expiration
                state.expirations.remove(&(when, key));
            }
        }
@Darksonn
Copy link
Collaborator

Nice catch. I somewhat prefer to swap their order so that we remove first, and then insert.

@qyuzh
Copy link
Contributor Author

qyuzh commented Oct 25, 2023

I opened a PR, help me review it please.

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

No branches or pull requests

2 participants