Class MemoizeCache

Memoization Cache.

Hierarchy

  • MemoizeCache

Constructors

Accessors

Methods

Constructors

Accessors

  • get keys(): string[]
  • Return all of the cached keys.

    • 
      

    const keys = getMemoizeCache(obj)?.keys() ```

    Returns string[]

    The cache's keys.

  • get size(): number
  • Return the size of the cache.

    const size = getMemoizeCache(obj).?size ?? 0
    

    Returns number

    The size of the cache.

Methods

  • Clear all entries from the cache.

    getMemoizeCache(obj)?.clear()
    

    Returns void

  • Get an item from the cache.

    const myAge = getMemoizeCache(obj)?.get('age')
    

    Parameters

    • name: string

      name of item to retrieve.

    Returns any

    item or undefined.

  • Return true if the item exists in the cache.

    const isInCache = !!getMemoizeCache(obj)?.has('age')
    

    Parameters

    • name: string

      name of cached item to lookup.

    Returns boolean

    true if an item is in cache.

  • Dump the value to the local console output.

    Parameters

    • Optional message: string

      An optional message to display before the value.

    Returns MemoizeCache

    The value instance.

  • Returns if the cache is empty.

    Returns boolean

    True if the cache is empty.

  • Removes an item from the cache by name.

    getMemoizeCache(obj).delete('memoizedElementName')
    

    Parameters

    • name: string

      cached item name to remove

    Returns boolean

    true if an item is successfully removed.

  • Set an item in the cache.

    getMemoizeCache(obj)?.set('age', 123)
    

    Parameters

    • name: string

      name of cached item.

    • value: any

      cached item.

    Returns any

    The cache item.

  • Return a copy of the cache as an object.

    const obj = getMemoizeCache(obj)?.toObj()
    

    Returns Record<string, any>

    The cached values.

Generated using TypeDoc