Skip to content

Commit

Permalink
Merge pull request #199 from moka-rs/remove-api-get-or-insert
Browse files Browse the repository at this point in the history
Remove deprecated APIs `get_or_insert_with` and `get_or_try_insert_with`
  • Loading branch information
tatsuya6502 authored Nov 7, 2022
2 parents c617ecf + f87711c commit 1f86c70
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 36 deletions.
24 changes: 4 additions & 20 deletions src/future/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,22 +832,6 @@ where
RefKeyEntrySelector::new(key, hash, self)
}

/// Deprecated, replaced with [`get_with`](#method.get_with)
#[deprecated(since = "0.8.0", note = "Replaced with `get_with`")]
pub async fn get_or_insert_with(&self, key: K, init: impl Future<Output = V>) -> V {
self.get_with(key, init).await
}

/// Deprecated, replaced with [`try_get_with`](#method.try_get_with)
#[deprecated(since = "0.8.0", note = "Replaced with `try_get_with`")]
pub async fn get_or_try_insert_with<F, E>(&self, key: K, init: F) -> Result<V, Arc<E>>
where
F: Future<Output = Result<V, E>>,
E: Send + Sync + 'static,
{
self.try_get_with(key, init).await
}

/// Returns a _clone_ of the value corresponding to the key. If the value does
/// not exist, resolve the `init` future and inserts the output.
///
Expand Down Expand Up @@ -1451,8 +1435,8 @@ where
let maybe_entry =
self.base
.get_with_hash_but_ignore_if(&key, hash, replace_if.as_mut(), need_key);
if let Some(v) = maybe_entry {
v
if let Some(entry) = maybe_entry {
entry
} else {
self.insert_with_hash_and_fun(key, hash, init, replace_if, need_key)
.await
Expand All @@ -1474,8 +1458,8 @@ where
let maybe_entry =
self.base
.get_with_hash_but_ignore_if(key, hash, replace_if.as_mut(), need_key);
if let Some(v) = maybe_entry {
v
if let Some(entry) = maybe_entry {
entry
} else {
let key = Arc::new(key.to_owned());
self.insert_with_hash_and_fun(key, hash, init, replace_if, need_key)
Expand Down
16 changes: 0 additions & 16 deletions src/sync/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,22 +984,6 @@ where
RefKeyEntrySelector::new(key, hash, self)
}

/// Deprecated, replaced with [`get_with`](#method.get_with)
#[deprecated(since = "0.8.0", note = "Replaced with `get_with`")]
pub fn get_or_insert_with(&self, key: K, init: impl FnOnce() -> V) -> V {
self.get_with(key, init)
}

/// Deprecated, replaced with [`try_get_with`](#method.try_get_with)
#[deprecated(since = "0.8.0", note = "Replaced with `try_get_with`")]
pub fn get_or_try_insert_with<F, E>(&self, key: K, init: F) -> Result<V, Arc<E>>
where
F: FnOnce() -> Result<V, E>,
E: Send + Sync + 'static,
{
self.try_get_with(key, init)
}

/// Returns a _clone_ of the value corresponding to the key. If the value does
/// not exist, evaluates the `init` closure and inserts the output.
///
Expand Down

0 comments on commit 1f86c70

Please sign in to comment.