1.0.3 • Published 3 years ago

local-cache-storage v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

local-cache-storage

Maintainability Test Coverage

Installing

npm

npm install local-cache-storage

yarn

yarn add local-cache-storage

How to use?

ES6 Modules

import * as localCache from 'local-cache-storage';

localCache.set('key', 'value', 3000);

CommonJS

const localCache = require('local-cache-storage');

localCache.get('key', true);

Example

import * as localCache from 'local-cache-storage';

const DAY = 1000 * 60 * 60 * 24;

localCache.set('foo', 'bar'); // If you want to save permanently.
localCache.set('counts', [1, 2, 3], 5 * DAY); // Key will be remained for five days.

localCache.get('counts'); // '[1, 2, 3]'

// If you want to get parsed value.
localCache.get('counts', true); // [1, 2, 3]

// After 6 days
localCache.get('counts'); // null
localCache.get('counts', true); // null