MCPcopy Create free account
hub / github.com/effect-app/libs / preCheck

Function preCheck

repos/effect/packages/effect/src/RequestResolver.ts:1110–1138  ·  view source on GitHub ↗
(entry)

Source from the content-addressed store, hash-verified

1108 * **Details**
1109 *
1110 * Running the returned effect creates the cache and returns a wrapped resolver.
1111 * The cache stores completed success or failure results by request equality up
1112 * to `capacity`. The `strategy` option controls eviction order and defaults to
1113 * `"lru"`; `"fifo"` keeps insertion order.
1114 *
1115 * **Gotchas**
1116 *
1117 * Entries do not expire by time, and completed failures are cached the same as
1118 * successes. Request equality controls cache hits.
1119 *
1120 * @see {@link asCache} for exposing the resolver as a `Cache` with time-to-live and service lookup controls
1121 * @see {@link persisted} for backing persistable requests with the configured persistence store
1122 *
1123 * @category caching
1124 * @since 4.0.0
1125 */
1126export const withCache: {
1127 <A extends Request.Any>(options: {
1128 readonly capacity: number
1129 readonly strategy?: "lru" | "fifo" | undefined
1130 }): (self: RequestResolver<A>) => Effect.Effect<RequestResolver<A>>
1131 <A extends Request.Any>(self: RequestResolver<A>, options: {
1132 readonly capacity: number
1133 readonly strategy?: "lru" | "fifo" | undefined
1134 }): Effect.Effect<RequestResolver<A>>
1135} = dual(2, <A extends Request.Any>(self: RequestResolver<A>, options: {
1136 readonly capacity: number
1137 readonly strategy?: "lru" | "fifo" | undefined
1138}): Effect.Effect<RequestResolver<A>> =>
1139 Effect.sync(() => {
1140 const strategy = options.strategy ?? "lru"
1141 const cache = MutableHashMap.empty<A, {

Callers

nothing calls this directly

Calls 4

completeUnsafeMethod · 0.80
getMethod · 0.65
setMethod · 0.65
removeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…