@lindeneg/ls-cache
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.