Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / redis / examples / backpressure_drain.js
1 var redis = require("../index"),
2     client = redis.createClient(null, null, {
3         command_queue_high_water: 5,
4         command_queue_low_water: 1
5     }),
6     remaining_ops = 100000, paused = false;
7
8 function op() {
9     if (remaining_ops <= 0) {
10         console.error("Finished.");
11         process.exit(0);
12     }
13
14     remaining_ops--;
15     if (client.hset("test hash", "val " + remaining_ops, remaining_ops) === false) {
16         console.log("Pausing at " + remaining_ops);
17         paused = true;
18     } else {
19         process.nextTick(op);
20     }
21 }
22
23 client.on("drain", function () {
24     if (paused) {
25         console.log("Resuming at " + remaining_ops);
26         paused = false;
27         process.nextTick(op);
28     } else {
29         console.log("Got drain while not paused at " + remaining_ops);
30     }
31 });
32
33 op();