Skip to main content

Class: WeakMapStorage<V>

Defined in: packages/core/src/storage/WeakMapStorage.ts:8

A specialization of the link MapStorage storage mimicking the native WeakMap using its internal garbage collector used once the size of the storage reaches the configured threshold.

Extends​

Type Parameters​

V​

V = object

Constructors​

Constructor​

new WeakMapStorage<V>(config): WeakMapStorage<V>

Defined in: packages/core/src/storage/WeakMapStorage.ts:26

Initializes the storage.

Parameters​

config​

Weak map storage configuration. The fields have the following meaning:

  • entryTtl The time-to-live of a storage entry in milliseconds.
entryTtl​

number

Returns​

WeakMapStorage<V>

Overrides​

Storage.constructor

Methods​

_discardExpiredEntries()​

_discardExpiredEntries(): void

Defined in: packages/core/src/storage/WeakMapStorage.ts:101

Deletes all expired entries from this storage.

Returns​

void


clear()​

clear(): this

Defined in: packages/core/src/storage/WeakMapStorage.ts:74

Clears the storage of all entries.

Returns​

this

This storage.

Overrides​

Storage.clear


delete()​

delete(key): this

Defined in: packages/core/src/storage/WeakMapStorage.ts:67

Deletes the entry identified by the specified key from this storage.

Parameters​

key​

string

The key identifying the storage entry.

Returns​

this

This storage.

Overrides​

Storage.delete


get()​

get(key): V | undefined

Defined in: packages/core/src/storage/WeakMapStorage.ts:44

Retrieves the value of the entry identified by the specified . The method returns undefined if the entry does not exists.

Entries set to the undefined value can be tested for existence using the link has method.

Parameters​

key​

string

The key identifying the storage entry.

Returns​

V | undefined

The value of the storage entry.

Overrides​

Storage.get


has()​

has(key): boolean

Defined in: packages/core/src/storage/WeakMapStorage.ts:35

Returns true if the entry identified by the specified key exists in this storage.

Parameters​

key​

string

The key identifying the storage entry.

Returns​

boolean

true if the storage entry exists.

Overrides​

Storage.has


init()​

init(): this

Defined in: packages/core/src/storage/Storage.ts:17

This method is used to finalize the initialization of the storage after the dependencies provided through the constructor have been prepared for use.

This method must be invoked only once and it must be the first method invoked on this instance.

Returns​

this

This storage.

Inherited from​

Storage.init


keys()​

keys(): Iterable<string>

Defined in: packages/core/src/storage/WeakMapStorage.ts:83

Returns an iterator for traversing the keys in this storage. The order in which the keys are traversed is undefined.

Returns​

Iterable<string>

An iterator for traversing the keys in this storage. The iterator also implements the iterable protocol, returning itself as its own iterator, allowing it to be used in a for..of loop.

Overrides​

Storage.keys


set()​

set(key, value): this

Defined in: packages/core/src/storage/WeakMapStorage.ts:57

Sets the storage entry identified by the specified key to the provided value. The method creates the entry if it does not exist already.

Parameters​

key​

string

The key identifying the storage entry.

value​

V

The storage entry value.

Returns​

this

This storage.

Overrides​

Storage.set


size()​

size(): number

Defined in: packages/core/src/storage/WeakMapStorage.ts:92

Returns the number of entries in this storage.

Returns​

number

The number of entries in this storage.

Overrides​

Storage.size