node_shm

0.0.1 • Public • Published

使用方式 | Usage

const cluster=require('cluster');
const shm=require('node_shm');
 
var buf;
if(cluster.isMaster){
    buf=shm.create(4096);//shm.create(size)
    cluster.fork().on('online',function(){
        this.send(buf.key);//send key
        setInterval(function(){
            console.log('[Master] Set buf[0]=%d',++buf[0]);
        },500);
    }).on('exit',() => process.exit());
}else{
    process.on('message',function(message){
        buf=shm.get(message);//shm.get(key);
        setInterval(function(){
            console.log('[Worker] Get buf[0]=%d',buf[0]);
            if(buf[0]>10) process.exit();
        },500);
    });
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    0

Package Sidebar

Install

npm i node_shm

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • a0000778