Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cluster-rolling-restart

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cluster-rolling-restart - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

2

package.json
{
"name": "cluster-rolling-restart",
"version": "1.0.9",
"version": "1.0.10",
"author": {

@@ -5,0 +5,0 @@ "name": "Tyson Midboe",

# cluster-rolling-restart
A simple way to turn express into a clustered server with support for rolling restart.
A simple way to turn express into a clustered server with support for rolling restart and cache synchronization.

@@ -73,1 +73,41 @@ ## Install

```
## Using Cache Synchronization
To use cache synchronization, you send the data you want to cache to the master process. You then listen for events from the master, and when a `saveCommand` event arrives, you update your cache with the data in the event.
Send data to save to master...
```js
async save(id, data) {
if (clusterEnabled) {
process.send({
cmd: "saveBroadcast",
pid: process.pid,
id,
data,
name: this.name,
});
}
return this.dataSource.set(id, data).get(id);
}
```
Listen for save event and update cache...
```js
process.on("message", ({ cmd, id, pid, data, name }) => {
if (cmd && id && data && process.pid !== pid) {
if (cmd === "saveCommand") {
const ds = DataSourceFactory.getDataSource(name);
ds.clusterSave(id, ModelFactory.loadModel(observer, ds, data, name));
return;
}
if (cmd === "deleteCommand") {
const ds = DataSourceFactory.getDataSource(name);
ds.clusterDelete(id);
return;
}
}
});
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc