Skip to main content
Module

x/cache_mapset/mod.ts>LRUMap

Maps and Sets with cache replacement policies, TC39 proposal-policy-map-set implementation
Latest
class LRUMap
extends BaseMap<K, V>
import { LRUMap } from "https://deno.land/x/cache_mapset@1.0.0/mod.ts";

Map with an upper limit, objects like. When the upper limit is reached, replaces the entry with LRU algorithm.

Examples

Example 1

import { LRUMap } from "https://deno.land/x/cache_mapset@$VERSION/lru.ts";

declare const maxNumOfEntries: number;
const map = new LRUMap(maxNumOfEntries);

Constructors

new
LRUMap(maxNumOfEntries: number, entries?: Readonly<Iterable<readonly [K, V]>>)

Methods

get(key: K): V | undefined
set(key: K, value: V): this