(key: MapKey<Key>)
| 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 |
no test coverage detected