GitHub

API reference for rc_map.

RcMap[K, A, E]: scoped resources shared by key.

get(key) runs lookup(key) the first time a key is asked for, shares the resource (or the lookup in progress) with every other caller for that key, and holds a reference until the caller's Scope closes. When the last reference to a key goes, its resource is released at once, or kept for idle_time_to_live (touch restarts that wait). invalidate drops a key so the next get looks it up afresh.

capacity bounds the number of keys, idle ones included; nothing is evicted, so a new key fails with ExceededCapacityError while the map is full. Closing the scope that made the map releases every entry.

Classes