Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
cache-manager-js
Advanced tools
A caching library for managing asynchronous function results with TTL and eviction strategies.
A caching library for managing asynchronous function results with TTL and eviction strategies.
You can install the package using npm:
npm install cache-manager-js
import { AsyncCacheManager } from "scache-manager-js";
const cache = new AsyncCacheManager();
const callCount: any[] = [];
async function fetchDataFromAPI(id: string): Promise<any> {
console.log(
`async function called. ID: ${id} Count: ${callCount.length + 1}`
);
const result = Math.random();
callCount.push(result);
return result;
}
const cachedFetchData = cache.wrap(fetchDataFromAPI);
// The first call triggers the actual async operation
const data1 = await cachedFetchData("123");
// Subsequent calls return cached results without re-executing the async operation
const data2 = await cachedFetchData("123");
const data3 = await cachedFetchData("666");
if (data1 === data2) {
console.log("data1 equals data2");
// data1 equals data2
}
Asynchronous programming is increasingly prevalent in modern JavaScript and TypeScript applications. Creating a sophisticated caching manager for asynchronous operations addresses a common performance optimization challenge. This package could be particularly useful in scenarios where repeated asynchronous calls with similar parameters occur.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A caching library for managing asynchronous function results with TTL and eviction strategies.
The npm package cache-manager-js receives a total of 0 weekly downloads. As such, cache-manager-js popularity was classified as not popular.
We found that cache-manager-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.