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

Update Store and TTL implementation #52

Merged
merged 4 commits into from
Sep 26, 2024

Conversation

ndelvalle
Copy link
Owner

No description provided.

/// Only set the key if it does not already exist.
Nx,
/// Only set the key if it already exists.
Xx,
Copy link
Owner Author

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,
Copy link
Owner Author

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.

@ndelvalle ndelvalle marked this pull request as ready for review September 23, 2024 17:00
Copy link
Collaborator

@gillchristian gillchristian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gillchristian gillchristian merged commit c86bdbe into master Sep 26, 2024
0 of 2 checks passed
@gillchristian gillchristian deleted the refactor-store-and-use-ttl-methods branch September 26, 2024 08:16
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

Successfully merging this pull request may close these issues.

2 participants