1.0.1 • Published 1 year ago
simple-localstorage-cache v1.0.1
simple-localstorage-cache
A simple local-storage cache with time based expiration policies
features
- simplicity:
get
,set
, andkeys
with an intuitive, pit-of-success, implementation - interoperability: fulfills the standard SimpleAsyncCache interface
- can be used with
- 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