simple-localstorage-cache
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

simple-localstorage-cache

A simple local-storage cache with time based expiration policies

features

  • simplicity: get, set, and keys with an intuitive, pit-of-success, implementation
  • interoperability: fulfills the standard SimpleAsyncCache interface
  • garbage collection: automatically removes expired keys from local-storage to free up space

install

npm install simple-localstorage-cache

use

create a cache

const cache = createCache({ namespace: 'super-awesome-feature' });

set to the cache

await cache.set('answer', 42);

ℹ️ note: if you'd like an item to never expire, set the expiration time to null or Infinity

get from the cache

await cache.get('answer'); // 42

Package Sidebar

Install

npm i simple-localstorage-cache

Weekly Downloads

2

Version

1.0.1

License

none

Unpacked Size

29.6 kB

Total Files

12

Last publish

Collaborators

  • uladkasach