Hyperlinkv0.8.0-beta.28

ScopedCache

ScopedCache.ScopedCacheinterfaceeffect/ScopedCache.ts:54
ScopedCache<Key, A, E, R>

A scoped cache whose values are acquired by a lookup effect and stored in per-entry scopes.

When to use

Use to cache values that acquire scoped resources and must release those resources when entries expire, are evicted, or are invalidated.

Details

Concurrent requests for the same key share the same in-flight lookup. Entries can expire based on the lookup exit, are evicted when capacity is exceeded, and release their entry scopes when invalidated, evicted, expired, or when the cache's owning scope closes.

export interface ScopedCache<in out Key, in out A, in out E = never, out R = never> extends Pipeable {
  readonly [TypeId]: typeof TypeId
  state: State<Key, A, E>
  readonly capacity: number
  readonly lookup: (key: Key) => Effect.Effect<A, E, R | Scope.Scope>
  readonly timeToLive: (exit: Exit.Exit<A, E>, key: Key) => Duration.Duration
}
Referenced by 15 symbols