File: connected-users-websocket/node_modules/socket.io/node_modules/redis/examples/backpressure_drain.js

Recommend this page to a friend!
  Classes of Igor Escobar   Terminal Crossword   connected-users-websocket/node_modules/socket.io/node_modules/redis/examples/backpressure_drain.js   Download  
File: connected-users-websocket/node_modules/socket.io/node_modules/redis/examples/backpressure_drain.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Terminal Crossword
Generate a crosswords board on a text console
Author: By
Last change:
Date: 2 years ago
Size: 810 bytes
 

Contents

Class file image Download
var redis = require("../index"), client = redis.createClient(null, null, { command_queue_high_water: 5, command_queue_low_water: 1 }), remaining_ops = 100000, paused = false; function op() { if (remaining_ops <= 0) { console.error("Finished."); process.exit(0); } remaining_ops--; if (client.hset("test hash", "val " + remaining_ops, remaining_ops) === false) { console.log("Pausing at " + remaining_ops); paused = true; } else { process.nextTick(op); } } client.on("drain", function () { if (paused) { console.log("Resuming at " + remaining_ops); paused = false; process.nextTick(op); } else { console.log("Got drain while not paused at " + remaining_ops); } }); op();