Gathering detailed insights and metrics for concurrent-memoize
Gathering detailed insights and metrics for concurrent-memoize
Gathering detailed insights and metrics for concurrent-memoize
Gathering detailed insights and metrics for concurrent-memoize
npm install concurrent-memoize
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
ISC License
21 Commits
3 Watchers
1 Branches
2 Contributors
Updated on Jan 27, 2016
Latest Version
0.0.6
Package Id
concurrent-memoize@0.0.6
Size
5.92 kB
NPM Version
2.14.12
Node Version
4.2.6
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Memoize Concurrent Requests in your Application so that only one request is executed and all subsequent, concurrent, waiting requests that are identical to the first request get notified with the result of the first call. Also all future accesses of the value return cache.
npm install concurrent-memoize
Often times organized, reusable code may make many duplicate calls. These calls may be database queries, HTTP requests, other third party requests. This module de-duplicates asynchronous, simultaneous requests, in this way
This module was originally created to keep a per request cache of all database queries made during a single HTTP GET request within a REST API. The cache only exists per request, eliminating the problem of stale data since most requests are very short lived. Executing in a GET request ensured that (for the most part) no data in the cache could become stale, since GET requests, by convention, should not make major database modifications anyway (by convention, major database modifications should be done in POST/PUT/etc requests).
1"use strict"; 2 3let cache = {}; 4 5const memoize = require('concurrent-memoize'); 6 7const request = memoize(require('request'), 'request', { 8 getCache: function() { 9 return cache; 10 }, 11 cacheKey: function(opts) { 12 return JSON.stringify(util.parse(opts).pathname); 13 }, 14 parseOptions: function(opts, queryOpts) { 15 return queryOpts; 16 }, 17 allowCache: function() { 18 return true; 19 } 20}); 21 22// ... 23 24request('http://localhost/') 25 .then(function(err, result) { 26 console.log("I'm fresh!") 27 }); 28request('http://localhost/') 29 .then(function(err, result) { 30 console.log("I'm cached!"); 31 });
The module is in its early stages still, so I'm resetting the major version to 0.x.x in order to work out bugs without increasing the major version with every breaking change.
memoize(originalFunc, funcName, config)
This function will return another function that wraps originalFunc. Calling this function will transparently check cache, wait for a result, or execute the query to get the result.
memoize.async(originalFunc, funcName, config)
This function is to be used for functions that expect a callback. The function returned will be "promisified" in that it will work instead with a promise if no callback is passed.
memoize.property(object, funcName, config)
This function is a shortcut to apply the memoize
to the property name funcName
on the object object
. The this
is preserved on the overriden function.
memoize.timer
Keeps track of statistics across the lifetime of the process
.
memoize.defaultConfig
Contains the base config for a managing cache (see lib/defaultConfig
for documentation).
ISC
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
Found 0/21 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More