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.
154
154
` client ` will emit ` drain ` when the TCP connection to the Redis server has been buffering, but is now
155
155
writable. This event can be used to stream commands in to Redis and adapt to backpressure.
156
156
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 .
158
158
That way you can decide when to reduce your send rate and resume sending commands when you get ` drain ` .
159
159
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 .
162
162
163
163
### "idle"
164
164
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ Features
10
10
- using .multi / .batch (up to +50% / on Node.js 0.10.x +300%)
11
11
- saving small buffers
12
12
- 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
13
16
14
17
Bugfixes
15
18
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
var 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 ( ) ,
8
5
remaining_ops = 100000 , paused = false ;
9
6
10
7
function op ( ) {
@@ -14,11 +11,12 @@ function op() {
14
11
}
15
12
16
13
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 ) {
18
16
console . log ( 'Pausing at ' + remaining_ops ) ;
19
17
paused = true ;
20
18
} else {
21
- process . nextTick ( op ) ;
19
+ setTimeout ( op , 1 ) ;
22
20
}
23
21
}
24
22
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ var redis = require('redis'),
4
4
client1 = redis . createClient ( ) , msg_count = 0 ,
5
5
client2 = redis . createClient ( ) ;
6
6
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.
8
8
client1 . on ( 'subscribe' , function ( channel , count ) {
9
9
console . log ( 'client1 subscribed to ' + channel + ', ' + count + ' total subscriptions' ) ;
10
10
if ( count === 2 ) {
Original file line number Diff line number Diff line change @@ -82,8 +82,6 @@ function RedisClient(stream, options) {
82
82
options . detect_buffers = false ;
83
83
}
84
84
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 ;
87
85
this . max_attempts = options . max_attempts | 0 ;
88
86
this . command_queue = new Queue ( ) ; // Holds sent commands to de-pipeline them
89
87
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 () {
15
15
16
16
beforeEach ( function ( done ) {
17
17
args = args || { } ;
18
- // This is going to test if the high water is also respected
19
- args . command_queue_high_water = 100 ;
20
18
client = redis . createClient . apply ( redis . createClient , args ) ;
21
19
client . once ( "ready" , function ( ) {
22
20
client . flushdb ( done ) ;
You can’t perform that action at this time.
0 commit comments