Class: LRUCache

LRUCache

new LRUCache()

Utils/classes/LRUCache.ts, line 11

Methods

emit(eventName, args)

Utils/classes/LRUCache.ts, line 146

Emits an event with the provided arguments.

Name Type Description
eventName string

The name of the event.

args any repeatable

Arguments to pass to the event handlers.

get(key)

Utils/classes/LRUCache.ts, line 103

Gets the value associated with the key if it exists in the cache and updates it as the most recently used.

Name Type Description
key

The key of the value to get.

Returns:
The value associated with the key, or undefined if the key does not exist.

off(eventName, callback)

Utils/classes/LRUCache.ts, line 164

Removes an event handler. If no callback is provided, removes all handlers for the event.

Name Type Description
eventName string optional

The name of the event.

callback function optional

The callback function to remove.

on(eventName, callback)

Utils/classes/LRUCache.ts, line 137

Registers an event handler that will be invoked every time the event is emitted.

Name Type Description
eventName string

The name of the event.

callback function

The callback function to handle the event.

once(eventName, callback)

Utils/classes/LRUCache.ts, line 155

Registers a one-time event handler that will be invoked only the next time the event is emitted.

Name Type Description
eventName string

The name of the event.

callback function

The callback function to handle the event.

put(key, value)

Utils/classes/LRUCache.ts, line 117

Adds or updates the value in the cache and sets it as the most recently used. Removes the least recently used element if the cache exceeds the established limit.

Name Type Description
key

The key of the value to store.

value

The value to store.