profectus-docs/assets/api_lib_lru-cache_classes_LRUCache.md.6ykyoxXD.lean.js

1 line
7.4 KiB
JavaScript
Raw Permalink 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 a,c as r,a0 as t,o}from"./chunks/framework.P9qPzDnn.js";const p=JSON.parse('{"title":"Class: LRUCache<K, V>","description":"","frontmatter":{"editLink":false},"headers":[],"relativePath":"api/lib/lru-cache/classes/LRUCache.md","filePath":"api/lib/lru-cache/classes/LRUCache.md","lastUpdated":null}'),c={name:"api/lib/lru-cache/classes/LRUCache.md"};function s(i,e,n,h,l,d){return o(),r("div",null,e[0]||(e[0]=[t('<p><a href="./../../../">Profectus</a> / <a href="./../">lib/lru-cache</a> / LRUCache</p><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 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><p>• <strong>K</strong></p><p>• <strong>V</strong></p><h2 id="constructors" tabindex="-1">Constructors <a class="header-anchor" href="#constructors" aria-label="Permalink to &quot;Constructors&quot;"></a></h2><h3 id="new-lrucache" tabindex="-1">new LRUCache() <a class="header-anchor" href="#new-lrucache" aria-label="Permalink to &quot;new LRUCache()&quot;"></a></h3><blockquote><p><strong>new LRUCache</strong>&lt;<code>K</code>, <code>V</code>&gt;(<code>maxSize</code>): <a href="./LRUCache"><code>LRUCache</code></a>&lt;<code>K</code>, <code>V</code>&gt;</p></blockquote><h4 id="parameters" tabindex="-1">Parameters <a class="header-anchor" href="#parameters" aria-label="Permalink to &quot;Parameters&quot;"></a></h4><h5 id="maxsize" tabindex="-1">maxSize <a class="header-anchor" href="#maxsize" aria-label="Permalink to &quot;maxSize&quot;"></a></h5><p><code>number</code></p><p>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>)</p><ul><li>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.</li></ul><h4 id="returns" tabindex="-1">Returns <a class="header-anchor" href="#returns" aria-label="Permalink to &quot;Returns&quot;"></a></h4><p><a href="./LRUCache"><code>LRUCache</code></a>&lt;<code>K</code>, <code>V</code>&gt;</p><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://code.incremental.social/profectus/Profectus/src/branch/main/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="maxsize-1" tabindex="-1">maxSize <a class="header-anchor" href="#maxsize-1" aria-label="Permalink to &quot;maxSize&quot;"></a></h3><blockquote><p><strong>maxSize</strong>: <code>number</code></p></blockquote><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://code.incremental.social/profectus/Profectus/src/branch/main/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><h4 id="get-signature" tabindex="-1">Get Signature <a class="header-anchor" href="#get-signature" aria-label="Permalink to &quot;Get Signature&quot;"></a></h4><blockquote><p><strong>get</strong> <strong>size</strong>(): <code>number</code></p></blockquote><h5 id="returns-1" tabindex="-1">Returns <a class="header-anchor" href="#returns-1" aria-label="Permalink to &quot;Returns&quot;"></a></h5><p><code>number</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://code.incremental.social/profectus/Profectus/src/branch/main/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><blockquote><p><strong>get</strong>(<code>key</code>): <code>undefined</code> | <code>V</code></p></blockquote><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><h5 id="key" tabindex="-1">key <a class="header-anchor" href="#key" aria-label="Permalink to &quot;key&quot;"></a></h5><p><code>K</code></p><p>The key to get.</p><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>undefined</code> | <code>V</code></p><p>The cached value, or undefined if key is not in the cache.</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://code.incremental.social/profectus/Profectus/src/branch/main/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><blockquote><p><strong>set</strong>(<code>key</code>, <code>value</code>): <code>void</code></p></blockquote><p>Sets an entry in the cache.</p><h4 id="parameters-2" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-2" aria-label="Permalink to &quot;Parameters&quot;"></a></h4><h5 id="key-1" tabindex="-1">key <a class="header-anchor" href="#key-1" aria-label="Permalink to &quot;key&quot;"></a></h5><p><code>K</code></p><p>The key of the entry.</p><h5 id="value" tabindex="-1">value <a class="header-anchor" href="#value" aria-label="Permalink to &quot;value&quot;"></a></h5><p><code>V</code></p><p>The value of the entry.</p><h4 id="returns-3" tabindex="-1">Returns <a class="header-anchor" href="#returns-3" aria-label="Permalink to &quot;Returns&quot;"></a></h4><p><code>void</code></p><h4 id="throws" tabindex="-1">Throws <a class="header-anchor" href="#throws" aria-label="Permalink to &quot;Throws&quot;"></a></h4><p>Error, if the map already contains the key.</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://code.incremental.social/profectus/Profectus/src/branch/main/src/lib/lru-cache.ts#L88" target="_blank" rel="noreferrer">profectus/src/lib/lru-cache.ts:88</a></p>',61)]))}const f=a(c,[["render",s]]);export{p as __pageData,f as default};