A type-hinted storage interface with items that can expire.

interface IPerishableStorage<T> {
    length: number;
    totalSize: number;
    clear(): void;
    estimateSize(key, value): number;
    getItem(key): T;
    key(index): string;
    removeItem(key): void;
    setItem(key, value): void;
    size(key?): number;
}

Type Parameters

Hierarchy (view full)

Implemented by

Properties

length: number

The number of items in storage.

totalSize: number

The total possible size of storage in bytes.

Methods

  • Calculate how many bytes of storage are in use. If no key is given, calculate for all keys.

    Parameters

    • Optional key: string

    Returns number