File tree Expand file tree Collapse file tree 6 files changed +11
-14
lines changed Expand file tree Collapse file tree 6 files changed +11
-14
lines changed Original file line number Diff line number Diff line change @@ -154,11 +154,11 @@ So please attach the error listener to node_redis.
154154` client ` will emit ` drain ` when the TCP connection to the Redis server has been buffering, but is now
155155writable. This event can be used to stream commands in to Redis and adapt to backpressure.
156156
157- All commands return a boolean if the stream had to buffer or not. If false is returned the stream had to buffer .
157+ If the stream is buffering ` client.should_buffer ` is set to true. Otherwise the variable is always set to false .
158158That way you can decide when to reduce your send rate and resume sending commands when you get ` drain ` .
159159
160- You can manually control the low water and high water marks by passing ommand_queue_high_water ` and ` command_queue_low_water` to the client options .
161- Check the [ Node.js streams API ] ( https://nodejs.org/api/ stream.html ) for further info .
160+ You can also check the return value of each command as it will also return the backpressure indicator .
161+ If false is returned the stream had to buffer .
162162
163163### "idle"
164164
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ Features
1010 - using .multi / .batch (up to +50% / on Node.js 0.10.x +300%)
1111 - saving small buffers
1212- Increased coverage to 99% ([ @BridgeAR ] ( https://github.com/BridgeAR ) )
13+ - Refactored manual backpressure control ([ @BridgeAR ] ( https://github.com/BridgeAR ) )
14+ - Removed the high water mark and low water mark. Such a mechanism should be implemented by a user instead
15+ - The ` drain ` event is from now on only emitted if the stream really had to buffer
1316
1417Bugfixes
1518
Original file line number Diff line number Diff line change 11'use strict' ;
22
33var redis = require ( '../index' ) ,
4- client = redis . createClient ( null , null , {
5- command_queue_high_water : 5 ,
6- command_queue_low_water : 1
7- } ) ,
4+ client = redis . createClient ( ) ,
85 remaining_ops = 100000 , paused = false ;
96
107function op ( ) {
@@ -14,11 +11,12 @@ function op() {
1411 }
1512
1613 remaining_ops -- ;
17- if ( client . hset ( 'test hash' , 'val ' + remaining_ops , remaining_ops ) === false ) {
14+ client . hset ( 'test hash' , 'val ' + remaining_ops , remaining_ops ) ;
15+ if ( client . should_buffer === true ) {
1816 console . log ( 'Pausing at ' + remaining_ops ) ;
1917 paused = true ;
2018 } else {
21- process . nextTick ( op ) ;
19+ setTimeout ( op , 1 ) ;
2220 }
2321}
2422
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ var redis = require('redis'),
44 client1 = redis . createClient ( ) , msg_count = 0 ,
55 client2 = redis . createClient ( ) ;
66
7- // Most clients probably don't do much on 'subscribe'. This example uses it to coordinate things within one program.
7+ // Most clients probably don't do much on 'subscribe'. This example uses it to coordinate things within one program.
88client1 . on ( 'subscribe' , function ( channel , count ) {
99 console . log ( 'client1 subscribed to ' + channel + ', ' + count + ' total subscriptions' ) ;
1010 if ( count === 2 ) {
Original file line number Diff line number Diff line change @@ -82,8 +82,6 @@ function RedisClient(stream, options) {
8282 options . detect_buffers = false ;
8383 }
8484 this . should_buffer = false ;
85- this . command_queue_high_water = + options . command_queue_high_water || 1000 ;
86- this . command_queue_low_water = options . command_queue_low_water | 0 ;
8785 this . max_attempts = options . max_attempts | 0 ;
8886 this . command_queue = new Queue ( ) ; // Holds sent commands to de-pipeline them
8987 this . offline_queue = new Queue ( ) ; // Holds commands issued but not able to be sent
Original file line number Diff line number Diff line change @@ -15,8 +15,6 @@ describe("The 'keys' method", function () {
1515
1616 beforeEach ( function ( done ) {
1717 args = args || { } ;
18- // This is going to test if the high water is also respected
19- args . command_queue_high_water = 100 ;
2018 client = redis . createClient . apply ( redis . createClient , args ) ;
2119 client . once ( "ready" , function ( ) {
2220 client . flushdb ( done ) ;
You can’t perform that action at this time.
0 commit comments