Class: CacheWithLoad

CacheWithLoad(evictPolicy, capacity, maxLoad, eqComparer)

A CacheWithLoad introduces a second concept to constrain the capacity of it. This second concept of load is useful for when the size of the items to cache is not known, and when the sheer amount of items does not allow to estimate the load. The CacheWithLoad evicts items when either its capacity is exhausted or the maximum load is exceeded.

Constructor

new CacheWithLoad(evictPolicy, capacity, maxLoad, eqComparer)

Parameters:
Name Type Description
evictPolicy EvictionPolicy | Number
capacity Number
maxLoad Number The maximum load, expressed as a positive number.
eqComparer EqualityComparer.<TVal>
Author:
Source:

Members

load :Number

Returns the current load.
Type:
  • Number
Source:

loadFree :Number

Returns the current free load (maximum load - current load).
Type:
  • Number
Source:

maxLoad :void

Set the maximum load.
Type:
  • void
Source:

maxLoad :Number

Returns the maximum load.
Type:
  • Number
Source:

Methods

set(key, val, load, expireAfterMsecsopt)

Parameters:
Name Type Attributes Description
key TKey
val TVal
load Number
expireAfterMsecs Number <optional>
defaults to undefined. Only used if given as a positive integer.
Source: