Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SegmentedLRUEvictionPolicy<Key, Value, ArgumentsBundle>

Segmented LRU eviction policy.

Type parameters

  • Key

    Type of the key.

  • Value

    Type of the value.

  • ArgumentsBundle

    Type of the arguments bundle.

Hierarchy

  • SegmentedLRUEvictionPolicy

Implements

Constructors

constructor

  • new SegmentedLRUEvictionPolicy<Key, Value, ArgumentsBundle>(cacheMaxCapacity: number, protectedOverProbationRatio?: number): SegmentedLRUEvictionPolicy<Key, Value, ArgumentsBundle>
  • Type parameters

    • Key

    • Value

    • ArgumentsBundle

    Parameters

    • cacheMaxCapacity: number

      Cache maximum capacity.

    • protectedOverProbationRatio: number = 0.7

      Size of protected segment expressed in % from cacheMaxCapacity.
      Defaults to 70%.

    Returns SegmentedLRUEvictionPolicy<Key, Value, ArgumentsBundle>

Accessors

leastRecent

  • get leastRecent(): Nullable<EvictableCacheEntry<Key, Value>>
  • Get least recently used key.

    Returns Nullable<EvictableCacheEntry<Key, Value>>

mostRecent

  • get mostRecent(): Nullable<EvictableCacheEntry<Key, Value>>
  • Get most recently used key.

    Returns Nullable<EvictableCacheEntry<Key, Value>>

size

  • get size(): number
  • Get the number of the elements stored in internal structures of this policy.

    Returns number

Methods

onClear

  • onClear(): void

onDelete

  • onDelete(entry: EvictableCacheEntry<Key, Value>): void
  • Hook executed before entry for key has been deleted.
    Policy is supposed to detach metadata from entry and cleanup it's internal data structures when this hook is called.

    Parameters

    • entry: EvictableCacheEntry<Key, Value>

      Entry that's being deleted.

    Returns void

onHit

  • Hook executed after entry for key was retrieved.
    Policy might decide that entry is no longer valid and return EntryValidity.NOT_VALID. In case it does so, policy is responsible to evict entry from cache before this method returns.

    Parameters

    • entry: EvictableCacheEntry<Key, Value>

      Entry hit on which was made.

    Returns EntryValidity

    Whether entry is still valid.

onMiss

  • onMiss(): void

onSet

  • onSet(entry: EvictableCacheEntry<Key, Value>): void
  • Hook executed after entry for key has been set.

    Parameters

    • entry: EvictableCacheEntry<Key, Value>

      Entry that was inserted.

    Returns void

onUpdate

  • onUpdate(): void

setDeleter

  • setDeleter(deleter: Deleter<Key, Value>): void