Class: TipCache

cache.TipCache(maxSizeopt)

LRU Cache implementation with TTL support

Constructor

new TipCache(maxSizeopt)

Creates a TipCache instance
Parameters:
Name Type Attributes Default Description
maxSize number <optional>
5 Maximum number of entries to store
Source:

Classes

TipCache

Members

_cachePool

Map to store cache entries
Source:

_maxSize

Maximum size of the cache
Source:

Methods

delete(key) → {boolean}

Deletes a value from the cache
Parameters:
Name Type Description
key string The key to delete
Source:
Returns:
True if the key was found and deleted
Type
boolean

delete(key) → {boolean}

Deletes a value from the cache
Parameters:
Name Type Description
key string The key to delete
Source:
Returns:
True if the key was found and deleted
Type
boolean

get(key) → {T|null}

Gets a value from the cache
Parameters:
Name Type Description
key string The key to retrieve
Source:
Returns:
The cached value or null if not found/expired
Type
T | null

get(key) → {T|null}

Gets a value from the cache
Parameters:
Name Type Description
key string The key to retrieve
Source:
Returns:
The cached value or null if not found/expired
Type
T | null

has(key) → {boolean}

Checks if a key exists in the cache and is not expired
Parameters:
Name Type Description
key string The key to check
Source:
Returns:
True if the key exists and is not expired
Type
boolean

has(key) → {boolean}

Checks if a key exists in the cache and is not expired
Parameters:
Name Type Description
key string The key to check
Source:
Returns:
True if the key exists and is not expired
Type
boolean

set(key, value, ttlopt)

Sets a value in the cache
Parameters:
Name Type Attributes Default Description
key string The key to store the value under
value T The value to store
ttl number <optional>
0 Time to live in milliseconds (0 for no expiry)
Source:

set(key, value, ttlopt) → {void}

Sets a value in the cache
Parameters:
Name Type Attributes Default Description
key string The key to store the value under
value T The value to store
ttl number <optional>
0 Time to live in milliseconds (0 for no expiry)
Source:
Returns:
Type
void

size() → {number}

Gets the current size of the cache
Source:
Returns:
Number of entries in the cache
Type
number

size() → {number}

Gets the current size of the cache
Source:
Returns:
Number of entries in the cache
Type
number