Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

localstorage-cache

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

localstorage-cache

storage

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
50
increased by85.19%
Maintainers
1
Weekly downloads
 
Created
Source

localstorage-cache

storage

Installation

In a browser:
<script src="localstorage-cache.js"></script>
Using npm:
$ npm i -g localstorage-cache
$ npm i --save localstorage-cache
Usage:
import LocalStorageCache from 'localstorage-cache';

/*
 * Set cache size: 2 * 1024KB(2MB)
 * set cache strategy: LRU / LFU;
 */
const storageCache = new LocalStorageCache(2 * 1024, 'LRU'); //

/**
 * set cache, and unit of expire is second.
 * @param {string/number} key
 * @param {any} value
 * @param {number} [expire]
 * @param {string} [charset]
 */
storageCache.setCache('name', 'lzwaiwai', 'utf8').setCache('age', 18);
storageCache.setCache('work', 'IT', 24 * 60 * 60);

/**
 * get cache by key.
 * @param {string/number} key
 * @returns
 */
const cacheWork = storageCache.getCache('work');
console.log(cacheWork);

/**
 * delete cache by key.
 * @param {string/number} key
 */
storageCache.deleteCache('age');

/**
 * delete all cache.
 */
storageCache.clearCache();
...

FAQs

Package last updated on 28 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc