MemoryCache class


A basic caching manager that caches to the system memory using a Map.

Signature:

export declare class MemoryCache implements ICache 

Implements: ICache

References: ICache


Constructor

new MemoryCache ()

Constructs a new instance of the MemoryCache class.

Parameters:

ParameterTypeDescription

Methods

.clear ()

Clears the cache.

Signature:

clear(): void;

Return type: void


.find ()

Finds a value in the cache using a predicate and a filter.

Signature:

find<T>(predicate: (t: T) => boolean): T | undefined;

Parameters:

ParameterTypeDescription
predicate(t: T) = > booleanThe predicate to use to find the value.

Return type: T | Undefined


.get ()

Gets a value from the cache.

Signature:

get<T>(key: string): T;

Parameters:

ParameterTypeDescription
keyStringThe key of the value to get.

Return type: T


.has ()

Signature:

has(key: string): boolean;

Parameters:

ParameterTypeDescription
keyString

Return type: Boolean


.keys ()

Fetches all keys in the cache.

Signature:

keys(): string[];

Return type: String


.remove ()

Removes a value from the cache.

Signature:

remove(key: string): void;

Parameters:

ParameterTypeDescription
keyStringThe key of the value to remove.

Return type: void


.set ()

Sets a value in the cache.

Signature:

set<T>(key: string, value: T): void;

Parameters:

ParameterTypeDescription
keyStringThe key of the value to set.
valueTThe value to set.

Return type: void


.values ()

Fetches all values stored in the cache.

Signature:

values(): any[];

Return type: any


Table of Contents