-
Notifications
You must be signed in to change notification settings - Fork 0
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
Update Store and TTL implementation #52
Conversation
/// Only set the key if it does not already exist. | ||
Nx, | ||
/// Only set the key if it already exists. | ||
Xx, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we can have these on cargo docs.
} | ||
pub struct InnerStoreLocked<'a> { | ||
state: MutexGuard<'a, State>, | ||
waker: &'a Notify, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
store.lock() returns an InnerStoreLocked wrapper type, which acts like a transaction. While this struct is held, all operations occur on the locked store, ensuring no other changes can occur concurrently. This is particularly useful for methods like SET, where a value may need to be read and then updated—allowing you to avoid locking the store multiple times by reusing the locked state.
However, it’s important to release the InnerStoreLocked as soon as possible, since holding it for longer than necessary blocks access to the store’s state for other operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.