Skip to Content
APIConfigurationInterface: ICache<T>

Interface: ICache<T>

Generic cache interface (Port) Defines the contract for cache implementations in the SDK. Following hexagonal architecture, this is a port that can be implemented by different adapters (memory, localStorage, etc.)

Example

T

Type Parameters

T

T

The type of values stored in the cache

Methods

clear()

void

Removes all entries from the cache

Returns

void


delete()

string

Removes a specific key from the cache

Parameters

key

string

The cache key to remove

Returns

boolean

true if the key was found and removed


get()

boolean

Retrieves a value from the cache

Parameters

key

string

The cache key

Returns

undefined | T

The cached value or undefined if not found/expired


getStats()

string

Returns current cache statistics

Returns

CacheStats

CacheStats object with size and configuration info


has()

undefined

Checks if a key exists in the cache

Parameters

key

string

The cache key

Returns

boolean

true if the key exists and is not expired


keys()

T

Returns all keys currently in the cache

Returns

string[]

Array of cache keys


set()

CacheStats

Stores a value in the cache

Parameters

key

string

The cache key

value

T

The value to store

Returns

void

Last updated on