Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/cache_mapset/mod.ts>LFUMap

Maps and Sets with cache replacement policies, TC39 proposal-policy-map-set implementation
Latest
class LFUMap
implements MapLike<K, V>
import { LFUMap } 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 LFU algorithm.

Examples

Example 1

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

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

Constructors

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

Properties

readonly
size: number

Methods

clear(): void
delete(key: K): boolean
get(key: K): V | undefined
has(key: K): boolean
set(key: K, value: V): this