Constructor
new LRU(optionsopt)
Example
const lru = new LRU({maxItems: 1000});
lru.set('hello', 'world');
lru.get('hello');
lru.delete('hello');
Parameters:
Name | Type | Attributes | Default | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
{}
|
Properties
|
Members
size
returns the size of the lru map (number of items in the map)
Methods
clear()
removes all values from the lru map
delete(key) → {boolean}
deletes a value from the lru map
Parameters:
Name | Type | Description |
---|---|---|
key |
any |
Returns:
whether any key was deleted
- Type
- boolean
get(key) → {any}
gets a value from the lru map
Parameters:
Name | Type | Description |
---|---|---|
key |
any |
Returns:
- Type
- any
has(key) → {boolean}
returns whether a value exists in the lru map
Parameters:
Name | Type | Description |
---|---|---|
key |
any |
Returns:
- Type
- boolean
(generator) keys()
return an iterator over the keys of the lru map
peek(key) → {any}
gets a value from the lru map without touching the lru sequence
Parameters:
Name | Type | Description |
---|---|---|
key |
any |
Returns:
- Type
- any
set(key, value)
sets a value in the lru map
Parameters:
Name | Type | Description |
---|---|---|
key |
any | |
value |
any |
totalSize() → {number}
Total size (including old + new) of the LRU cache
Returns:
- Type
- number
(generator) values()
return an iterator over the values of the lru map