npm.io
2.0.7 • Published 4 years ago

@lindeneg/ls-cache

Licence
MIT
Version
2.0.7
Deps
2
Size
15 kB
Vulns
0
Weekly
0

@lindeneg/ls-cache

typescript bundle-size license


Utility class for interacting with localStorage

Installation

yarn add @lindeneg/ls-cache

Usage
import LSCache from '@lindeneg/ls-cache';

// default usage
const cache = new LSCache();

// async usage
const cache = new LSCache({
  delayInit: true,
});

await cache.initialize();
Config
type Config = {
  /* prefix localStorage keys to avoid collisions
     default: '__cl_ls_cache__' */
  prefix?: string;

  /* delay localStorage initialization
     default: false */
  delayInit?: boolean;

  /* trimming interval in seconds 
     default: 600 */
  trim?: number;

  /* time-to-live in seconds 
     default: 3600 */
  ttl?: number;
};
Methods

The documentation here can be used.

Keywords