Module Async_extended.Resource.Memo

Parameters

Signature

val memo : (Key.t ‑> ('a'et) ‑> Key.t ‑> ('a'et

memo f is similar to Core.Memo.general (fun k -> shared (f k)). The important difference is that the memo entry is only kept while the resource is acquired. In particular, once all handles of a particular key get released the memo entry gets forgotten and f gets applied again on next acquisition. If acquire fails or function raises for a particular key, the result is not cached.