Skip to content

Commit 5294917

Browse files
committed
Merge pull request #1018 from NodeRedis/docu
Improve test and add some more documentation
2 parents 6e06301 + 7af9004 commit 5294917

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ limits total amount of connection tries. Setting this to 1 will prevent any reco
215215
* `rename_commands`: *null*; pass a object with renamed commands to use those instead of the original functions. See the [redis security topics](http://redis.io/topics/security) for more info.
216216
* `tls`: an object containing options to pass to [tls.connect](http://nodejs.org/api/tls.html#tls_tls_connect_port_host_options_callback),
217217
to set up a TLS connection to Redis (if, for example, it is set up to be accessible via a tunnel).
218-
* `prefix`: *null*; pass a string to prefix all used keys with that string as prefix e.g. 'namespace:test'
218+
* `prefix`: *null*; pass a string to prefix all used keys with that string as prefix e.g. 'namespace:test'. Please be aware, that the "keys" command is not going to be prefixed. The command has a "pattern" as argument and no key and it would be impossible to determine the existing keys in Redis if this would be prefixed.
219219
* `retry_strategy`: *function*; pass a function that receives a options object as parameter including the retry `attempt`, the `total_retry_time` indicating how much time passed since the last time connected, the `error` why the connection was lost and the number of `times_connected` in total. If you return a number from this function, the retry will happen exactly after that time in milliseconds. If you return a non-number no further retry is going to happen and all offline commands are flushed with errors. Return a error to return that specific error to all offline commands. Check out the example too.
220220

221221
```js

test/auth.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ describe("client authentication", function () {
5252
var time = Date.now();
5353
client.auth(auth, function (err, res) {
5454
assert.strictEqual('retry worked', res);
55-
assert(Date.now() - time >= 200, 'Time should be above 200 ms (the reconnect time)');
56-
assert(Date.now() - time < 300, 'Time should be below 300 ms (the reconnect should only take a bit above 200 ms)');
55+
var now = Date.now();
56+
// Hint: setTimeout sometimes triggers early and therefor the value can be like one or two ms to early
57+
assert(now - time >= 198, 'Time should be above 200 ms (the reconnect time) and is ' + (now - time));
58+
assert(now - time < 300, 'Time should be below 300 ms (the reconnect should only take a bit above 200 ms) and is ' + (now - time));
5759
done();
5860
});
5961
var tmp = client.command_queue.get(0).callback;

0 commit comments

Comments
 (0)