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

Add the remove method #258

Merged
merged 2 commits into from
Apr 24, 2023
Merged

Add the remove method #258

merged 2 commits into from
Apr 24, 2023

Conversation

tatsuya6502
Copy link
Member

This PR adds the remove method to future and sync caches. It does the same to the invalidate method except returning a clone of the value that has been discarded.

// moka::future::Cache

/// Discards any cached value for the key and returns a _clone_ of the value.
///
/// If you do not need to get the value that has been discarded, use the
/// [`invalidate`](#method.invalidate) method instead.
///
/// The key may be any borrowed form of the cache's key type, but `Hash` and `Eq`
/// on the borrowed form _must_ match those for the key type.
pub async fn remove<Q>(&self, key: &Q) -> Option<V>
where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized;

// FYI, an existing `invalidate` method.
pub async fn invalidate<Q>(&self, key: &Q)
where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized,

Fixes #255.

@tatsuya6502 tatsuya6502 self-assigned this Apr 23, 2023
@tatsuya6502 tatsuya6502 added the enhancement New feature or request label Apr 23, 2023
@tatsuya6502 tatsuya6502 added this to the v0.11.0 milestone Apr 23, 2023
Copy link
Member Author

@tatsuya6502 tatsuya6502 left a comment

Choose a reason for hiding this comment

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

Merging.

@tatsuya6502 tatsuya6502 added this pull request to the merge queue Apr 24, 2023
Merged via the queue into master with commit 358a71e Apr 24, 2023
@tatsuya6502 tatsuya6502 deleted the the-remove-method branch April 24, 2023 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature request: remove method
1 participant