aedes-cached-persistence
Abstract class to write an Aedes [persistence][persistence] with in-process caching of subscriptions. It implements the API defined by aedes-persistence.
Install
To install aedes-cached--persistence, simply use npm:
npm install aedes-cached-persistence --save
Provided methods
CachedPersistence()
instance.subscriptionsByTopic()
instance.cleanSubscriptions()
instance.destroy()
Implement another persistence
Inheritance
In order to reuse aedes-cached-persistence, you need to:
'use strict' var util = var CachedPersistence = // if you need http://npm.im/aedes-packet, it is available// from this module as well// var Packet = CachedPersistence.Packet { if !this instanceof MyPersistence return opts // initialize your data here CachedPersistence} util MyPersistenceprototype { // ..persistence specific implementation.. // call this._addedSubscriptions when you are done this} MyPersistenceprototype { // ..persistence specific implementation.. // call this._addedSubscriptions when you are done this} { return clientId: thisid topic: subtopic }
Tests
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 = testvar myperst = var abs =
If you require some async stuff before returning, a callback is also supported:
var test = testvar myperst = var abs = var clean = // invented module
License
MIT