@lindeneg/ls-cache
TypeScript icon, indicating that this package has built-in type declarations

2.0.7 • Public • Published

@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.

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @lindeneg/ls-cache

    Weekly Downloads

    3

    Version

    2.0.7

    License

    MIT

    Unpacked Size

    15.5 kB

    Total Files

    9

    Last publish

    Collaborators

    • christianlindeneg