New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@consenlabs-fe/memory-cache

Package Overview
Dependencies
Maintainers
5
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@consenlabs-fe/memory-cache

key-value pair cache tool.

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
24
decreased by-14.29%
Maintainers
5
Weekly downloads
 
Created
Source

Memory Cache

key-value pair cache tool.

Features

  • Multiple environment support
  • Stored in memory only
  • Extremely small size (<1kb)
  • No side effects

Compatibility

  • Browser: FF 45+, Safari 9+, Chrome 42+
  • Browser (low version): Add class polyfill from Babel or core-js
  • NodeJS: Full support
  • React Native: Full support

Guide

Install
  • Run npm i @consenlabs-fe/memory-cache.
  • ESM: import MemoryCache from '@consenlabs-fe/memory-cache'
  • CJS (NodeJS): const MemoryCache require('@consenlabs-fe/memory-cache')
Examples

1. Get and Set

const cache = new MemoryCache('my-caches')

cache.setItem('name', 'witt')
cache.getItem('name') // -> 'witt'

2. Remove and Clean

const cache = new MemoryCache('my-caches')

cache.setItem('name', 'witt')
cache.setItem('location', 'china')

cache.removeItem('name')
cache.getItem('name') // -> null
cache.getItem('location') // -> 'china'

cache.cleanAll()
cache.getItem('location') // -> null

3. Expiration

const cache = new MemoryCache('my-caches', { maxAge: 100 })

cache.setItem('name', 'witt')
cache.getItem('name') // -> 'witt'

setTimeout(() => {
  cache.getItem('name') // -> null
}, 200)

License

MIT

FAQs

Package last updated on 15 Jul 2021

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