Class: CacheMapBased

CacheMapBased(evictPolicyopt, capacityopt, eqCompareropt)

new CacheMapBased(evictPolicyopt, capacityopt, eqCompareropt)

Creates a new, empty CacheMapBased., using the specified @see {EvictionPolicy} and an initial capacity.
Parameters:
Name Type Attributes Description
evictPolicy EvictionPolicy | number <optional>
Optional. Specify the eviction policy that is applied, if the cache has no more space left.
capacity number <optional>
Optional. Specify the initial capacity of this cache. The capacity can be increased and decreased later.
eqComparer EqualityComparer.<TVal> <optional>
Optional. Defaults To EqualityComparer..default.
Author:
Source:

Members

(static) _counter

Used to assign a running number to new cache items.
Source:

_capacity :number

Type:
  • number
Source:

_evictPolicy :EvictionPolicy|number

Type:
Source:

_map :Map.<TKey, CacheItem.<TVal>>

Type:
Source:

capacity

Source:

capacity

Source:

evictionPolicy

Source:

evictionPolicy

Source:

isFull

Source:

observableEvict :Observable.<CollectionEvent.<Array.<TVal>>>

Type:
Source:

Methods

__unwrapValue(value) → {TVal}

Parameters:
Name Type Description
value CacheItem.<TVal>
Source:
Returns:
The wrapped value
Type
TVal

(generator) _evictNext() → {IterableIterator.<CacheItem.<T>>}

Returns items in the order they will be evicted, according to the policy.
Source:
Returns:
Type
IterableIterator.<CacheItem.<T>>

_validateCapacity(capacity)

Parameters:
Name Type Description
capacity number The capacity to check. Must be a positive integer.
Source:
Throws:
If the given capacity is not an integer or less than zero.
Type
Error

_validateEvictionPolicy(policy)

Parameters:
Name Type Description
policy EvictionPolicy | number An @see {EvictionPolicy}
Source:
Throws:
If the given policy is not one of @see {EvictionPolicy}.
Type
Error

(generator) entries()

Source:

evict() → {T}

Source:
Returns:
the evicted item.
Type
T

evictMany(count) → {Array.<T>}

Parameters:
Name Type Description
count Number
Source:
Returns:
The evicted items in an array.
Type
Array.<T>

get()

Source:

peekEvict(amount)

Allows to peek at the next n items that will be evicted next, without removing them. Returns the items as key/value pair.
Parameters:
Name Type Description
amount Number
Source:
Returns:

set(expireAfterMsecsopt)

Parameters:
Name Type Attributes Description
expireAfterMsecs Number <optional>
Optional. if given a positive integer, then it will be used as the amount of milliseconds this entry will expire and remove itself from the cache.
Source:
Throws:
If this cache is full and no automatic eviction policy was set.
Type
Error

(generator) values()

Source: