🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

map-cache

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
m

map-cache

Basic cache object for storing key-value pairs.

0.2.2
latest
100

Supply Chain Security

100

Vulnerability

100

Quality

76

Maintenance

100

License

Version published
Weekly downloads
12M
-7.44%
Maintainers
1
Weekly downloads
 
Created
Issues
0

What is map-cache?

The map-cache npm package is a simple cache to store key-value pairs. It is particularly useful for storing the results of expensive function calls or any other calculations that you don't want to repeat unnecessarily. It's a lightweight and fast caching solution.

What are map-cache's main functionalities?

Set and Get Values

This feature allows you to store a value with a specific key and then retrieve that value using the key.

{"const MapCache = require('map-cache');
const cache = new MapCache();
cache.set('foo', 'bar');
const value = cache.get('foo');
console.log(value); // Output: 'bar'"}

Check Existence of Key

This feature allows you to check if a key exists in the cache.

{"const MapCache = require('map-cache');
const cache = new MapCache();
cache.set('foo', 'bar');
const hasKey = cache.has('foo');
console.log(hasKey); // Output: true"}

Delete a Key

This feature allows you to delete a key-value pair from the cache.

{"const MapCache = require('map-cache');
const cache = new MapCache();
cache.set('foo', 'bar');
cache.delete('foo');
const value = cache.get('foo');
console.log(value); // Output: undefined"}

Clear the Cache

This feature allows you to clear all key-value pairs stored in the cache.

{"const MapCache = require('map-cache');
const cache = new MapCache();
cache.set('foo', 'bar');
cache.clear();
const value = cache.get('foo');
console.log(value); // Output: undefined"}

Other packages similar to map-cache

FAQs

Package last updated on 10 May 2016

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