MCPcopy Index your code
hub / github.com/Effect-TS/effect / cacheRequest

Function cacheRequest

packages/effect/src/internal/query.ts:146–166  ·  view source on GitHub ↗
(
  request: A,
  result: Request.Request.Result<A>
)

Source from the content-addressed store, hash-verified

144
145/** @internal */
146export const cacheRequest = <A extends Request.Request<any, any>>(
147 request: A,
148 result: Request.Request.Result<A>
149): Effect.Effect<void> => {
150 return core.fiberRefGetWith(currentCacheEnabled, (cacheEnabled) => {
151 if (cacheEnabled) {
152 return core.fiberRefGetWith(currentCache, (cache) =>
153 core.flatMap(cache.getEither(request), (orNew) => {
154 switch (orNew._tag) {
155 case "Left": {
156 return core.void
157 }
158 case "Right": {
159 return core.deferredComplete(orNew.right.handle, result)
160 }
161 }
162 }))
163 }
164 return core.void
165 })
166}
167
168/** @internal */
169export const withRequestCaching: {

Callers

nothing calls this directly

Calls 1

getEitherMethod · 0.65

Tested by

no test coverage detected