Skip to main content
Module

x/steam_trader/deps.ts>LFU

https://deno.land/x/steam_trader
Latest
class LFU
extends BaseCache<V>
import { LFU } from "https://deno.land/x/steam_trader@v0.4.0/deps.ts";

Least Frequently Used Cache

Constructors

new
LFU(options: Options)

Type Parameters

optional
V = any

Properties

private
_keys: [key in Key]: Node<V>
private
_size: number
private
frequency: { [key: number]: DoublyLinkedList; }
private
minFrequency: number
readonly
keys

List of keys in the cache

readonly
size

Current number of entries in the cache

readonly
values

List of values in the cache

Methods

Reset the cache

forEach(callback: (item: { key: Key; value: V; }, index: number) => void)

Array like forEach, iterating over all entries in the cache

get(key: Key)

Gets the value for a given key

has(key: Key)

Checks if a given key is in the cache

peek(key: Key)

Get the value to a key without manipulating the cache

remove(key: Key)

Removes the cache entry with given key

set(
key: Key,
value: V,
ttl?: number,
)

Inserts a new entry into the cache