CacheModule
Functions for creating and reading a single-flight Cache`3.
Summary
| Name | Signature | Synopsis |
|---|---|---|
| Operations | ||
| make | Cache.make lookup | Creates a cache that computes missing values with lookup. |
| get | Cache.get key cache | Returns the value for a key, running the lookup if no success is cached and none is running. |
| invalidate | Cache.invalidate key cache | Forgets a key's cached value, so the next get runs the lookup again. |
| invalidateAll | Cache.invalidateAll cache | Forgets every cached value. |
| count | Cache.count cache | Returns the number of keys that are cached or being looked up. |
Operations
kind:member
Creates a cache that computes missing values with
lookup.Parameters
| Name | Type | Description |
|---|---|---|
| lookup | 'key -> Flow<'env, 'error, 'value> | Computes the value for a key. |
Returns
Flow<'env, 'none, Cache<'key, 'error, 'value>>
Verification Examples
flow {
let! users = Cache.make loadUser
let! first = users |> Cache.get 42
let! again = users |> Cache.get 42 // no second load
return first = again
}kind:member
kind:member
kind:member

