profectus-docs/assets/api_classes_lib_lru-cache.LRUCache.md.4a3c08f5.js

1 line
9.5 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as e,c as t,o as a,N as r}from"./chunks/framework.0799945b.js";const p=JSON.parse('{"title":"Class: LRUCache<K, V>","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('<h1 id="class-lrucache-k-v" tabindex="-1">Class: LRUCache&lt;K, V&gt; <a class="header-anchor" href="#class-lrucache-k-v" aria-label="Permalink to &quot;Class: LRUCache&lt;K, V\\&gt;&quot;"></a></h1><p><a href="./../../modules/lib/lru-cache">lib/lru-cache</a>.LRUCache</p><p>A LRU cache intended for caching pure functions.</p><h2 id="type-parameters" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters" aria-label="Permalink to &quot;Type parameters&quot;"></a></h2><table><thead><tr><th style="text-align:left;">Name</th></tr></thead><tbody><tr><td style="text-align:left;"><code>K</code></td></tr><tr><td style="text-align:left;"><code>V</code></td></tr></tbody></table><h2 id="constructors" tabindex="-1">Constructors <a class="header-anchor" href="#constructors" aria-label="Permalink to &quot;Constructors&quot;"></a></h2><h3 id="constructor" tabindex="-1">constructor <a class="header-anchor" href="#constructor" aria-label="Permalink to &quot;constructor&quot;"></a></h3><p>• <strong>new LRUCache</strong>&lt;<code>K</code>, <code>V</code>&gt;(<code>maxSize</code>)</p><h4 id="type-parameters-1" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters-1" aria-label="Permalink to &quot;Type parameters&quot;"></a></h4><table><thead><tr><th style="text-align:left;">Name</th></tr></thead><tbody><tr><td style="text-align:left;"><code>K</code></td></tr><tr><td style="text-align:left;"><code>V</code></td></tr></tbody></table><h4 id="parameters" tabindex="-1">Parameters <a class="header-anchor" href="#parameters" aria-label="Permalink to &quot;Parameters&quot;"></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th><th style="text-align:left;">Description</th></tr></thead><tbody><tr><td style="text-align:left;"><code>maxSize</code></td><td style="text-align:left;"><code>number</code></td><td style="text-align:left;">The maximum size for this cache. We recommend setting this to be one less than a power of 2, as most hashtables - including V8&#39;s Object hashtable (<a href="https://crsrc.org/c/v8/src/objects/ordered-hash-table.cc" target="_blank" rel="noreferrer">https://crsrc.org/c/v8/src/objects/ordered-hash-table.cc</a>) - uses powers of two for hashtable sizes. It can&#39;t exactly be a power of two, as a .set() call could temporarily set the size of the map to be maxSize + 1.</td></tr></tbody></table><h4 id="defined-in" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/70cda5f/src/lib/lru-cache.ts#L23" target="_blank" rel="noreferrer">profectus/src/lib/lru-cache.ts:23</a></p><h2 id="properties" tabindex="-1">Properties <a class="header-anchor" href="#properties" aria-label="Permalink to &quot;Properties&quot;"></a></h2><h3 id="first" tabindex="-1">first <a class="header-anchor" href="#first" aria-label="Permalink to &quot;first&quot;"></a></h3><p>• <code>Private</code> <strong>first</strong>: <code>undefined</code> | <code>ListNode</code>&lt;<code>K</code>, <code>V</code>&gt; = <code>undefined</code></p><h4 id="defined-in-1" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-1" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/70cda5f/src/lib/lru-cache.ts#L11" target="_blank" rel="noreferrer">profectus/src/lib/lru-cache.ts:11</a></p><hr><h3 id="last" tabindex="-1">last <a class="header-anchor" href="#last" aria-label="Permalink to &quot;last&quot;"></a></h3><p>• <code>Private</code> <strong>last</strong>: <code>undefined</code> | <code>ListNode</code>&lt;<code>K</code>, <code>V</code>&gt; = <code>undefined</code></p><h4 id="defined-in-2" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-2" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/70cda5f/src/lib/lru-cache.ts#L12" target="_blank" rel="noreferrer">profectus/src/lib/lru-cache.ts:12</a></p><hr><h3 id="map" tabindex="-1">map <a class="header-anchor" href="#map" aria-label="Permalink to &quot;map&quot;"></a></h3><p>• <code>Private</code> <strong>map</strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map" target="_blank" rel="noreferrer"><code>Map</code></a>&lt;<code>K</code>, <code>ListNode</code>&lt;<code>K</code>, <code>V</code>&gt;&gt;</p><h4 id="defined-in-3" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-3" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/70cda5f/src/lib/lru-cache.ts#L5" target="_blank" rel="noreferrer">profectus/src/lib/lru-cache.ts:5</a></p><hr><h3 id="maxsize" tabindex="-1">maxSize <a class="header-anchor" href="#maxsize" aria-label="Permalink to &quot;maxSize&quot;"></a></h3><p>• <strong>maxSize</strong>: <code>number</code></p><h4 id="defined-in-4" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-4" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/70cda5f/src/lib/lru-cache.ts#L13" target="_blank" rel="noreferrer">profectus/src/lib/lru-cache.ts:13</a></p><h2 id="accessors" tabindex="-1">Accessors <a class="header-anchor" href="#accessors" aria-label="Permalink to &quot;Accessors&quot;"></a></h2><h3 id="size" tabindex="-1">size <a class="header-anchor" href="#size" aria-label="Permalink to &quot;size&quot;"></a></h3><p>• <code>get</code> <strong>size</strong>(): <code>number</code></p><h4 id="returns" tabindex="-1">Returns <a class="header-anchor" href="#returns" aria-label="Permalink to &quot;Returns&quot;"></a></h4><p><code>number</code></p><h4 id="defined-in-5" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-5" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/70cda5f/src/lib/lru-cache.ts#L27" target="_blank" rel="noreferrer">profectus/src/lib/lru-cache.ts:27</a></p><h2 id="methods" tabindex="-1">Methods <a class="header-anchor" href="#methods" aria-label="Permalink to &quot;Methods&quot;"></a></h2><h3 id="get" tabindex="-1">get <a class="header-anchor" href="#get" aria-label="Permalink to &quot;get&quot;"></a></h3><p>▸ <strong>get</strong>(<code>key</code>): <code>undefined</code> | <code>V</code></p><p>Gets the specified key from the cache, or undefined if it is not in the cache.</p><h4 id="parameters-1" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-1" aria-label="Permalink to &quot;Parameters&quot;"></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th><th style="text-align:left;">Description</th></tr></thead><tbody><tr><td style="text-align:left;"><code>key</code></td><td style="text-align:left;"><code>K</code></td><td style="text-align:left;">The key to get.</td></tr></tbody></table><h4 id="returns-1" tabindex="-1">Returns <a class="header-anchor" href="#returns-1" aria-label="Permalink to &quot;Returns&quot;"></a></h4><p><code>undefined</code> | <code>V</code></p><p>The cached value, or undefined if key is not in the cache.</p><h4 id="defined-in-6" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-6" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/70cda5f/src/lib/lru-cache.ts#L37" target="_blank" rel="noreferrer">profectus/src/lib/lru-cache.ts:37</a></p><hr><h3 id="set" tabindex="-1">set <a class="header-anchor" href="#set" aria-label="Permalink to &quot;set&quot;"></a></h3><p>▸ <strong>set</strong>(<code>key</code>, <code>value</code>): <code>void</code></p><p>Sets an entry in the cache.</p><p><strong><code>Throws</code></strong></p><p>Error, if the map already contains the key.</p><h4 id="parameters-2" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-2" aria-label="Permalink to &quot;Parameters&quot;"></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th><th style="text-align:left;">Description</th></tr></thead><tbody><tr><td style="text-align:left;"><code>key</code></td><td style="text-align:left;"><code>K</code></td><td style="text-align:left;">The key of the entry.</td></tr><tr><td style="text-align:left;"><code>value</code></td><td style="text-align:left;"><code>V</code></td><td style="text-align:left;">The value of the entry.</td></tr></tbody></table><h4 id="returns-2" tabindex="-1">Returns <a class="header-anchor" href="#returns-2" aria-label="Permalink to &quot;Returns&quot;"></a></h4><p><code>void</code></p><h4 id="defined-in-7" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-7" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/70cda5f/src/lib/lru-cache.ts#L88" target="_blank" rel="noreferrer">profectus/src/lib/lru-cache.ts:88</a></p>',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};