MCPcopy Create free account
hub / github.com/Effect-TS/effect / makeManagedResourceCache

Function makeManagedResourceCache

packages/effect/test/ScopedCache.test.ts:2309–2329  ·  view source on GitHub ↗
(capacity: number)

Source from the content-addressed store, hash-verified

2307}
2308
2309const makeManagedResourceCache = (capacity: number) =>
2310 Effect.gen(function*() {
2311 const cleanupTracker: CleanupTracker = {
2312 cleanedUp: [],
2313 acquired: []
2314 }
2315
2316 const cache = yield* ScopedCache.make({
2317 capacity,
2318 lookup: (key: string) =>
2319 Effect.gen(function*() {
2320 yield* Effect.acquireRelease(
2321 Effect.sync(() => cleanupTracker.acquired.push(key)),
2322 () => Effect.sync(() => cleanupTracker.cleanedUp.push(key))
2323 )
2324 return `resource-${key}`
2325 })
2326 })
2327
2328 return { cache, cleanupTracker }
2329 })

Callers 1

Calls 3

pushMethod · 0.80
makeMethod · 0.65
syncMethod · 0.45

Tested by

no test coverage detected