Class: Cache

Cache(size)

new Cache(size)

A cache with a fixed capacity, newer entries replace entries that have been stored first.
Parameters:
Name Type Description
size
Source:

Members

_bufferIndex :Integer

Index in the ring buffer to be written next.
Type:
  • Integer
Source:

_ringBuffer :Array

Ring buffer storing hash keys, allows determining which keys need to be evicted.
Type:
  • Array
Source:

data :Object

Cache data, maps values to the keys. Read-only access, for writing use add() method.
Type:
  • Object
Source:

Methods

add(key)

Adds a key and the corresponding value to the cache.
Parameters:
Name Type Description
key
Source:

clear()

Clears cache contents.
Source: