shared-node-buffer

> Node shared buffer class for fast sharing data between processes (Windows/OSX/Linux supported). >

Usage no npm install needed!

<script type="module">
  import sharedNodeBuffer from 'https://cdn.skypack.dev/shared-node-buffer';
</script>

README

shared-node-buffer

Node shared buffer class for fast sharing data between processes (Windows/OSX/Linux supported).

linux ci osx ci windows ci Version License

About

The SharedNodeBuffer class library provides Node.js class that utilise memory mapped files for fast low-level inter-process communication (IPC).

Install

> npm install shared-node-buffer --save

Example

const cluster = require("cluster");
const SharedNodeBuffer = require("shared-node-buffer");
const buffer = new SharedNodeBuffer("your key", 1024 * 1024);

if (cluster.isMain) {
  buffer.write("Hello World!");
  cluster.fork();
} else {
  console.log(buffer.slice(0, 64).toString());
}

API

SharedNodeBuffer proxys the most Buffer.prototype's method, you can find at Node.js Buffer Doc.