diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 88974e42dac..c3db31f3bb1 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -13,17 +13,17 @@ jobs: redis-version: [5] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2.3.4 with: fetch-depth: 1 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2.1.5 with: node-version: ${{ matrix.node-version }} - name: Setup Redis - uses: shogo82148/actions-setup-redis@v1.0.1 + uses: shogo82148/actions-setup-redis@v1.9.7 with: redis-version: ${{ matrix.redis-version }} auto-start: "true" @@ -32,7 +32,7 @@ jobs: - name: Run Benchmark run: npm run benchmark > benchmark-output.txt && cat benchmark-output.txt - name: Upload Benchmark Result - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2.2.2 with: name: benchmark-output.txt path: benchmark-output.txt diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 08a5f1e5ac3..d110707ee09 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -7,10 +7,10 @@ jobs: name: ESLint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2.3.4 with: fetch-depth: 1 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2.1.5 with: node-version: 12 - run: npm i --no-audit --prefer-offline @@ -20,12 +20,12 @@ jobs: run: npm run lint:report continue-on-error: true - name: Annotate Code Linting Results - uses: ataylorme/eslint-annotate-action@1.0.4 + uses: ataylorme/eslint-annotate-action@1.1.2 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" report-json: "eslint-report.json" - name: Upload ESLint report - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2.2.2 with: name: eslint-report.json path: eslint-report.json diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a7829a9d1b5..b3a608ac77f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,17 +13,17 @@ jobs: redis-version: [4.x, 5.x] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2.3.4 with: fetch-depth: 1 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2.1.5 with: node-version: ${{ matrix.node-version }} - name: Setup Redis - uses: shogo82148/actions-setup-redis@v1.0.1 + uses: shogo82148/actions-setup-redis@v1.9.7 with: redis-version: ${{ matrix.redis-version }} auto-start: "false" @@ -46,7 +46,7 @@ jobs: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} - name: Upload Coverage Report - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2.2.2 with: name: coverage path: coverage diff --git a/.github/workflows/tests_windows.yml b/.github/workflows/tests_windows.yml index 504cb6a4f8f..2f5e7e441ab 100644 --- a/.github/workflows/tests_windows.yml +++ b/.github/workflows/tests_windows.yml @@ -11,14 +11,14 @@ jobs: matrix: node-version: [6.x, 8.x, 10.x, 12.x] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2.3.4 with: fetch-depth: 1 - name: Install Redis - uses: crazy-max/ghaction-chocolatey@v1 + uses: crazy-max/ghaction-chocolatey@v1.4.0 with: - args: install redis-64 --no-progress + args: install redis-64 --version=3.0.503 --no-progress - name: Start Redis run: | @@ -27,7 +27,7 @@ jobs: redis-cli config set stop-writes-on-bgsave-error no - name: Setup Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2.1.5 with: node-version: ${{ matrix.node-version }} @@ -43,7 +43,7 @@ jobs: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} - name: Upload Coverage Report - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2.2.2 with: name: coverage path: coverage diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f9cba8b4a61..d9fac6a450c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,9 +82,13 @@ Working on your first Pull Request? You can learn how from this _free_ series, Node Redis has a full test suite with coverage setup. -To run the tests use the `npm test` command. To check detailed coverage locally run the `npm run coverage` command after +To run the tests, run `npm install` to install all dependencies, and then run `npm test`. To check detailed coverage locally run the `npm run coverage` command after testing and open the generated `./coverage/index.html` in your browser. +Note that the test suite assumes that a few tools are installed in your environment, such as: +- redis (make sure redis-server is not running when starting the tests, it's part of the test-suite to start it and you'll end up with a "port already in use" error) +- stunnel (for TLS tests) + ### Submitting code for review The bigger the pull request, the longer it will take to review and merge. Where possible try to break down large pull diff --git a/README.md b/README.md index 5c1f3dce58e..4e47c6f9bdc 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Windows Build Status Coverage Status Follow on Twitter + Coverage Status

--- @@ -171,15 +172,15 @@ using unix sockets if possible to increase throughput. | port | 6379 | Port of the Redis server | | path | null | The UNIX socket string of the Redis server | | url | null | The URL of the Redis server. Format: `[redis[s]:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]` (More info avaliable at [IANA](http://www.iana.org/assignments/uri-schemes/prov/redis)). | -| string_numbers | null | Set to `true`, Node Redis will return Redis number values as Strings instead of javascript Numbers. Useful if you need to handle big numbers (above `Number.MAX_SAFE_INTEGER === 2^53`). Hiredis is incapable of this behavior, so setting this option to `true` will result in the built-in javascript parser being used no matter the value of the `parser` option. | +| string_numbers | null | Set to `true`, Node Redis will return Redis number values as Strings instead of javascript Numbers. Useful if you need to handle big numbers (above `Number.MAX_SAFE_INTEGER === 2^53`). Hiredis is incapable of this behavior, so setting this option to `true` will result in the built-in javascript parser being used no matter the value of the `parser` option. | | return_buffers | false | If set to `true`, then all replies will be sent to callbacks as Buffers instead of Strings. | | detect_buffers | false | If set to `true`, then replies will be sent to callbacks as Buffers. This option lets you switch between Buffers and Strings on a per-command basis, whereas `return_buffers` applies to every command on a client. **Note**: This doesn't work properly with the pubsub mode. A subscriber has to either always return Strings or Buffers. | | socket_keepalive | true | If set to `true`, the keep-alive functionality is enabled on the underlying socket. | | socket_initial_delay | 0 | Initial Delay in milliseconds, and this will also behave the interval keep alive message sending to Redis. | -| no_ready_check | false | When a connection is established to the Redis server, the server might still be loading the database from disk. While loading, the server will not respond to any commands. To work around this, Node Redis has a "ready check" which sends the `INFO` command to the server. The response from the `INFO` command indicates whether the server is ready for more commands. When ready, `node_redis` emits a `ready` event. Setting `no_ready_check` to `true` will inhibit this check. | +| no_ready_check | false | When a connection is established to the Redis server, the server might still be loading the database from disk. While loading, the server will not respond to any commands. To work around this, Node Redis has a "ready check" which sends the `INFO` command to the server. The response from the `INFO` command indicates whether the server is ready for more commands. When ready, `node_redis` emits a `ready` event. Setting `no_ready_check` to `true` will inhibit this check. | | enable_offline_queue | true | By default, if there is no active connection to the Redis server, commands are added to a queue and are executed once the connection has been established. Setting `enable_offline_queue` to `false` will disable this feature and the callback will be executed immediately with an error, or an error will be emitted if no callback is specified. | | retry_unfulfilled_commands | false | If set to `true`, all commands that were unfulfilled while the connection is lost will be retried after the connection has been reestablished. Use this with caution if you use state altering commands (e.g. `incr`). This is especially useful if you use blocking commands. | -| password | null | If set, client will run Redis auth command on connect. Alias `auth_pass` **Note** Node Redis < 2.5 must use `auth_pass` | +| password | null | If set, client will run Redis auth command on connect. Alias `auth_pass` **Note** Node Redis < 2.5 must use `auth_pass` | | db | null | If set, client will run Redis `select` command on connect. | | family | IPv4 | You can force using IPv6 if you set the family to 'IPv6'. See Node.js [net](https://nodejs.org/api/net.html) or [dns](https://nodejs.org/api/dns.html) modules on how to use the family type. | | disable_resubscribing | false | If set to `true`, a client won't resubscribe after disconnecting. | @@ -187,6 +188,7 @@ using unix sockets if possible to increase throughput. | tls | null | An object containing options to pass to [tls.connect](http://nodejs.org/api/tls.html#tls_tls_connect_port_host_options_callback) to set up a TLS connection to Redis (if, for example, it is set up to be accessible via a tunnel). | | prefix | null | A string used to prefix all used keys (e.g. `namespace:test`). Please be aware that the `keys` command will not be prefixed. The `keys` 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. | | retry_strategy | function | A function that receives an 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 will happen and all offline commands are flushed with errors. Return an error to return that specific error to all offline commands. Example below. | +| connect_timeout | 3600000 | In milliseconds. This should only be the timeout for connecting to redis, but for now it interferes with `retry_strategy` and stops it from reconnecting after this timeout. | **`detect_buffers` example:** @@ -847,19 +849,19 @@ non-blocking ones may be queued up until after the blocking ones finish. Another reason to use duplicate() is when multiple DBs on the same server are accessed via the redis SELECT command. Each DB could use its own connection. -### `client.send_command(command_name[, [args][, callback]])` +### `client.sendCommand(command_name[, [args][, callback]])` All Redis commands have been added to the `client` object. However, if new commands are introduced before this library is updated or if you want to add -individual commands you can use `send_command()` to send arbitrary commands to +individual commands you can use `sendCommand()` to send arbitrary commands to Redis. All commands are sent as multi-bulk commands. `args` can either be an Array of arguments, or omitted / set to undefined. -### `redis.add_command(command_name)` +### `redis.addCommand(command_name)` -Calling add_command will add a new command to the prototype. The exact command +Calling addCommand will add a new command to the prototype. The exact command name will be used when calling using this new command. Using arbitrary arguments is possible as with any other command.