(options: {
readonly visibility: Signal
readonly connectivity: Signal
/** The problems sink. A throw from it is swallowed. */
readonly report: (problem: Problem.Any) => void
/** In milliseconds, from `cacheIdleMs`. */
readonly idleMs: number
/**
* The server's per-request mode: an entry settles at most once and is never
* stale after, every settle is stored, a query's own `invalidate` is ignored
* and reported, and no idle timer, interval or host edge runs.
*/
readonly settleOnce?: boolean | undefined
/** `false`: no fetch ever starts, as on a server render with a budget of 0. */
readonly fetches?: boolean | undefined
})
| 4536 | * @internal |
| 4537 | */ |
| 4538 | export const makeCache = (options: { |
| 4539 | readonly visibility: Signal |
| 4540 | readonly connectivity: Signal |
| 4541 | /** The problems sink. A throw from it is swallowed. */ |
| 4542 | readonly report: (problem: Problem.Any) => void |
| 4543 | /** In milliseconds, from `cacheIdleMs`. */ |
| 4544 | readonly idleMs: number |
| 4545 | /** |
| 4546 | * The server's per-request mode: an entry settles at most once and is never |
| 4547 | * stale after, every settle is stored, a query's own `invalidate` is ignored |
| 4548 | * and reported, and no idle timer, interval or host edge runs. |
| 4549 | */ |
| 4550 | readonly settleOnce?: boolean | undefined |
| 4551 | /** `false`: no fetch ever starts, as on a server render with a budget of 0. */ |
| 4552 | readonly fetches?: boolean | undefined |
| 4553 | }): Effect.Effect<CacheInternals, never, Scope.Scope> => |
| 4554 | Effect.map( |
| 4555 | // Uninterruptible from the build to the finalizer's registration, so no build goes without disposal. |
| 4556 | Effect.acquireRelease( |
| 4557 | Effect.contextWith((context: Context.Context<never>) => Effect.sync(() => buildCache(context, options))), |
| 4558 | (built) => built.dispose |
| 4559 | ), |
| 4560 | (built) => built.cache |
| 4561 | ) |
| 4562 | |
| 4563 | const cacheIdleMs = (input: Duration.Input | undefined): number => { |
| 4564 | const duration = Duration.fromInputUnsafe(input ?? "5 minutes") |
no test coverage detected