def
LeanRedis.Cache.new
{τ : Type}
[Transport.Transport τ]
(config : Config)
:
Std.Async.Async (Cache τ)
Equations
- LeanRedis.Cache.new config = do let client ← liftM (LeanRedis.Client.new config) client.connect let inflight ← liftM (Std.Mutex.new ∅) pure { redis := client, inflight := inflight }
Instances For
Equations
- LeanRedis.Cache.newDefault config = LeanRedis.Cache.new config
Instances For
@[inline, specialize #[]]
def
LeanRedis.Cache.get
{τ : Type}
[Transport.Transport τ]
(cache : Cache τ)
(key : String)
(cb : Unit → Std.Async.Async String)
(ttl : Option UInt64 := none)
:
Gets a value from the cache by key. If no value is found, the callback will be called to populate it. The callback is executed exactly once for each key, even if multiple threads request the same key concurrently. Cache stampedes are prevented
Equations
- One or more equations did not get rendered due to their size.