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

Method trackAccess

packages/effect/src/internal/cache.ts:611–639  ·  view source on GitHub ↗
(key: MapKey<Key>)

Source from the content-addressed store, hash-verified

609 }
610
611 trackAccess(key: MapKey<Key>): void {
612 MutableQueue.offer(this.cacheState.accesses, key)
613 if (MutableRef.compareAndSet(this.cacheState.updating, false, true)) {
614 let loop = true
615 while (loop) {
616 const key = MutableQueue.poll(this.cacheState.accesses, MutableQueue.EmptyMutableQueue)
617 if (key === MutableQueue.EmptyMutableQueue) {
618 loop = false
619 } else {
620 this.cacheState.keys.add(key)
621 }
622 }
623 let size = MutableHashMap.size(this.cacheState.map)
624 loop = size > this.capacity
625 while (loop) {
626 const key = this.cacheState.keys.remove()
627 if (key !== undefined) {
628 if (MutableHashMap.has(this.cacheState.map, key.current)) {
629 MutableHashMap.remove(this.cacheState.map, key.current)
630 size = size - 1
631 loop = size > this.capacity
632 }
633 } else {
634 loop = false
635 }
636 }
637 MutableRef.set(this.cacheState.updating, false)
638 }
639 }
640
641 hasExpired(clock: Clock.Clock, timeToLiveMillis: number): boolean {
642 return clock.unsafeCurrentTimeMillis() > timeToLiveMillis

Callers 4

getOptionMethod · 0.95
getOptionCompleteMethod · 0.95
getEitherMethod · 0.95
resolveMapValueMethod · 0.95

Calls 6

offerMethod · 0.65
pollMethod · 0.65
addMethod · 0.65
sizeMethod · 0.65
removeMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected