You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building a cache whose entries have their own standalone TTL. However moka supports global TTL and IDLE only. So I'm here to propose a new method Cache::get_with_if(&self, key: &K, fallback: Fut, cond: Fn(&V) -> bool) -> V
The function works like Cache::get_with(&self, key: &K, init: Fut) -> V, but when the key does not exist or cond(&V) is true, the init clojure will be called to initialize the value.
The text was updated successfully, but these errors were encountered:
ClSlaid
changed the title
[feature request] add Cache::get_with_if(&self, key: &K, fallback: Fut, cond: Fn(&V) -> bool) -> V support
[feature request] add Cache::get_with_if(&self, key: &K, fallback: Fut, cond: Fn(&V) -> bool) -> V method
May 15, 2022
Thank you for proposing get_with_if method. I think it will be easy to implement. Let me work on it.
I'm building a cache whose entries have their own standalone TTL. However moka supports global TTL and IDLE only.
You are right. Per-entry expiration is on our roadmap but currently scheduled very late. (The item 10: "(post v1.0) feat: The variable (per-entry) expiration, using a hierarchical timer wheel") I will probably give it more priority. But anyway, I will implement get_with_if for now.
I'm building a cache whose entries have their own standalone TTL. However
moka
supports global TTL and IDLE only. So I'm here to propose a new methodCache::get_with_if(&self, key: &K, fallback: Fut, cond: Fn(&V) -> bool) -> V
The function works like
Cache::get_with(&self, key: &K, init: Fut) -> V
, but when the key does not exist orcond(&V)
is true, theinit
clojure will be called to initialize the value.The text was updated successfully, but these errors were encountered: