Skip to main content
Module

x/lru/mod.ts>default

Simple and powerful LRU cache for Deno
Latest
class default
import { default } from "https://deno.land/x/lru@1.0.2/mod.ts";

LRU main class

Constructors

new
default(max: number)

Constructor method for a new LRU

Properties

readonly
keys: Array<string>

Get all keys from cache

readonly
object: { [key: string]: T; }

Get entries as object

readonly
size: number

Amount of entries in the cache

readonly
values: Array<T>

Get all values from cache

Methods

private
_first()

Get the oldest entry in the cache

clear(): void

Removes all entries in the cache

filter(callbackfn: (
value: [string, T],
index: number,
array: [string, T][],
) => T
, thisArg?: unknown
): [string, T][]

Creates a new array with all elements that pass the test implemented by the provided function

forEach(callbackfn: (
value: T,
key: string,
map: Map<string, T>,
) => void
, thisArg?: unknown
): void

Executes a provided function once for each array element

get(key: string): T | undefined

Attemps to retrieve a value from the cache

has(key: string): boolean

Returns a boolean indicating whether an element with the specified key exists or not

map(callbackfn: (
value: [string, T],
index: number,
array: [string, T][],
) => T
, thisArg?: unknown
): T[]

Method creates a new array populated with the results of calling a provided function on every element in the calling array

reduce(callbackfn: (
previousValue: [string, T],
currentValue: [string, T],
currentIndex: number,
array: [string, T][],
) => [string, T]
, initialValue?: [string, T]
): [string, T]

Executes a reducer function (that you provide) on each element of the array, resulting in single output value

reduce<U>(callbackfn: (
previousValue: U,
currentValue: [string, T],
currentIndex: number,
array: [string, T][],
) => U
, initialValue: U
): U
remove(key: string): void

Removes the entry

set(key: string, value: T): void

Adds or updates an entry in the cache

Use it for..of method