MCPcopy Index your code
hub / github.com/Effect-TS/effect / get

Method get

packages/effect/src/internal/scopedCache.ts:260–306  ·  view source on GitHub ↗
(key: Key)

Source from the content-addressed store, hash-verified

258 }
259
260 get(key: Key): Effect.Effect<Value, Error, Scope.Scope> {
261 return pipe(
262 this.lookupValueOf(key),
263 effect.memoize,
264 core.flatMap((lookupValue) =>
265 core.suspend(() => {
266 let k: cache_.MapKey<Key> | undefined = undefined
267 let value = Option.getOrUndefined(MutableHashMap.get(this.cacheState.map, key))
268 if (value === undefined) {
269 k = cache_.makeMapKey(key)
270 if (MutableHashMap.has(this.cacheState.map, key)) {
271 value = Option.getOrUndefined(MutableHashMap.get(this.cacheState.map, key))
272 } else {
273 MutableHashMap.set(this.cacheState.map, key, pending(k, lookupValue))
274 }
275 }
276 if (value === undefined) {
277 this.trackMiss()
278 return core.zipRight(
279 this.ensureMapSizeNotExceeded(k!),
280 lookupValue
281 )
282 }
283
284 return core.map(
285 this.resolveMapValue(value),
286 core.flatMap(Option.match({
287 onNone: () => {
288 const val = value as Complete<Key, Value, Error>
289 const current = Option.getOrUndefined(MutableHashMap.get(this.cacheState.map, key))
290 if (Equal.equals(current, value)) {
291 MutableHashMap.remove(this.cacheState.map, key)
292 }
293 return pipe(
294 this.ensureMapSizeNotExceeded(val.key),
295 core.zipRight(releaseOwner(val)),
296 core.zipRight(this.get(key))
297 )
298 },
299 onSome: core.succeed
300 }))
301 )
302 })
303 ),
304 core.flatten
305 )
306 }
307
308 invalidate(key: Key): Effect.Effect<void> {
309 return core.suspend(() => {

Callers 1

refreshMethod · 0.95

Calls 11

lookupValueOfMethod · 0.95
trackMissMethod · 0.95
resolveMapValueMethod · 0.95
releaseOwnerFunction · 0.85
pipeFunction · 0.70
pendingFunction · 0.70
getMethod · 0.65
setMethod · 0.65
mapMethod · 0.65
removeMethod · 0.65

Tested by

no test coverage detected