Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
cachegoose
Advanced tools
#cachegoose
####Mongoose caching that actually works.
##About
A Mongoose caching module that works exactly how you would expect it to, with the latest version of Mongoose.
##Usage
var mongoose = require('mongoose');
var cachegoose = require('cachegoose');
cachegoose(mongoose, {
engine: 'redis', /* If you don't specify the redis engine, */
port: 6379, /* the query results will be cached in memory. */
host: 'localhost'
});
Record
.find({ some_condition: true })
.cache(30) // The number of seconds to cache the query. Defaults to 60 seconds.
.exec(function(err, records) {
...
});
Record
.aggregate()
.group({ total: { $sum: '$some_field' } })
.cache(0) // Explicitly passing in 0 will cache the results indefinitely.
.exec(function(err, aggResults) {
...
});
You can also pass a custom key into the .cache()
method, which you can then use later to clear the cached content.
var mongoose = require('mongoose');
var cachegoose = require('cachegoose');
cachegoose(mongoose, {
engine: 'redis',
port: 6379,
host: 'localhost'
});
var userId = '1234567890';
Children
.find({ parentId: userId })
.cache(0, userId + '-children') /* Will create a redis entry */
.exec(function(err, records) { /* with the key '1234567890-children' */
...
});
ChildrenSchema.post('save', function(child) {
// Clear the parent's cache, since a new child has been added.
cachegoose.clearCache(child.parentId + '-children');
});
That's pretty much it. Just insert .cache()
into the queries you want to cache, and they will be cached. Works with select
, lean
, sort
, and anything else that will modify the results of a query.
##Test npm test
FAQs
Mongoose caching that actually works.
The npm package cachegoose receives a total of 401 weekly downloads. As such, cachegoose popularity was classified as not popular.
We found that cachegoose 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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.