import{_ as e,c as t,o as a,N as r}from"./chunks/framework.0799945b.js";const p=JSON.parse('{"title":"Class: LRUCache","description":"","frontmatter":{"editLink":false},"headers":[],"relativePath":"api/classes/lib/lru-cache.LRUCache.md","lastUpdated":null}'),o={name:"api/classes/lib/lru-cache.LRUCache.md"},c=r('

Class: LRUCache<K, V>

lib/lru-cache.LRUCache

A LRU cache intended for caching pure functions.

Type parameters

Name
K
V

Constructors

constructor

new LRUCache<K, V>(maxSize)

Type parameters

Name
K
V

Parameters

NameTypeDescription
maxSizenumberThe maximum size for this cache. We recommend setting this to be one less than a power of 2, as most hashtables - including V8's Object hashtable (https://crsrc.org/c/v8/src/objects/ordered-hash-table.cc) - uses powers of two for hashtable sizes. It can't exactly be a power of two, as a .set() call could temporarily set the size of the map to be maxSize + 1.

Defined in

profectus/src/lib/lru-cache.ts:23

Properties

first

Private first: undefined | ListNode<K, V> = undefined

Defined in

profectus/src/lib/lru-cache.ts:11


last

Private last: undefined | ListNode<K, V> = undefined

Defined in

profectus/src/lib/lru-cache.ts:12


map

Private map: Map<K, ListNode<K, V>>

Defined in

profectus/src/lib/lru-cache.ts:5


maxSize

maxSize: number

Defined in

profectus/src/lib/lru-cache.ts:13

Accessors

size

get size(): number

Returns

number

Defined in

profectus/src/lib/lru-cache.ts:27

Methods

get

get(key): undefined | V

Gets the specified key from the cache, or undefined if it is not in the cache.

Parameters

NameTypeDescription
keyKThe key to get.

Returns

undefined | V

The cached value, or undefined if key is not in the cache.

Defined in

profectus/src/lib/lru-cache.ts:37


set

set(key, value): void

Sets an entry in the cache.

Throws

Error, if the map already contains the key.

Parameters

NameTypeDescription
keyKThe key of the entry.
valueVThe value of the entry.

Returns

void

Defined in

profectus/src/lib/lru-cache.ts:88

',64),d=[c];function s(l,i,n,h,f,u){return a(),t("div",null,d)}const m=e(o,[["render",s]]);export{p as __pageData,m as default};