Documentation
    Preparing search index...

    Class StorageCache

    Timed cache using a Storage interface.

    Letting cache expire.

    const cache = new StorageCache(localStorage, 'my-cache', 30 * 60_000)

    cache.set(['a', 'path'], 'foo')
    cache.get(['a', 'path'])
    // 'foo'

    await setTimeout(30 * 60_000)
    cache.get(['a', 'path'])
    // undefined

    Manually invalidating cache.

    const cache = new StorageCache(localStorage, 'my-cache', 30 * 60_000)
    cache.set(['foo', 'bar'], 'a')
    cache.set(['foo', 'rab'], 'b')

    // Remove a specific cache item
    cache.unset(['foo', 'bar'])

    // Remove all "foos"
    cache.unset(['foo'])
    Index

    Constructors

    Accessors

    Methods

    Constructors

    Accessors

    Methods

    • Checks if a path has cache. If not, updates it and returns true. Otherwise returns false.

      Parameters

      • path: string[]
      • update: () => unknown
      • Optionalms: number

      Returns Promise<boolean>