Class: CacheBase

CacheBase(options)

CacheBase

Constructor

new CacheBase(options)

Parameters:
Name Type Default Description
options object {}
Properties
Name Type Default Description
prefix string CacheBase cache prefix
parent CacheBase parent cache
expire number 60000 cahce expire
Source:

Methods

buildKey(key) → {string}

build full key
Parameters:
Name Type Description
key string cache key
Source:
Returns:
full cache key
Type
string

(abstract) clear(key) → {Promise}

clear cache data by key
Parameters:
Name Type Description
key string cache key
Source:
Returns:
Type
Promise

(async) get(key, loadFunc) → {Promise}

get data
Parameters:
Name Type Attributes Description
key string cache key
loadFunc function load data func
...expires number <repeatable>
caches's expire
Source:
Returns:
data
Type
Promise

(async) getAndSave(key, loadFunc) → {Promise}

get data and refresh cache
Parameters:
Name Type Attributes Description
key string cache key
loadFunc function load data function
...expires number <repeatable>
caches's expire
Source:
Returns:
data
Type
Promise

(abstract) loadFromCache(fullKey) → {Promise}

load data from cache
Parameters:
Name Type Description
fullKey string cache full key
Source:
Returns:
cache data
Type
Promise

(abstract) saveToCache(fullKey, data, expire) → {Promise}

save data to cache
Parameters:
Name Type Description
fullKey string cache full key
data object data to save
expire number
Source:
Returns:
Type
Promise