MCPcopy Create free account
hub / github.com/Effect-TS/effect / Cache

Interface Cache

packages/effect/src/Cache.ts:58–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56 * @category models
57 */
58export interface Cache<in out Key, in out Value, out Error = never>
59 extends ConsumerCache<Key, Value, Error>, Cache.Variance<Key, Value, Error>
60{
61 /**
62 * Retrieves the value associated with the specified key if it exists.
63 * Otherwise computes the value with the lookup function, puts it in the
64 * cache, and returns it.
65 */
66 get(key: Key): Effect.Effect<Value, Error>
67
68 /**
69 * Retrieves the value associated with the specified key if it exists as a left.
70 * Otherwise computes the value with the lookup function, puts it in the
71 * cache, and returns it as a right.
72 */
73 getEither(key: Key): Effect.Effect<Either<Value, Value>, Error>
74
75 /**
76 * Computes the value associated with the specified key, with the lookup
77 * function, and puts it in the cache. The difference between this and
78 * `get` method is that `refresh` triggers (re)computation of the value
79 * without invalidating it in the cache, so any request to the associated
80 * key can still be served while the value is being re-computed/retrieved
81 * by the lookup function. Additionally, `refresh` always triggers the
82 * lookup function, disregarding the last `Error`.
83 */
84 refresh(key: Key): Effect.Effect<void, Error>
85
86 /**
87 * Associates the specified value with the specified key in the cache.
88 */
89 set(key: Key, value: Value): Effect.Effect<void>
90}
91
92/**
93 * A ConsumerCache models a portion of a cache which is safe to share without allowing to create new values or access existing ones.

Callers 24

sendFunction · 0.65
onMessageFunction · 0.65
onMessageFunction · 0.65
makeFunction · 0.65
makeExecuteFunction · 0.65
requestFunction · 0.65
groupedFunction · 0.65
fromRequestFunction · 0.65
cacheRequestFunction · 0.65
Resource.test.tsFile · 0.65

Implementers 1

CacheImplpackages/effect/src/internal/cache.ts

Calls

no outgoing calls

Tested by

no test coverage detected