Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CacheReplacementPolicy<Key, Value, ArgumentsBundle>

Represents an abstraction over CacheEntry processing.
Policy might intercept cache operations and execute different actions using metadata attached to CacheEntry. These actions might result in CacheEntry evictions, depending on policy replacement algorithm.

Type parameters

  • Key

    Type of the key.

  • Value

    Type of the value.

  • ArgumentsBundle

    Type of the arguments bundle received by different operations.
    This template argument is used to uniformize API of different policy implementations.
    When using multiple policies together, they will share a common arguments bundle object.

Hierarchy

  • CacheReplacementPolicy

Implemented by

Methods

onClear

  • onClear(): void
  • Hook executed before cache has been cleared.

    Returns void

onDelete

  • 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: CacheEntry<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: CacheEntry<Key, Value>

      Entry hit on which was made.

    Returns EntryValidity

    Whether entry is still valid.

onMiss

  • onMiss(key: Key): void
  • Hook executed after key wasn't found in the cache on Cache.get operation.

    Parameters

    • key: Key

      Name of the key.

    Returns void

onSet

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

    Parameters

    • entry: CacheEntry<Key, Value>

      Entry that was inserted.

    • Optional argsBundle: ArgumentsBundle

      Arguments bundle for cache set operation.

    Returns void

onUpdate

  • onUpdate(entry: CacheEntry<Key, Value>, argsBundle?: ArgumentsBundle): void
  • Hook executed after value for entry associated with key has been updated.

    Parameters

    • entry: CacheEntry<Key, Value>

      Entry that was update.

    • Optional argsBundle: ArgumentsBundle

      Arguments bundle for cache set operation.

    Returns void

setDeleter

  • setDeleter(deleter: Deleter<Key, Value>): void
  • Set deleter which removes entries from cache.

    Parameters

    Returns void