Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HashGenCacheSet<T>

A hashed generational cache set discards the least recently used value with the worst hit rate per hash bucket. HashGenCacheSet is a concurrent and lock-free LRFU cache, with O(1) access time.

Maintaining four "generations" of cached values per hash bucket, the cache discards from the younger generations based on least recent usage, and promotes younger generations to older generations based on most frequent usage. Cache misses count as negative usage of the older generations, biasing the cache against least recently used values with poor hit rates.

The cache soft references the older generations, and weak references the younger generations; the garbage collector can reclaim the entire cache, but will preferentially wipe the younger cache generations before the older cache generations.

Type parameters

  • T

Hierarchy

  • HashGenCacheSet

Index

Constructors

constructor

Properties

_buckets

_buckets: Array<HashGenCacheSetBucket<T> | undefined>

_gen1Hits

_gen1Hits: number

_gen2Hits

_gen2Hits: number

_gen3Hits

_gen3Hits: number

_gen4Hits

_gen4Hits: number

_misses

_misses: number

Methods

clear

  • clear(): void

hitRatio

  • hitRatio(): number

put

  • put(value: T): T

remove

  • remove(value: T): boolean