Reference Source
public class | source

CacheManager

Cache manager class.

Example:

API:
		get(arg_key:string, arg_default):Promise
		mget(arg_keys:array, arg_default:any|array):Promise
		has(arg_key:string):Promise
		set(arg_key:string, arg_value, arg_ttl=undefined):Promise
		set_ttl(arg_key:string, arg_ttl):Promise
		get_ttl(arg_key:string):Promise
		get_keys():Promise
		remove(arg_key:string|array):Promise
		flush():nothing - delete all entries.
		close():nothing - clear interval timeout for checks.

		add_adapter(arg_cache_adapter):nothing - add a cache adapters.

Constructor Summary

Public Constructor
public

constructor(arg_cache_adapters: array): nothing

Create Cache instance to manage cached datas.

Member Summary

Public Members
public

Class type flag.

Private Members
private

Cache adapters array.

Method Summary

Public Methods
public

add_adapter(arg_cache_adapter: *): nothing

Add a cache adapter.

public

Close cache engine.

public

Flush all cached values (clear interval timeout for checks).

public

get(arg_key: string, arg_default: any): Promise

Get a cached value.

public

Get cached keys.

public

get_ttl(arg_key: string): Promise

Get cached value ttl.

public

has(arg_key: string): Promise

Test if given key has a cached value.

public

mget(arg_keys: array, arg_default: any): Promise

Get a cached value.

public

remove(arg_keys: string | array): Promise

Remove a cached value.

public

set(arg_key: string, arg_value: any, arg_ttl: integer): Promise

Set a cached value with given key.

public

set_ttl(arg_key: string, arg_ttl: integer): Promise

Set cached value ttl.

Public Constructors

public constructor(arg_cache_adapters: array): nothing source

Create Cache instance to manage cached datas.

Params:

NameTypeAttributeDescription
arg_cache_adapters array

cache adapters.

Return:

nothing

Public Members

public is_cache_manager: boolean source

Class type flag.

Private Members

private _cache_adapters: array source

Cache adapters array.

Public Methods

public add_adapter(arg_cache_adapter: *): nothing source

Add a cache adapter.

@param{DataCacheAdapter} arg_cache_adapter - cache adapter.

Params:

NameTypeAttributeDescription
arg_cache_adapter *

Return:

nothing

public close(): Promise source

Close cache engine.

Return:

Promise

Promise of undefined.

public flush(): Promise source

Flush all cached values (clear interval timeout for checks).

Return:

Promise

Promise of undefined.

public get(arg_key: string, arg_default: any): Promise source

Get a cached value.

Params:

NameTypeAttributeDescription
arg_key string

key string to retrieve the value.

arg_default any

returned default value if the key is not found (optional) (default:undefined).

Return:

Promise

Promise of cached value or undefined.

public get_keys(): Promise source

Get cached keys.

Return:

Promise

Promise of keys array.

public get_ttl(arg_key: string): Promise source

Get cached value ttl.

Params:

NameTypeAttributeDescription
arg_key string

key string to retrieve the value.

Return:

Promise

Promise of integer|undefined.

public has(arg_key: string): Promise source

Test if given key has a cached value.

Params:

NameTypeAttributeDescription
arg_key string

key string to retrieve the value.

Return:

Promise

Promise of cached value or undefined.

public mget(arg_keys: array, arg_default: any): Promise source

Get a cached value.

Params:

NameTypeAttributeDescription
arg_keys array

key strings to retrieve the values.

arg_default any

returned default value if the key is not found (optional) (default:undefined).

Return:

Promise

Promise of cached value or undefined array.

public remove(arg_keys: string | array): Promise source

Remove a cached value.

Params:

NameTypeAttributeDescription
arg_keys string | array

value key string or array.

Return:

Promise

Promise of undefined.

public set(arg_key: string, arg_value: any, arg_ttl: integer): Promise source

Set a cached value with given key.

Params:

NameTypeAttributeDescription
arg_key string

key string to retrieve the value.

arg_value any

value to cache.

arg_ttl integer

time to leave for cached value.

Return:

Promise

Promise of nothing.

public set_ttl(arg_key: string, arg_ttl: integer): Promise source

Set cached value ttl.

Params:

NameTypeAttributeDescription
arg_key string

key string to retrieve the value.

arg_ttl integer

time to leave for cached value.

Return:

Promise

Promise of nothing.