Class representing a memory cache.

Constructors

Properties

_mc: CacheEngine
_subscribedPaths: {} = {}

Type declaration

    _subscribers: {
        [id: string]: CacheEventHandler;
    } = {}

    Type declaration

    set: (<T>(key?, value, time?, timeoutCallback?) => void) = ...

    Get a value from the cache. If no key is provided, it returns an object with all key-value pairs in the cache. If a key is provided, it returns the value for that key, or the default value if the key is not in the cache.

    Type declaration

      • <T>(key?, value, time?, timeoutCallback?): void
      • Type Parameters

        • T = any

        Parameters

        • Optional key: Path

          The key of the item to get.

        • value: T
        • Optional time: number
        • Optional timeoutCallback: TimeoutCallback

        Returns void

    Returns

    The value of the item, or an object with all key-value pairs in the cache.

    See

    Accessors

    Methods

    • Get a value from the cache. If no key is provided, it returns an object with all key-value pairs in the cache. If a key is provided, it returns the value for that key, or the default value if the key is not in the cache.

      Type Parameters

      • T = any

      Parameters

      • Optional key: Path

        The key of the item to get.

      • Optional defaultValue: T

        The default value to return if the key is not in the cache.

      Returns any

      The value of the item, or an object with all key-value pairs in the cache.

    • Merge values into the cache. This method will also notify all subscribers about the merge operation.

      Parameters

      • Optional values: ImportData = {}

        The values to merge into the cache.

      • Optional options: {
            skipDuplicates: boolean;
        } = ...

        The options for the merge operation.

        • skipDuplicates: boolean

          Whether to skip duplicate keys.

      Returns any