Rebasely Beta: data may be purged

justintypescript-ultra-strict Public

Text · 17 lines · 461 B · at 355e324

import { type Result } from "@tsus/runtime";export type LoadError = { kind: "load_failed"; reason: string };export type CacheError = { kind: "invalid_ttl" };export type Cache<V> = {  get: (key: string) => Promise<Result<V, LoadError>>;  invalidate: (key: string) => void;};export const createCache = <V>(  loader: (key: string) => Promise<Result<V, LoadError>>,  ttlMs: number,  now: () => number,): Result<Cache<V>, CacheError> => {  // TODO};