1.0.1 • Published 10 months ago

simple-localstorage-cache v1.0.1

Weekly downloads
-
License
-
Repository
github
Last release
10 months ago

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