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

Function getImpl

packages/effect/src/Cache.ts:616–633  ·  view source on GitHub ↗
(
  self: Cache<Key, A, E, R>,
  key: Key,
  fiber: Fiber.Fiber<any, any>,
  isRead = true
)

Source from the content-addressed store, hash-verified

614)
615
616const getImpl = <Key, A, E, R>(
617 self: Cache<Key, A, E, R>,
618 key: Key,
619 fiber: Fiber.Fiber<any, any>,
620 isRead = true
621): Entry<A, E> | undefined => {
622 const oentry = MutableHashMap.get(self.map, key)
623 if (Option.isNone(oentry)) {
624 return undefined
625 } else if (hasExpired(oentry.value, fiber)) {
626 MutableHashMap.remove(self.map, key)
627 return undefined
628 } else if (isRead) {
629 MutableHashMap.remove(self.map, key)
630 MutableHashMap.set(self.map, key, oentry.value)
631 }
632 return oentry.value
633}
634
635/**
636 * Retrieves the value associated with the specified key from the cache, only if

Callers 1

Cache.tsFile · 0.70

Calls 4

hasExpiredFunction · 0.70
getMethod · 0.65
setMethod · 0.65
removeMethod · 0.45

Tested by

no test coverage detected