pub struct IrCache { /* private fields */ }Expand description
What a service keeps of its ir answers (RETURNS-40 review #4, re-review
#1, #2): one build per key at a time — a later asker of a key waits for
the build under way, and when the asker building it goes the next waiter
takes the build over; bounded at the ask — a slot being built counts
toward the entries, and an ask with no room (every slot building) builds
without keeping; a slot whose every asker has gone before it was built
is removed (a blocking build under way then finishes and its answer is
dropped); built answers kept least recently used out, by entries and by
bytes, an answer past the byte bound never kept, a slot being built
never evicted; a refusal never kept. The lock is held for O(log n) work
alone.
Implementations§
Source§impl IrCache
impl IrCache
pub fn with_limits(max_entries: usize, max_bytes: usize) -> Self
Sourcepub async fn get_or_build<F, Fut>(
&self,
key: IrKey,
build: F,
) -> Result<ServiceIr, IrError>
pub async fn get_or_build<F, Fut>( &self, key: IrKey, build: F, ) -> Result<ServiceIr, IrError>
The answer kept for key, or build’s — run once for every asker
of key while it runs. An Err is answered and not kept.