Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
cache-service-cache-module
Advanced tools
verbose
flag.cache-service
and superagent-cache
.mset()
implementation which allows you to set expirations on a per key, per function call, and/or per cache-service-cache-module
instance basis.Require and instantiate
var cModule = require('cache-service-cache-module');
var cacheModuleConfig = {defaultExpiration: 60};
var cacheModule = new cModule(cacheModuleConfig);
Cache!
cacheModule.set('key', 'value');
cache-service-cache-module
's constructor takes an optional config object with any number of the following properties:
An arbitrary identifier you can assign so you know which cache is responsible for logs and errors.
The expiration to include when executing cache set commands. Can be overridden via .set()
's optional expiraiton
param.
How frequently should all background refresh-enabled keys be scanned to determine whether they should be refreshed. For a more thorough explanation on background refresh
, see the Using Background Refresh section.
The maximum ttl a scanned background refresh-enabled key can have without triggering a refresh. This number should always be greater than backgroundRefreshInterval
.
Whether to throw an exception if backgroundRefreshInterval
is greater than backgroundRefreshMinTtl
. Setting this property to false is highly discouraged.
When used with
cache-service
, this property is overridden bycache-service
'sverbose
value.
When false, cache-service-cache-module
will log only errors. When true, cache-service-cache-module
will log all activity (useful for testing and debugging).
As a cache-service
-compatible cache, cache-service-cache-module
matches cache-service
's API.
Retrieve a value by a given key.
Retrieve the values belonging to a series of keys. If a key is not found, it will not be in response
.
See the Using Background Refresh section for more about the
refresh
andcallback
params.
Set a value by a given key.
Set multiple values to multiple keys
This function exposes a heirarchy of expiration values as follows:
expiration
property of a key that also contains a cacheValue
property will override all other expirations. (This means that, if you are caching an object, the string 'cacheValue' is a reserved property name within that object.)cacheValue
and expiration
as properties is not present, the expiration
provided to the .mset()
argument list will be used.defaultExpiration
will be applied.Delete a key or an array of keys and their associated values.
Flush all keys and values.
With a typical cache setup, you're left to find the perfect compromise between having a long expiration so that users don't have to suffer through the worst case load time, and a short expiration so data doesn't get stale. cache-service-cache-module
eliminates the need to worry about users suffering through the longest wait time by automatically refreshing keys for you. Here's how it works:
By default, background refresh is off. It will turn itself on the first time you pass a refresh
param to .set()
.
There are three options you can manipulate. See the API section for more information about them.
backgroundRefreshInterval
backgroundRefreshMinTtl
backgroundRefreshIntervalCheck
Background refresh is exposed via the .set()
command as follows:
cacheModule.set('key', 'value', 300, refresh, cb);
If you want to pass refresh
, you must also pass cb
because if only four params are passed, cache-service-cache-module
will assume the fourth param is cb
.
The refresh
param MUST be a function that accepts key
and a callback function that accepts err
and response
as follows:
var refresh = function(key, cb){
var response = goGetData();
cb(null, response);
}
FAQs
A cache plugin for cache-service.
The npm package cache-service-cache-module receives a total of 1,536 weekly downloads. As such, cache-service-cache-module popularity was classified as popular.
We found that cache-service-cache-module demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.