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

Function keys

packages/effect/src/Cache.ts:1316–1326  ·  view source on GitHub ↗
(self: Cache<Key, A, E, R>)

Source from the content-addressed store, hash-verified

1314 * @since 4.0.0
1315 */
1316export const keys = <Key, A, E, R>(self: Cache<Key, A, E, R>): Effect.Effect<Iterable<Key>> =>
1317 core.withFiber((fiber) => {
1318 const now = fiber.getRef(effect.ClockRef).currentTimeMillisUnsafe()
1319 return effect.succeed(Iterable.filterMap(self.map, ([key, entry]) => {
1320 if (entry.expiresAt === undefined || entry.expiresAt > now) {
1321 return Result.succeed(key)
1322 }
1323 MutableHashMap.remove(self.map, key)
1324 return Result.failVoid
1325 }))
1326 })
1327
1328/**
1329 * Retrieves all successfully cached values from the cache, excluding failed

Callers

nothing calls this directly

Calls 4

getRefMethod · 0.80
succeedMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected