
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
aedes1cached-persistence
Advanced tools
Abstract class to write an Aedes persistence with in-process caching of subscriptions
Abstract class to write an Aedes [persistence][persistence] with in-process caching of subscriptions. It implements the API defined by aedes-persistence.
To install aedes-cached--persistence, simply use npm:
npm install aedes-cached-persistence --save
CachedPersistence()
instance.subscriptionsByTopic()
instance.cleanSubscriptions()
instance.destroy()
In order to reuse aedes-cached-persistence, you need to:
'use strict'
var util = require('util')
var CachedPersistence = require('aedes-cached-persistence')
// if you need http://npm.im/aedes-packet, it is available
// from this module as well
// var Packet = CachedPersistence.Packet
function MyPersistence (opts) {
if (!(this instanceof MyPersistence)) {
return new MyPersistence(opts)
}
// initialize your data here
CachedPersistence.call(this, opts)
}
util.inherits(MyPersistence, CachedPersistence)
MyPersistence.prototype.addSubscriptions = function (client, subs, cb) {
// ..persistence specific implementation..
// call this._addedSubscriptions when you are done
this._addedSubscriptions(client, subsObjs, cb)
}
MyPersistence.prototype.removeSubscriptions = function (client, subs, cb) {
// ..persistence specific implementation..
// call this._addedSubscriptions when you are done
this._removedSubscriptions(client, subs.map(subs, client), cb)
}
function toSubObj (sub) {
return {
clientId: this.id,
topic: sub.topic
}
}
A persistence needs to pass all tests defined in ./abstract.js. You can import and use that test suite in the following manner:
var test = require('tape').test
var myperst = require('./')
var abs = require('aedes-cached-persistence/abstract')
abs({
test: test,
persistence: myperst
})
If you require some async stuff before returning, a callback is also supported:
var test = require('tape').test
var myperst = require('./')
var abs = require('aedes-persistence/abstract')
var clean = require('./clean') // invented module
abs({
test: test,
buildEmitter: require('mymqemitter'), // optional
persistence: function build (cb) {
clean(function (err) {
cb(err, myperst())
})
}
})
MIT
FAQs
Abstract class to write an Aedes persistence with in-process caching of subscriptions
We found that aedes1cached-persistence 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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.