| 144 | |
| 145 | /** @internal */ |
| 146 | export 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 */ |
| 169 | export const withRequestCaching: { |