A custom cache collection which has a max cache size.

Example

new CacheCollection();

Type Parameters

  • K

  • V

Hierarchy

  • Collection<K, V>
    • CacheCollection

Constructors

Properties

Methods

Constructors

  • Type Parameters

    • K

    • V

    Parameters

    • Optional maxSize: number

      The max size of the cache.

    • Optional entries: null | Iterable<[K, V]>

      The initial entries of the cache.

    Returns CacheCollection<K, V>

Properties

maxSize?: number

Methods

  • Set an entry in the cache.

    Returns

    The cache collection.

    Example

    cache.set(key, value);
    

    Parameters

    • key: K

      The key of the entry.

    • value: V

      The value of the entry.

    Returns CacheCollection<K, V>

  • Set the max size of the cache.

    Returns

    The cache collection.

    Example

    cache.setMaxSize(100);
    

    Parameters

    • Optional maxSize: number

      The max size of the cache.

    Returns CacheCollection<K, V>