Cache

lib/xp/cache~ Cache

(private) new Cache(native)

Creates a new cache with options.

Parameters:
Name Type Description
native *

Native cache object.

Methods

clear()

Clears the cache.

get(key, callback) → {*}

Returns value for cache entry if exists, otherwise it's calculated and put into the cache.

Parameters:
Name Type Description
key string

Cache key to use.

callback function

Callback to a function that can calculate the cache value.

Returns:

Cache value for key.

Type
*

getSize() → {number}

Returns number of elements in cache.

Returns:

Returns the number of elements that are currently in the cache.

Type
number