Copy disabled (too large)
Download .txt
Showing preview only (19,804K chars total). Download the full file to get everything.
Repository: redis/ioredis
Branch: main
Commit: 9e26f8b384e9
Files: 213
Total size: 19.9 MB
Directory structure:
gitextract_79gv0u86/
├── .eslintrc.json
├── .github/
│ ├── CONTRIBUTING.md
│ ├── FUNDING.yml
│ ├── stale.yml
│ └── workflows/
│ ├── manual.yml
│ ├── push-requests.yml
│ ├── release.yml
│ ├── stale-issues.yml
│ ├── test.yml
│ └── test_with_cov.yml
├── .gitignore
├── .prettierignore
├── .releaserc.json
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── benchmarks/
│ ├── autopipelining-cluster.ts
│ ├── autopipelining-single.ts
│ ├── dropBuffer.ts
│ ├── errorStack.ts
│ └── fixtures/
│ ├── generate.ts
│ └── insert.ts
├── bin/
│ ├── argumentTypes.js
│ ├── index.js
│ ├── overrides.js
│ ├── returnTypes.js
│ ├── sortArguments.js
│ ├── template.ts
│ └── typeMaps.js
├── docs/
│ ├── .nojekyll
│ ├── assets/
│ │ ├── highlight.css
│ │ ├── icons.css
│ │ ├── main.js
│ │ ├── search.js
│ │ └── style.css
│ ├── classes/
│ │ ├── Cluster.html
│ │ └── Redis.html
│ ├── index.html
│ └── interfaces/
│ ├── ChainableCommander.html
│ ├── ClusterOptions.html
│ ├── CommonRedisOptions.html
│ ├── SentinelAddress.html
│ └── SentinelConnectionOptions.html
├── examples/
│ ├── basic_operations.js
│ ├── custom_connector.js
│ ├── express/
│ │ ├── README.md
│ │ ├── app.js
│ │ ├── bin/
│ │ │ └── www
│ │ ├── package.json
│ │ ├── public/
│ │ │ └── stylesheets/
│ │ │ └── style.css
│ │ ├── redis.js
│ │ ├── routes/
│ │ │ ├── index.js
│ │ │ └── users.js
│ │ └── views/
│ │ ├── error.jade
│ │ ├── index.jade
│ │ ├── layout.jade
│ │ └── users.jade
│ ├── hash.js
│ ├── list.js
│ ├── module.js
│ ├── redis_streams.js
│ ├── set.js
│ ├── stream.js
│ ├── string.js
│ ├── ttl.js
│ ├── typescript/
│ │ ├── package.json
│ │ └── scripts.ts
│ └── zset.js
├── lib/
│ ├── Command.ts
│ ├── DataHandler.ts
│ ├── Pipeline.ts
│ ├── Redis.ts
│ ├── ScanStream.ts
│ ├── Script.ts
│ ├── SubscriptionSet.ts
│ ├── autoPipelining.ts
│ ├── cluster/
│ │ ├── ClusterOptions.ts
│ │ ├── ClusterSubscriber.ts
│ │ ├── ClusterSubscriberGroup.ts
│ │ ├── ConnectionPool.ts
│ │ ├── DelayQueue.ts
│ │ ├── ShardedSubscriber.ts
│ │ ├── index.ts
│ │ └── util.ts
│ ├── connectors/
│ │ ├── AbstractConnector.ts
│ │ ├── ConnectorConstructor.ts
│ │ ├── SentinelConnector/
│ │ │ ├── FailoverDetector.ts
│ │ │ ├── SentinelIterator.ts
│ │ │ ├── index.ts
│ │ │ └── types.ts
│ │ ├── StandaloneConnector.ts
│ │ └── index.ts
│ ├── constants/
│ │ └── TLSProfiles.ts
│ ├── errors/
│ │ ├── ClusterAllFailedError.ts
│ │ ├── MaxRetriesPerRequestError.ts
│ │ └── index.ts
│ ├── index.ts
│ ├── redis/
│ │ ├── RedisOptions.ts
│ │ └── event_handler.ts
│ ├── transaction.ts
│ ├── types.ts
│ └── utils/
│ ├── Commander.ts
│ ├── RedisCommander.ts
│ ├── applyMixin.ts
│ ├── argumentParsers.ts
│ ├── debug.ts
│ ├── index.ts
│ └── lodash.ts
├── package.json
├── test/
│ ├── cluster/
│ │ ├── basic.ts
│ │ ├── cluster_subscriber_group.ts
│ │ └── docker/
│ │ ├── Dockerfile
│ │ └── main.sh
│ ├── docker-compose.yml
│ ├── functional/
│ │ ├── auth.ts
│ │ ├── autopipelining.ts
│ │ ├── blocking_timeout.ts
│ │ ├── client_info.ts
│ │ ├── cluster/
│ │ │ ├── ClusterSubscriber.ts
│ │ │ ├── ask.ts
│ │ │ ├── autopipelining.ts
│ │ │ ├── clusterdown.ts
│ │ │ ├── connect.ts
│ │ │ ├── disconnection.ts
│ │ │ ├── dnsLookup.ts
│ │ │ ├── duplicate.ts
│ │ │ ├── index.ts
│ │ │ ├── maxRedirections.ts
│ │ │ ├── moved.ts
│ │ │ ├── nat.ts
│ │ │ ├── pipeline.ts
│ │ │ ├── pub_sub.ts
│ │ │ ├── quit.ts
│ │ │ ├── resolveSrv.ts
│ │ │ ├── scripting.ts
│ │ │ ├── spub_ssub.ts
│ │ │ ├── tls.ts
│ │ │ ├── transaction.ts
│ │ │ └── tryagain.ts
│ │ ├── commandTimeout.ts
│ │ ├── commands/
│ │ │ ├── hexpireat.ts
│ │ │ ├── hexpiretime.ts
│ │ │ ├── hgetdel.ts
│ │ │ ├── hgetex.ts
│ │ │ ├── hpersist.ts
│ │ │ ├── hpexpireat.ts
│ │ │ ├── hpexpiretime.ts
│ │ │ ├── hpttl.ts
│ │ │ ├── hsetex.ts
│ │ │ ├── httl.ts
│ │ │ ├── xdelex.ts
│ │ │ └── xtrim.ts
│ │ ├── connection.ts
│ │ ├── disconnection.ts
│ │ ├── duplicate.ts
│ │ ├── elasticache.ts
│ │ ├── exports.ts
│ │ ├── fatal_error.ts
│ │ ├── hexpire.ts
│ │ ├── hgetall.ts
│ │ ├── hpexpire.ts
│ │ ├── lazy_connect.ts
│ │ ├── maxRetriesPerRequest.ts
│ │ ├── monitor.ts
│ │ ├── pipeline.ts
│ │ ├── pub_sub.ts
│ │ ├── ready_check.ts
│ │ ├── reconnect_on_error.ts
│ │ ├── scan_stream.ts
│ │ ├── scripting.ts
│ │ ├── select.ts
│ │ ├── send_command.ts
│ │ ├── sentinel.ts
│ │ ├── sentinel_nat.ts
│ │ ├── show_friendly_error_stack.ts
│ │ ├── socketTimeout.ts
│ │ ├── spub_ssub.ts
│ │ ├── string_numbers.ts
│ │ ├── tls.ts
│ │ ├── transaction.ts
│ │ ├── transformer.ts
│ │ └── watch-exec.ts
│ ├── helpers/
│ │ ├── global.ts
│ │ ├── mock_server.ts
│ │ └── util.ts
│ ├── scenario/
│ │ ├── sharded-pub-sub/
│ │ │ ├── basic.test.ts
│ │ │ ├── connection-lifecycle.test.ts
│ │ │ ├── failure-recovery.multi.test.ts
│ │ │ └── failure-recovery.single.test.ts
│ │ └── utils/
│ │ ├── command-runner.ts
│ │ ├── fault-injector.ts
│ │ ├── message-tracker.ts
│ │ └── test.util.ts
│ ├── typing/
│ │ ├── commands.test-d.ts
│ │ ├── events.test-.ts
│ │ ├── options.test-d.ts
│ │ ├── pipeline.test-d.ts
│ │ └── transformers.test-d.ts
│ └── unit/
│ ├── DataHandler.ts
│ ├── autoPipelining.ts
│ ├── clusters/
│ │ ├── ConnectionPool.ts
│ │ └── index.ts
│ ├── command.ts
│ ├── commander.ts
│ ├── connectors/
│ │ ├── SentinelConnector/
│ │ │ └── SentinelIterator.ts
│ │ └── connector.ts
│ ├── debug.ts
│ ├── index.ts
│ ├── pipeline.ts
│ ├── redis.ts
│ └── utils.ts
└── tsconfig.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .eslintrc.json
================================================
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"ignorePatterns": ["bin/generateRedisCommander/template.ts"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"env": { "node": true },
"rules": {
"prefer-rest-params": 0,
"no-var": 0,
"no-prototype-builtins": 0,
"prefer-spread": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-this-alias": 0,
"@typescript-eslint/ban-ts-ignore": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/adjacent-overload-signatures": 0,
"@typescript-eslint/ban-types": 0,
"@typescript-eslint/member-ordering": [
1,
{
"default": {
"memberTypes": [
"public-static-field",
"protected-static-field",
"private-static-field",
"public-static-method",
"protected-static-method",
"private-static-method",
"public-instance-field",
"protected-instance-field",
"private-instance-field",
"public-constructor",
"private-constructor",
"protected-constructor",
"public-instance-method",
"protected-instance-method",
"private-instance-method"
]
}
}
],
"@typescript-eslint/explicit-member-accessibility": [
1,
{ "accessibility": "no-public" }
],
"@typescript-eslint/no-empty-interface": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-unused-vars": [
"warn",
{
"args": "none"
}
]
},
"overrides": [
{
"files": ["test/cluster/*", "test/unit/*", "test/functional/*"],
"env": {
"mocha": true
},
"rules": { "prefer-const": 0 }
}
]
}
================================================
FILE: .github/CONTRIBUTING.md
================================================
# Contributing to this repository
Thanks for contributing to ioredis! 👏
The goal of ioredis is to become a Redis client that is delightful to work with. It should have a full feature set, easy-to-use APIs, and high performance.
Nowadays, it is one of the most popular Redis clients, and more and more people are using it. That's why we are welcoming more people to contribute to ioredis to make it even better! 👍
## User Roles
There are two user roles: contributors and collaborators. Everyone becomes a contributor when they are creating issues, pull requests, or helping to review code.
In the meantime, there is a group of collaborators of ioredis who can not only contribute code but also approve and merge others' pull requests.
## Note to collaborators
Thank you for being a collaborator (which means you have already contributed amazing code so thanks again)! As a collaborator, you have the following permissions:
1. Approve pull requests.
2. Merge pull requests.
Considering ioredis has been used in a great many serious codebases, we must be careful with code changes. In this repository, at least one approval is required for each pull request to be merged.
ioredis uses [semantic-release](https://github.com/semantic-release/semantic-release). Every commit to the master branch will trigger a release automatically. To get a helpful changelog and make sure the version is correct, we adopt AngularJS's convention for commit message format. Please read more here: https://github.com/semantic-release/semantic-release#commit-message-format
We prefer a linear Git history, so when merging a pull request, we should always go with squash, and update the commit message to fit our convention (simply put, prefix with `feat: ` for features, `fix: ` for fixes, `refactor: ` for refactors, and `docs: ` for documentation changes).
================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms
github: luin
================================================
FILE: .github/stale.yml
================================================
daysUntilStale: 365
daysUntilClose: 7
exemptLabels:
- pinned
- security
- bug
- discussion
staleLabel: wontfix
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed after 7 days if no further activity occurs,
but feel free to re-open a closed issue if needed.
closeComment: false
================================================
FILE: .github/workflows/manual.yml
================================================
name: Manual
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to run the workflow on'
required: true
default: 'main'
jobs:
test:
uses: ./.github/workflows/test.yml
with:
branch: ${{ inputs.branch }}
================================================
FILE: .github/workflows/push-requests.yml
================================================
name: Pull Requests
on:
pull_request:
branches: [main]
jobs:
test:
uses: ./.github/workflows/test_with_cov.yml
================================================
FILE: .github/workflows/release.yml
================================================
name: Release
on: workflow_dispatch
concurrency:
group: release_version
cancel-in-progress: true
jobs:
test:
uses: ./.github/workflows/test_with_cov.yml
release:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: "lts/*"
- run: npm ci
- run: npm run build
- run: npm run docs
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_AUTHOR_NAME: "ioredis robot"
GIT_AUTHOR_EMAIL: "ioredis-robot@zihua.li"
run: npx semantic-release
================================================
FILE: .github/workflows/stale-issues.yml
================================================
name: "Stale Issue Management"
on:
schedule:
# Run daily at midnight UTC
- cron: "0 0 * * *"
workflow_dispatch: # Allow manual triggering
env:
# Default stale policy timeframes
DAYS_BEFORE_STALE: 365
DAYS_BEFORE_CLOSE: 30
# Accelerated timeline for needs-information issues
NEEDS_INFO_DAYS_BEFORE_STALE: 30
NEEDS_INFO_DAYS_BEFORE_CLOSE: 7
jobs:
stale:
runs-on: ubuntu-latest
steps:
# First step: Handle regular issues (excluding needs-information)
- name: Mark regular issues as stale
uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
# Default stale policy
days-before-stale: ${{ env.DAYS_BEFORE_STALE }}
days-before-close: ${{ env.DAYS_BEFORE_CLOSE }}
# Explicit stale label configuration
stale-issue-label: "stale"
stale-pr-label: "stale"
stale-issue-message: |
This issue has been automatically marked as stale due to inactivity.
It will be closed in 30 days if no further activity occurs.
If you believe this issue is still relevant, please add a comment to keep it open.
close-issue-message: |
This issue has been automatically closed due to inactivity.
If you believe this issue is still relevant, please reopen it or create a new issue with updated information.
# Exclude needs-information issues from this step
exempt-issue-labels: 'no-stale,needs-information'
# Remove stale label when issue/PR becomes active again
remove-stale-when-updated: true
# Apply to pull requests with same timeline
days-before-pr-stale: ${{ env.DAYS_BEFORE_STALE }}
days-before-pr-close: ${{ env.DAYS_BEFORE_CLOSE }}
stale-pr-message: |
This pull request has been automatically marked as stale due to inactivity.
It will be closed in 30 days if no further activity occurs.
close-pr-message: |
This pull request has been automatically closed due to inactivity.
If you would like to continue this work, please reopen the PR or create a new one.
# Only exclude no-stale PRs (needs-information PRs follow standard timeline)
exempt-pr-labels: 'no-stale'
# Second step: Handle needs-information issues with accelerated timeline
- name: Mark needs-information issues as stale
uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
# Accelerated timeline for needs-information
days-before-stale: ${{ env.NEEDS_INFO_DAYS_BEFORE_STALE }}
days-before-close: ${{ env.NEEDS_INFO_DAYS_BEFORE_CLOSE }}
# Explicit stale label configuration
stale-issue-label: "stale"
# Only target ISSUES with needs-information label (not PRs)
only-issue-labels: 'needs-information'
stale-issue-message: |
This issue has been marked as stale because it requires additional information
that has not been provided for 30 days. It will be closed in 7 days if the
requested information is not provided.
close-issue-message: |
This issue has been closed because the requested information was not provided within the specified timeframe.
If you can provide the missing information, please reopen this issue or create a new one.
# Disable PR processing for this step
days-before-pr-stale: -1
days-before-pr-close: -1
# Remove stale label when issue becomes active again
remove-stale-when-updated: true
================================================
FILE: .github/workflows/test.yml
================================================
on:
workflow_call:
inputs:
branch:
required: false
type: string
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [12.x, 14.x, 16.x, 18.x, 20.x]
steps:
- name: Git checkout
uses: actions/checkout@v2
with:
ref: ${{ inputs.branch || github.event.pull_request.head.ref || github.ref_name }}
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Start Redis
uses: supercharge/redis-github-action@1.4.0
with:
redis-version: latest
- run: npm run cluster:setup
- run: npm install
- run: npm run lint
- run: npm run build
- run: npm run test:tsd
- run: npm run test:cov || npm run test:cov || npm run test:cov
- run: npm run test:cluster
================================================
FILE: .github/workflows/test_with_cov.yml
================================================
on:
workflow_call:
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [20.x, 22.x, 24.x]
redis: ["rs-7.4.0-v1", "8.2", "8.4.0"]
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm run docker:setup
env:
REDIS_VERSION: ${{ matrix.redis }}
- run: npm install
- run: npm run lint
- run: npm run build
- run: npm run test:tsd
- run: npm run test:cov || npm run test:cov || npm run test:cov
- run: npm run test:cluster
- name: Coveralls
if: matrix.node == '24.x'
continue-on-error: true
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: node-${{matrix.node}}
parallel: true
code-coverage:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls
continue-on-error: true
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
================================================
FILE: .gitignore
================================================
node_modules
*.cpuprofile
/test.*
/.idea
built
.nyc_output
coverage
.vscode
benchmarks/fixtures/*.txt
*.rdb
================================================
FILE: .prettierignore
================================================
package*.json
built/
node_modules/
coverage/
.vscode/
================================================
FILE: .releaserc.json
================================================
{
"branches": [
"main",
{
"name": "beta",
"channel": "beta",
"tag": "beta",
"prerelease": "beta"
}
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "angular",
"parserOpts": {
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
}
}
],
"@semantic-release/release-notes-generator",
["@semantic-release/changelog", { "changelogFile": "CHANGELOG.md" }],
"@semantic-release/npm",
[
"@semantic-release/git",
{
"assets": [
"package.json",
"package-lock.json",
"CHANGELOG.md",
"docs/**/*"
]
}
],
"@semantic-release/github"
]
}
================================================
FILE: CHANGELOG.md
================================================
## [5.10.1](https://github.com/luin/ioredis/compare/v5.10.0...v5.10.1) (2026-03-19)
### Bug Fixes
* **cluster:** lazily start sharded subscribers ([#2090](https://github.com/luin/ioredis/issues/2090)) ([4f167bb](https://github.com/luin/ioredis/commit/4f167bb9f494f0e8200a20dedd8bbdf1810fcd22))
# [5.10.0](https://github.com/luin/ioredis/compare/v5.9.3...v5.10.0) (2026-02-27)
### Features
* add hash field expiration commands and tests ([5219f9f](https://github.com/luin/ioredis/commit/5219f9f6ae40c5b4e9bc40581d6513da27dbf1c2))
* add hexpireat & hexpiretime ([#2082](https://github.com/luin/ioredis/issues/2082)) ([b38124f](https://github.com/luin/ioredis/commit/b38124f784cc6d170ff60f508f3bc34269806f47))
## [5.9.3](https://github.com/luin/ioredis/compare/v5.9.2...v5.9.3) (2026-02-12)
### Bug Fixes
* autopipelining to route writes to masters with scaleReads ([#2072](https://github.com/luin/ioredis/issues/2072)) ([8adb1ae](https://github.com/luin/ioredis/commit/8adb1aeb6f01cb2cf832c1f218033daf2a722925))
* fix issue with moved command for replicas ([#2064](https://github.com/luin/ioredis/issues/2064)) ([de4eed4](https://github.com/luin/ioredis/commit/de4eed4c88c1222002223b17d6d481c2a12df329))
* **types:** optional properties on RedisOptions allow explicit undefined ([#2066](https://github.com/luin/ioredis/issues/2066)) ([0a1a898](https://github.com/luin/ioredis/commit/0a1a8982f9c912c78de68295e1f56136b62a645e))
## [5.9.3](https://github.com/luin/ioredis/compare/v5.9.2...v5.9.3) (2026-02-12)
### Bug Fixes
* autopipelining to route writes to masters with scaleReads ([#2072](https://github.com/luin/ioredis/issues/2072)) ([8adb1ae](https://github.com/luin/ioredis/commit/8adb1aeb6f01cb2cf832c1f218033daf2a722925))
* fix issue with moved command for replicas ([#2064](https://github.com/luin/ioredis/issues/2064)) ([de4eed4](https://github.com/luin/ioredis/commit/de4eed4c88c1222002223b17d6d481c2a12df329))
* **types:** optional properties on RedisOptions allow explicit undefined ([#2066](https://github.com/luin/ioredis/issues/2066)) ([0a1a898](https://github.com/luin/ioredis/commit/0a1a8982f9c912c78de68295e1f56136b62a645e))
## [5.9.2](https://github.com/luin/ioredis/compare/v5.9.1...v5.9.2) (2026-01-15)
### Bug Fixes
* **cluster:** Cluster reconnect sharded subscribers ([#2060](https://github.com/luin/ioredis/issues/2060)) ([def9804](https://github.com/luin/ioredis/commit/def9804dd44faa13dd57347c7353142ec0bd2d8f))
* preserve replica slots on MOVED in pipelines ([#2059](https://github.com/luin/ioredis/issues/2059)) ([a1c3e9d](https://github.com/luin/ioredis/commit/a1c3e9d3a1915cf4a699aff9781629e492f75076))
### Reverts
* Revert "fix: preserve replica slots on MOVED in pipelines (#2059)" (#2062) ([517b932](https://github.com/luin/ioredis/commit/517b93239648c06829c695112223c9f17c2e7f80)), closes [#2059](https://github.com/luin/ioredis/issues/2059) [#2062](https://github.com/luin/ioredis/issues/2062)
## [5.9.1](https://github.com/luin/ioredis/compare/v5.9.0...v5.9.1) (2026-01-08)
### Bug Fixes
* make client-side blocking timeouts opt-in ([#2058](https://github.com/luin/ioredis/issues/2058)) ([07ed493](https://github.com/luin/ioredis/commit/07ed4939ce4228efa1f85f75c16528aa5f25862e))
# [5.9.0](https://github.com/luin/ioredis/compare/v5.8.2...v5.9.0) (2026-01-05)
### Bug Fixes
* remove unnecessary case-sensitivity when working with commands ([#2036](https://github.com/luin/ioredis/issues/2036)) ([f33a2c8](https://github.com/luin/ioredis/commit/f33a2c823c8e908eb79cb5dc7f0a68b40c51422a))
### Features
* add timeout blocking commands ([#2052](https://github.com/luin/ioredis/issues/2052)) ([6ec78be](https://github.com/luin/ioredis/commit/6ec78bee58be2b2d7be9684e9ea05e897727aa91))
* **cluster:** refactor sharded pub/sub v5 ([#2043](https://github.com/luin/ioredis/issues/2043)) ([a523f3a](https://github.com/luin/ioredis/commit/a523f3a3007ec4e4f58ff874699365c876da60d8))
## [5.8.2](https://github.com/luin/ioredis/compare/v5.8.1...v5.8.2) (2025-10-21)
### Bug Fixes
* default IP family selection to 0 ([#2028](https://github.com/luin/ioredis/issues/2028)) ([fb082d6](https://github.com/luin/ioredis/commit/fb082d6a8ece4b0921379ac449215c7ec7435023)), closes [#2026](https://github.com/luin/ioredis/issues/2026)
* move CLIENT SETINFO commands to connection handshake ([#2033](https://github.com/luin/ioredis/issues/2033)) ([fcbbbe8](https://github.com/luin/ioredis/commit/fcbbbe898fc2540f5c14ad1f5d301f89bc2e4c22))
## [5.8.1](https://github.com/luin/ioredis/compare/v5.8.0...v5.8.1) (2025-10-06)
### Bug Fixes
* **ssubscribe:** re-subscribe sharded pubsub channels individually ([#2021](https://github.com/luin/ioredis/issues/2021)) ([f161367](https://github.com/luin/ioredis/commit/f161367e4f2965b1ffe076f7e87e750772f56234))
# [5.8.0](https://github.com/luin/ioredis/compare/v5.7.0...v5.8.0) (2025-09-23)
### Bug Fixes
* **ssubscribe:** re-subscribe sharded pubsub channels individually on ready ([#2012](https://github.com/luin/ioredis/issues/2012)) ([55a410f](https://github.com/luin/ioredis/commit/55a410fb1d7201d5de90ebb7a18a1c3cbf359b12))
### Features
* add more xtrim method overloads and tests ([#2010](https://github.com/luin/ioredis/issues/2010)) ([8a3e052](https://github.com/luin/ioredis/commit/8a3e05205009325c1de417217c3f6156994b7079))
* implement proper hpexpire command signatures and tests ([#2006](https://github.com/luin/ioredis/issues/2006)) ([95e80af](https://github.com/luin/ioredis/commit/95e80afa3f104a8911610bfeebdfb6c5cfc7a4cc))
* **stream:** Add XDELEX command ([#2003](https://github.com/luin/ioredis/issues/2003)) ([7be3c8d](https://github.com/luin/ioredis/commit/7be3c8dc23403e247a32472998deff613fd8c9ad))
* support client setinfo ([#2011](https://github.com/luin/ioredis/issues/2011)) ([a5d808b](https://github.com/luin/ioredis/commit/a5d808bc0bad8beab72ca0e044632a7178db5661))
# [5.7.0](https://github.com/luin/ioredis/compare/v5.6.1...v5.7.0) (2025-07-31)
### Bug Fixes
* xread example for TypeScript ([#1872](https://github.com/luin/ioredis/issues/1872)) ([265ea59](https://github.com/luin/ioredis/commit/265ea5975a0447be12d7dd5e209256ecb42fc797))
### Features
* Implement hexpire for [#1898](https://github.com/luin/ioredis/issues/1898) ([#1918](https://github.com/luin/ioredis/issues/1918)) ([121202c](https://github.com/luin/ioredis/commit/121202ca1a461c627680d2332e60dd8b33feaff8))
## [5.6.1](https://github.com/luin/ioredis/compare/v5.6.0...v5.6.1) (2025-04-11)
### Bug Fixes
* adding debug log on cluster.slots initial connection error ([bedcfb5](https://github.com/luin/ioredis/commit/bedcfb5d4b462c3f0a804ab32152d80029e72710))
# [5.6.0](https://github.com/luin/ioredis/compare/v5.5.0...v5.6.0) (2025-03-05)
### Features
* Sharded pub/sub support via dedicated subscribers ([#1956](https://github.com/luin/ioredis/issues/1956)) ([963a395](https://github.com/luin/ioredis/commit/963a395cd52cc12c0aa2b2bd23b55248c5b97d19))
# [5.5.0](https://github.com/luin/ioredis/compare/v5.4.2...v5.5.0) (2025-02-07)
### Features
* Add ability for nat mapping through function ([#1948](https://github.com/luin/ioredis/issues/1948)) ([3a04bee](https://github.com/luin/ioredis/commit/3a04bee10995832303916fe8c7854eb6f3dcb65d))
* **HscanStream:** adding NOVALUES option ([#1943](https://github.com/luin/ioredis/issues/1943)) ([2f9843d](https://github.com/luin/ioredis/commit/2f9843ddfa8d46cbee6c858fefbf9c2cd3852503))
## [5.4.2](https://github.com/luin/ioredis/compare/v5.4.1...v5.4.2) (2024-12-20)
### Bug Fixes
* Connection instability when using socketTimeout parameter ([#1937](https://github.com/luin/ioredis/issues/1937)) ([ca5e940](https://github.com/luin/ioredis/commit/ca5e9405f80318ef35c42d23da640df4b88b6670)), closes [#1919](https://github.com/luin/ioredis/issues/1919)
## [5.4.1](https://github.com/luin/ioredis/compare/v5.4.0...v5.4.1) (2024-04-17)
### Bug Fixes
* remove console.log ([558497c](https://github.com/luin/ioredis/commit/558497cba8dc7487c06c7765ddbe12b479bd9b9b))
# [5.4.0](https://github.com/luin/ioredis/compare/v5.3.2...v5.4.0) (2024-04-16)
### Bug Fixes
* when `refreshSlotsCache` is callback concurrently, call the callback only when the refresh process is done ([#1881](https://github.com/luin/ioredis/issues/1881)) ([804ee07](https://github.com/luin/ioredis/commit/804ee071cab4326d1d69eec0e9d156aac4aa89f4))
### Features
* add support for `socketTimeout` in `Redis` ([#1882](https://github.com/luin/ioredis/issues/1882)) ([673ac77](https://github.com/luin/ioredis/commit/673ac77d9d88bd461110da7b4a8b2b98fb45f845))
## [5.3.2](https://github.com/luin/ioredis/compare/v5.3.1...v5.3.2) (2023-04-15)
### Bug Fixes
* add types for known events ([#1694](https://github.com/luin/ioredis/issues/1694)) ([1a87b23](https://github.com/luin/ioredis/commit/1a87b237e8f43f1dee44dcab8e9da6855bbf772a))
## [5.3.1](https://github.com/luin/ioredis/compare/v5.3.0...v5.3.1) (2023-02-12)
### Bug Fixes
* Fix commands not resend on reconnect in edge cases ([#1720](https://github.com/luin/ioredis/issues/1720)) ([fe52ff1](https://github.com/luin/ioredis/commit/fe52ff1c6f4cb1beb0c9e999299248ba380d5cde)), closes [#1718](https://github.com/luin/ioredis/issues/1718)
* Fix db parameter not working with auto pipelining ([#1721](https://github.com/luin/ioredis/issues/1721)) ([d9b1bf1](https://github.com/luin/ioredis/commit/d9b1bf1a2868344eaff71cc39c790e98043fff53))
# [5.3.0](https://github.com/luin/ioredis/compare/v5.2.6...v5.3.0) (2023-01-25)
### Bug Fixes
* unsubscribe not work with stringNumbers ([#1710](https://github.com/luin/ioredis/issues/1710)) ([321f8de](https://github.com/luin/ioredis/commit/321f8def3dff7f996c90af1ef73ffd789e02381e)), closes [#1643](https://github.com/luin/ioredis/issues/1643)
### Features
* Add support ssubscribe ([#1690](https://github.com/luin/ioredis/issues/1690)) ([6285e80](https://github.com/luin/ioredis/commit/6285e80ffb47564dc01d8e9940ff9a103bf70e2d))
## [5.2.6](https://github.com/luin/ioredis/compare/v5.2.5...v5.2.6) (2023-01-25)
### Bug Fixes
* remove extraneous TCP/IPC properties from RedisOptions TS type ([#1707](https://github.com/luin/ioredis/issues/1707)) ([9af7b1c](https://github.com/luin/ioredis/commit/9af7b1c0d0ab4723093d78bc05a142c9d0e3b4a8))
## [5.2.5](https://github.com/luin/ioredis/compare/v5.2.4...v5.2.5) (2023-01-14)
### Bug Fixes
* Named export to support ESM imports in Typescript ([#1695](https://github.com/luin/ioredis/issues/1695)) ([cdded57](https://github.com/luin/ioredis/commit/cdded5703ded8dff02d7df3362ae25120bb75e97))
With this change, users would be able to import Redis with `import { Redis} from 'ioredis'`. This makes it possible to import Redis in an ESM project. The original way (`import Redis from 'ioredis'`) will still be supported but will be deprecated in the next major version.
## [5.2.4](https://github.com/luin/ioredis/compare/v5.2.3...v5.2.4) (2022-11-02)
### Bug Fixes
* passing in family parameter in URL in node 18 ([#1673](https://github.com/luin/ioredis/issues/1673)) ([6f1ab9f](https://github.com/luin/ioredis/commit/6f1ab9f374bff2d62cf64ff6bfca1cf9f03d14d5))
## [5.2.3](https://github.com/luin/ioredis/compare/v5.2.2...v5.2.3) (2022-08-23)
### Bug Fixes
* type of zscore result should be nullable ([#1639](https://github.com/luin/ioredis/issues/1639)) ([a3838ae](https://github.com/luin/ioredis/commit/a3838ae7598c7d9d3aff688923403f6176d7a393))
* update to latest profile for Redis Cloud ([#1637](https://github.com/luin/ioredis/issues/1637)) ([dccb820](https://github.com/luin/ioredis/commit/dccb8205488d63653e1d157c6e87e28bfcddd3e1))
## [5.2.2](https://github.com/luin/ioredis/compare/v5.2.1...v5.2.2) (2022-07-23)
### Bug Fixes
* srandmember with count argument should return array of strings ([#1620](https://github.com/luin/ioredis/issues/1620)) ([5f813f3](https://github.com/luin/ioredis/commit/5f813f3327ca9a2ef89fae195a458787f200e34d))
## [5.2.1](https://github.com/luin/ioredis/compare/v5.2.0...v5.2.1) (2022-07-16)
### Bug Fixes
* always allow selecting a new node for cluster mode subscriptions when the current one fails ([#1589](https://github.com/luin/ioredis/issues/1589)) ([1c8cb85](https://github.com/luin/ioredis/commit/1c8cb856f31b024195be2c7fc8073bcabd3586a7))
# [5.2.0](https://github.com/luin/ioredis/compare/v5.1.0...v5.2.0) (2022-07-11)
### Features
* add mode property to client ([#1618](https://github.com/luin/ioredis/issues/1618)) ([9e6db7d](https://github.com/luin/ioredis/commit/9e6db7d7fc769ddc99d9dee4a943f141d71c0756))
# [5.1.0](https://github.com/luin/ioredis/compare/v5.0.6...v5.1.0) (2022-06-25)
### Features
* add command typings for Redis 7.0.2. Also fix a typing issue for hgetallBuffer. ([#1611](https://github.com/luin/ioredis/issues/1611)) ([fa77c07](https://github.com/luin/ioredis/commit/fa77c07bdeece59c2b98d670bbd2c069944a988f))
## [5.0.6](https://github.com/luin/ioredis/compare/v5.0.5...v5.0.6) (2022-05-31)
### Bug Fixes
* Add back Pipeline#length ([#1585](https://github.com/luin/ioredis/issues/1585)) ([63b2ee4](https://github.com/luin/ioredis/commit/63b2ee49c52c8cee326d30f62bc29c64f3ec28b3)), closes [#1584](https://github.com/luin/ioredis/issues/1584)
## [5.0.5](https://github.com/luin/ioredis/compare/v5.0.4...v5.0.5) (2022-05-17)
### Bug Fixes
* improve typing for redis.multi ([#1580](https://github.com/luin/ioredis/issues/1580)) ([f9f875b](https://github.com/luin/ioredis/commit/f9f875b1972dd2eb87ee6a5011f8f6d7abc7cf75))
* send correct command during auto-pipelining of .call() operations ([#1579](https://github.com/luin/ioredis/issues/1579)) ([e41c3dc](https://github.com/luin/ioredis/commit/e41c3dc880906e8aad73332837bf233f65d12e67))
## [5.0.4](https://github.com/luin/ioredis/compare/v5.0.3...v5.0.4) (2022-04-09)
### Bug Fixes
* Expose ChainableCommander and other types ([#1560](https://github.com/luin/ioredis/issues/1560)) ([df04dd8](https://github.com/luin/ioredis/commit/df04dd8d87a44d3b64b385c86581915248554508))
## [5.0.3](https://github.com/luin/ioredis/compare/v5.0.2...v5.0.3) (2022-03-31)
### Bug Fixes
* add named exports to keep compatible with @types/ioredis ([#1552](https://github.com/luin/ioredis/issues/1552)) ([a89a900](https://github.com/luin/ioredis/commit/a89a9002db70d44c83dfa6aaef81fb40caa5fb19))
* Fix failover detector with sentinel and tls streams ([ac00a00](https://github.com/luin/ioredis/commit/ac00a005220aa48e9be509f18594bd5e13969ce4))
* handle NOPERM error for monitor ([93b873d](https://github.com/luin/ioredis/commit/93b873dfaf75baf08e517476bfe54384d144b526)), closes [#1498](https://github.com/luin/ioredis/issues/1498)
* Hook up the keepAlive after a successful connect ([14f03a4](https://github.com/luin/ioredis/commit/14f03a4d9416b32a912f3ab9eee4c004ccad8acc)), closes [#1339](https://github.com/luin/ioredis/issues/1339)
## [5.0.2](https://github.com/luin/ioredis/compare/v5.0.1...v5.0.2) (2022-03-30)
### Bug Fixes
* allow option maxRetriesPerRequest to be null ([#1553](https://github.com/luin/ioredis/issues/1553)) ([d62a808](https://github.com/luin/ioredis/commit/d62a8082131389c38a24244ed29a5a9d8b06c4e7)), closes [#1550](https://github.com/luin/ioredis/issues/1550)
* support TypeScript interface as parameters of hmset and mset ([#1545](https://github.com/luin/ioredis/issues/1545)) ([3444791](https://github.com/luin/ioredis/commit/3444791a7ed807098ab17155e8d498a915f27750)), closes [#1536](https://github.com/luin/ioredis/issues/1536)
## [5.0.1](https://github.com/luin/ioredis/compare/v5.0.0...v5.0.1) (2022-03-26)
### Bug Fixes
* improve typing compatibility with @types/ioredis ([#1542](https://github.com/luin/ioredis/issues/1542)) ([3bf300a](https://github.com/luin/ioredis/commit/3bf300a1c99ae4cf8038930c45e19ebd68db222e))
# [5.0.0](https://github.com/luin/ioredis/compare/v4.28.5...v5.0.0) (2022-03-26)
In the update of v5, we've made ioredis even more stable and developer-friendly while minimizing the number of breaking changes, so you can spend more time enjoying your life 😄.
Please refer to the guideline to upgrade your projects: [🚀 Upgrading from v4 to v5](https://github.com/luin/ioredis/wiki/Upgrading-from-v4-to-v5).
### Bug Fixes
* add @ioredis/interface-generator to dev deps ([aa3b3e9](https://github.com/luin/ioredis/commit/aa3b3e91a369526ea2dff39b0619b0c2e0b4153b))
* add missing declaration for callBuffer ([08c9072](https://github.com/luin/ioredis/commit/08c9072b24fa301401d424494c1ec8cde7ccf78b))
* add the missing typing for Redis#call() ([747dd30](https://github.com/luin/ioredis/commit/747dd305696bf3fb661c1d0b4ac376de55e0ec25))
* better support for CJS importing ([687d3eb](https://github.com/luin/ioredis/commit/687d3eb8dd0499fd900ede2f4dff835981999665))
* disable slotsRefreshInterval by default ([370fa62](https://github.com/luin/ioredis/commit/370fa625cd20bfe62f41c38088e596c7a6f0619c))
* Fix the NOSCRIPT behavior when using pipelines ([bc1b168](https://github.com/luin/ioredis/commit/bc1b1680663216ca2cfb1c77622bfa4fec9b2bd4))
* improve typing for auto pipelining ([4e8c567](https://github.com/luin/ioredis/commit/4e8c567d1175de31e2371a9dad308a94fcb5627f))
* improve typing for pipeline ([d18f3fe](https://github.com/luin/ioredis/commit/d18f3fe07ed04da5b7b26981d91bb4aa74b83ca3))
* keyPrefix should work with Buffer ([6942cec](https://github.com/luin/ioredis/commit/6942cecd8a463756468988cf50a94c68298d3bfc)), closes [#1486](https://github.com/luin/ioredis/issues/1486)
* make fields private when possible ([d5c2f20](https://github.com/luin/ioredis/commit/d5c2f203b8f1f617f464402e400655c1f7c0fa08))
* parameter declaration of Redis#duplicate ([a29d9c4](https://github.com/luin/ioredis/commit/a29d9c46f67dc8bcc345de6543a92dd808e8a6c0))
* pipeline fails when cluster is not ready ([af60bb0](https://github.com/luin/ioredis/commit/af60bb082d20a32de1348f049507e6ea8862397f)), closes [#1460](https://github.com/luin/ioredis/issues/1460)
* remove dropBufferSupport option ([04e68ac](https://github.com/luin/ioredis/commit/04e68ac4ade14d68809ca58d7ad8536eceda2b1e))
* remove unused Command#isCustomCommand ([46ade6b](https://github.com/luin/ioredis/commit/46ade6b8732b112cc5cffb641b1bab51eb96df38))
* rename interfaces by dropping prefix I ([d1d9dba](https://github.com/luin/ioredis/commit/d1d9dba9eafc574a9d9041fd4bc7cd04f1584159))
* Reset loaded script hashes to force a reload of scripts after reconnect of redis ([60c2af9](https://github.com/luin/ioredis/commit/60c2af985a994a247d1148bfab122e5c0ecd81d2))
* support passing keyPrefix via redisOptions ([6b0dc1e](https://github.com/luin/ioredis/commit/6b0dc1e0edbaa5f46b7b03629dda20176c7a81b4))
### Features
* add [@since](https://github.com/since) to method comments ([13eff8e](https://github.com/luin/ioredis/commit/13eff8e86a0d08a3aa614f2d8fe7a166f6beb532))
* add declarations for methods ([1e10c95](https://github.com/luin/ioredis/commit/1e10c95eadede949e536f02ca1412ef4383ba654))
* add tests for cluster ([1eba58b](https://github.com/luin/ioredis/commit/1eba58ba3961e477c6502daf05cf4074f728d3cf))
* always parse username passed via URI ([c6f41f6](https://github.com/luin/ioredis/commit/c6f41f692243129dbc952ef8fd2e5c160133d677))
* drop support of Node.js 10 ([f9a5071](https://github.com/luin/ioredis/commit/f9a5071d95519c0f358c4ecf064838824ce8ad62))
* drop support of third-party Promise libraries ([2001ec6](https://github.com/luin/ioredis/commit/2001ec6fafd057eda9111ab858c1c618d939371e))
* expose official declarations ([7a436b1](https://github.com/luin/ioredis/commit/7a436b128c3e97586d2378149beaa2043eb00850))
* improve typings for cluster ([06782e6](https://github.com/luin/ioredis/commit/06782e681500eae6f3ceafcc6385b9be4fdaf4e3))
* improve typings for pipeline ([334242b](https://github.com/luin/ioredis/commit/334242b1adf5399a1ad9d7ba6202d062a0695882))
* improve typings for smismember ([487c3a0](https://github.com/luin/ioredis/commit/487c3a07e6080070d365e09dae75bbbc4267b619))
* improve typings for transformers ([94c1e24](https://github.com/luin/ioredis/commit/94c1e24f09b9e7eaff4181f984f6317acacade94))
* improve typings for xread ([96cc335](https://github.com/luin/ioredis/commit/96cc33590a8c2494b730d33780668a86cdd405cf))
* Pipeline-based script loading ([8df6ee2](https://github.com/luin/ioredis/commit/8df6ee265595f035cc85b52b4d11793bea0318f3))
* prepare v5 stable release ([#1538](https://github.com/luin/ioredis/issues/1538)) ([fe32ce7](https://github.com/luin/ioredis/commit/fe32ce71cbfb49b133834f1c4858ec0ca20ad6e8))
* Refactor code with modern settings ([a8ffa80](https://github.com/luin/ioredis/commit/a8ffa80dd2fb081012222a436d5be2b5325623b9))
* skip ready check on NOPERM error ([b530a0b](https://github.com/luin/ioredis/commit/b530a0b9fe0f987d6786e5cfccbfae8b5b9c9294)), closes [#1293](https://github.com/luin/ioredis/issues/1293)
* support commands added in Redis v7 ([53ca412](https://github.com/luin/ioredis/commit/53ca41264f94f05a9a7a231915a0e852a46079d4))
* support defining custom commands via constructor options ([f293b97](https://github.com/luin/ioredis/commit/f293b978c6023b8ce3477af0076203c7bc2482f8))
* support Redis Functions introduced in Redis 7.0 ([32eb381](https://github.com/luin/ioredis/commit/32eb381c3035ebc70e8e316697c7e0b479ec66a2))
### BREAKING CHANGES
* `slotsRefreshInterval` is disabled by default,
previously, the default value was 5000.
* `allowUsernameInURI` is removed and ioredis will always
use the username passed via URI.
Previously, the `username` part in `new Redis("redis://username:authpassword@127.0.0.1:6380/4")`
was ignored unless `allowUsernameInURI` is specified: `new Redis("redis://username:authpassword@127.0.0.1:6380/4?allowUsernameInURI=true")`.
Now, if you don't want to send username to Redis, just leave the username part empty:
`new Redis("redis://:authpassword@127.0.0.1:6380/4")`
* `Redis#serverInfo` is removed. This field is never documented so
you very likely have never used it.
* Support for third-party Promise libraries is dropped. Related methods (`exports.Promise = require('bluebird')`) are kept but they don't take any effects. The native Promise will always be used.
* We now require Node.js v12 or newer.
* `Redis` can't be called as a function anymore as it's now a class.
Please change `Redis()` to `new Redis()`. Note that `Redis()` was already deprecated
in the previous version.
# [5.0.0-beta.4](https://github.com/luin/ioredis/compare/v5.0.0-beta.3...v5.0.0-beta.4) (2022-03-19)
### Bug Fixes
* add missing declaration for callBuffer ([08c9072](https://github.com/luin/ioredis/commit/08c9072b24fa301401d424494c1ec8cde7ccf78b))
* keyPrefix should work with Buffer ([6942cec](https://github.com/luin/ioredis/commit/6942cecd8a463756468988cf50a94c68298d3bfc)), closes [#1486](https://github.com/luin/ioredis/issues/1486)
# [5.0.0-beta.3](https://github.com/luin/ioredis/compare/v5.0.0-beta.2...v5.0.0-beta.3) (2022-03-19)
### Bug Fixes
* pipeline fails when cluster is not ready ([af60bb0](https://github.com/luin/ioredis/commit/af60bb082d20a32de1348f049507e6ea8862397f)), closes [#1460](https://github.com/luin/ioredis/issues/1460)
# [5.0.0-beta.2](https://github.com/luin/ioredis/compare/v5.0.0-beta.1...v5.0.0-beta.2) (2022-03-16)
### Features
* improve typings for smismember ([487c3a0](https://github.com/luin/ioredis/commit/487c3a07e6080070d365e09dae75bbbc4267b619))
* improve typings for xread ([96cc335](https://github.com/luin/ioredis/commit/96cc33590a8c2494b730d33780668a86cdd405cf))
# [5.0.0-beta.1](https://github.com/luin/ioredis/compare/v4.28.5...v5.0.0-beta.1) (2022-03-14)
### Bug Fixes
* add @ioredis/interface-generator to dev deps ([aa3b3e9](https://github.com/luin/ioredis/commit/aa3b3e91a369526ea2dff39b0619b0c2e0b4153b))
* add the missing typing for Redis#call() ([747dd30](https://github.com/luin/ioredis/commit/747dd305696bf3fb661c1d0b4ac376de55e0ec25))
* better support for CJS importing ([687d3eb](https://github.com/luin/ioredis/commit/687d3eb8dd0499fd900ede2f4dff835981999665))
* disable slotsRefreshInterval by default ([370fa62](https://github.com/luin/ioredis/commit/370fa625cd20bfe62f41c38088e596c7a6f0619c))
* Fix the NOSCRIPT behavior when using pipelines ([bc1b168](https://github.com/luin/ioredis/commit/bc1b1680663216ca2cfb1c77622bfa4fec9b2bd4))
* improve typing for auto pipelining ([4e8c567](https://github.com/luin/ioredis/commit/4e8c567d1175de31e2371a9dad308a94fcb5627f))
* improve typing for pipeline ([d18f3fe](https://github.com/luin/ioredis/commit/d18f3fe07ed04da5b7b26981d91bb4aa74b83ca3))
* make fields private when possible ([d5c2f20](https://github.com/luin/ioredis/commit/d5c2f203b8f1f617f464402e400655c1f7c0fa08))
* parameter declaration of Redis#duplicate ([a29d9c4](https://github.com/luin/ioredis/commit/a29d9c46f67dc8bcc345de6543a92dd808e8a6c0))
* remove dropBufferSupport option ([04e68ac](https://github.com/luin/ioredis/commit/04e68ac4ade14d68809ca58d7ad8536eceda2b1e))
* remove unused Command#isCustomCommand ([46ade6b](https://github.com/luin/ioredis/commit/46ade6b8732b112cc5cffb641b1bab51eb96df38))
* rename interfaces by dropping prefix I ([d1d9dba](https://github.com/luin/ioredis/commit/d1d9dba9eafc574a9d9041fd4bc7cd04f1584159))
* Reset loaded script hashes to force a reload of scripts after reconnect of redis ([60c2af9](https://github.com/luin/ioredis/commit/60c2af985a994a247d1148bfab122e5c0ecd81d2))
* support passing keyPrefix via redisOptions ([6b0dc1e](https://github.com/luin/ioredis/commit/6b0dc1e0edbaa5f46b7b03629dda20176c7a81b4))
### Features
* add [@since](https://github.com/since) to method comments ([13eff8e](https://github.com/luin/ioredis/commit/13eff8e86a0d08a3aa614f2d8fe7a166f6beb532))
* add declarations for methods ([1e10c95](https://github.com/luin/ioredis/commit/1e10c95eadede949e536f02ca1412ef4383ba654))
* add tests for cluster ([1eba58b](https://github.com/luin/ioredis/commit/1eba58ba3961e477c6502daf05cf4074f728d3cf))
* always parse username passed via URI ([c6f41f6](https://github.com/luin/ioredis/commit/c6f41f692243129dbc952ef8fd2e5c160133d677))
* drop support of Node.js 10 ([f9a5071](https://github.com/luin/ioredis/commit/f9a5071d95519c0f358c4ecf064838824ce8ad62))
* drop support of third-party Promise libraries ([2001ec6](https://github.com/luin/ioredis/commit/2001ec6fafd057eda9111ab858c1c618d939371e))
* expose official declarations ([7a436b1](https://github.com/luin/ioredis/commit/7a436b128c3e97586d2378149beaa2043eb00850))
* improve typings for cluster ([06782e6](https://github.com/luin/ioredis/commit/06782e681500eae6f3ceafcc6385b9be4fdaf4e3))
* improve typings for pipeline ([334242b](https://github.com/luin/ioredis/commit/334242b1adf5399a1ad9d7ba6202d062a0695882))
* improve typings for transformers ([94c1e24](https://github.com/luin/ioredis/commit/94c1e24f09b9e7eaff4181f984f6317acacade94))
* Pipeline-based script loading ([8df6ee2](https://github.com/luin/ioredis/commit/8df6ee265595f035cc85b52b4d11793bea0318f3))
* Refactor code with modern settings ([a8ffa80](https://github.com/luin/ioredis/commit/a8ffa80dd2fb081012222a436d5be2b5325623b9))
* skip ready check on NOPERM error ([b530a0b](https://github.com/luin/ioredis/commit/b530a0b9fe0f987d6786e5cfccbfae8b5b9c9294)), closes [#1293](https://github.com/luin/ioredis/issues/1293)
* support commands added in Redis v7 ([53ca412](https://github.com/luin/ioredis/commit/53ca41264f94f05a9a7a231915a0e852a46079d4))
* support defining custom commands via constructor options ([f293b97](https://github.com/luin/ioredis/commit/f293b978c6023b8ce3477af0076203c7bc2482f8))
* support Redis Functions introduced in Redis 7.0 ([32eb381](https://github.com/luin/ioredis/commit/32eb381c3035ebc70e8e316697c7e0b479ec66a2))
### BREAKING CHANGES
* `slotsRefreshInterval` is disabled by default,
previously, the default value was 5000.
* `allowUsernameInURI` is removed and ioredis will always
use the username passed via URI.
Previously, the `username` part in `new Redis("redis://username:authpassword@127.0.0.1:6380/4")`
was ignored unless `allowUsernameInURI` is specified: `new Redis("redis://username:authpassword@127.0.0.1:6380/4?allowUsernameInURI=true")`.
Now, if you don't want to send username to Redis, just leave the username part empty:
`new Redis("redis://:authpassword@127.0.0.1:6380/4")`
* `Redis#serverInfo` is removed. This field is never documented so
you very likely have never used it.
* Support for third-party Promise libraries is dropped. Related methods (`exports.Promise = require('bluebird')`) are kept but they don't take any effects. The native Promise will always be used.
* We now require Node.js v12 or newer.
* `Redis` can't be called as a function anymore as it's now a class.
Please change `Redis()` to `new Redis()`. Note that `Redis()` was already deprecated
in the previous version.
## [4.28.5](https://github.com/luin/ioredis/compare/v4.28.4...v4.28.5) (2022-02-06)
### Bug Fixes
* Reset loaded script hashes to force a reload of scripts after reconnect of redis ([#1497](https://github.com/luin/ioredis/issues/1497)) ([f357a31](https://github.com/luin/ioredis/commit/f357a3145694250bf361827403252b31435afabd))
## [4.28.4](https://github.com/luin/ioredis/compare/v4.28.3...v4.28.4) (2022-02-02)
### Bug Fixes
* make sure timers is cleared on exit ([#1502](https://github.com/luin/ioredis/issues/1502)) ([cfb04a0](https://github.com/luin/ioredis/commit/cfb04a062b380bad5655b6f97b4259f328f1ee4a))
## [4.28.3](https://github.com/luin/ioredis/compare/v4.28.2...v4.28.3) (2022-01-11)
### Bug Fixes
* fix exceptions on messages of client side cache ([#1479](https://github.com/luin/ioredis/issues/1479)) ([02adca4](https://github.com/luin/ioredis/commit/02adca4bc1cc50a232703d2b48ea41a18fa82c93))
## [4.28.2](https://github.com/luin/ioredis/compare/v4.28.1...v4.28.2) (2021-12-01)
### Bug Fixes
* add Redis campaign ([#1475](https://github.com/luin/ioredis/issues/1475)) ([3f3d8e9](https://github.com/luin/ioredis/commit/3f3d8e9eb868f4e58bb63926d3b683d9892835f2))
* fix a memory leak with autopipelining. ([#1470](https://github.com/luin/ioredis/issues/1470)) ([f5d8b73](https://github.com/luin/ioredis/commit/f5d8b73c747a0db5cb36e83e6fe022a19a544bd2))
* unhandled Promise rejections in pipeline.exec [skip ci] ([#1466](https://github.com/luin/ioredis/issues/1466)) ([e5615da](https://github.com/luin/ioredis/commit/e5615da8786956df08a9b33b6cd4dd31e6eaa759))
## [4.28.1](https://github.com/luin/ioredis/compare/v4.28.0...v4.28.1) (2021-11-23)
### Bug Fixes
* handle possible unhandled promise rejection with autopipelining+cluster ([#1467](https://github.com/luin/ioredis/issues/1467)) ([6ad285a](https://github.com/luin/ioredis/commit/6ad285a59f4a46d5452a799371dfbd69a07ac9f9)), closes [#1466](https://github.com/luin/ioredis/issues/1466)
# [4.28.0](https://github.com/luin/ioredis/compare/v4.27.11...v4.28.0) (2021-10-13)
### Features
* **tls:** add TLS profiles for easier configuration ([#1441](https://github.com/luin/ioredis/issues/1441)) ([4680211](https://github.com/luin/ioredis/commit/4680211fe853831f9ff3a3eb69f16d5db6bfbabd))
## [4.27.11](https://github.com/luin/ioredis/compare/v4.27.10...v4.27.11) (2021-10-11)
### Bug Fixes
* make export interface compatible with jest ([#1445](https://github.com/luin/ioredis/issues/1445)) ([2728dbe](https://github.com/luin/ioredis/commit/2728dbe5289ebc8603484bc85c01632cfab98204))
## [4.27.10](https://github.com/luin/ioredis/compare/v4.27.9...v4.27.10) (2021-10-04)
### Bug Fixes
* **cluster:** lazyConnect with pipeline ([#1408](https://github.com/luin/ioredis/issues/1408)) ([b798107](https://github.com/luin/ioredis/commit/b798107e4123d0027ef1bdb3319cd00516221f3b))
## [4.27.9](https://github.com/luin/ioredis/compare/v4.27.8...v4.27.9) (2021-08-30)
### Bug Fixes
* Fix undefined property warning in executeAutoPipeline ([#1425](https://github.com/luin/ioredis/issues/1425)) ([f898672](https://github.com/luin/ioredis/commit/f898672a29753774eeb6e166c28ed6f548533517))
* improve proto checking for hgetall [skip ci] ([#1418](https://github.com/luin/ioredis/issues/1418)) ([cba83cb](https://github.com/luin/ioredis/commit/cba83cba2dba25e59ad87c85d740f15f78e45e14))
## [4.27.8](https://github.com/luin/ioredis/compare/v4.27.7...v4.27.8) (2021-08-18)
### Bug Fixes
* handle malicious keys for hgetall ([#1416](https://github.com/luin/ioredis/issues/1416)) ([7d73b9d](https://github.com/luin/ioredis/commit/7d73b9d07b52ec077f235292aa15c7aca203bba9)), closes [#1267](https://github.com/luin/ioredis/issues/1267)
## [4.27.7](https://github.com/luin/ioredis/compare/v4.27.6...v4.27.7) (2021-08-01)
### Bug Fixes
* **cluster:** fix autopipeline with keyPrefix or arg array ([#1391](https://github.com/luin/ioredis/issues/1391)) ([d7477aa](https://github.com/luin/ioredis/commit/d7477aa5853388b51037210542372131919ddfb2)), closes [#1264](https://github.com/luin/ioredis/issues/1264) [#1248](https://github.com/luin/ioredis/issues/1248) [#1392](https://github.com/luin/ioredis/issues/1392)
## [4.27.6](https://github.com/luin/ioredis/compare/v4.27.5...v4.27.6) (2021-06-13)
### Bug Fixes
* fixed autopipeline performances. ([#1226](https://github.com/luin/ioredis/issues/1226)) ([42f1ee1](https://github.com/luin/ioredis/commit/42f1ee107174366a79ff94bec8a7a1ac353e035c))
## [4.27.5](https://github.com/luin/ioredis/compare/v4.27.4...v4.27.5) (2021-06-05)
### Bug Fixes
* **SENTINEL:** actively failover detection under an option ([#1363](https://github.com/luin/ioredis/issues/1363)) ([f02e383](https://github.com/luin/ioredis/commit/f02e383996310adaefc2b4c40d946b76e450e5c7))
## [4.27.4](https://github.com/luin/ioredis/compare/v4.27.3...v4.27.4) (2021-06-04)
### Performance Improvements
* Serialize error stack only when needed ([#1359](https://github.com/luin/ioredis/issues/1359)) ([62b6a64](https://github.com/luin/ioredis/commit/62b6a648910eccc3d83a3acd2db873704fd2080a))
## [4.27.3](https://github.com/luin/ioredis/compare/v4.27.2...v4.27.3) (2021-05-22)
### Bug Fixes
* autopipeling for buffer function ([#1231](https://github.com/luin/ioredis/issues/1231)) ([abd9a82](https://github.com/luin/ioredis/commit/abd9a82433ad67b91a4bddb45aff8da2e20d45e8))
## [4.27.2](https://github.com/luin/ioredis/compare/v4.27.1...v4.27.2) (2021-05-04)
### Bug Fixes
* **cluster:** avoid ClusterAllFailedError in certain cases ([aa9c5b1](https://github.com/luin/ioredis/commit/aa9c5b1fee5daa24f35b3ff0d3556ecfb86db251)), closes [#1330](https://github.com/luin/ioredis/issues/1330)
## [4.27.1](https://github.com/luin/ioredis/compare/v4.27.0...v4.27.1) (2021-04-24)
### Bug Fixes
* clears commandTimeout timer as each respective command gets fulfilled ([#1336](https://github.com/luin/ioredis/issues/1336)) ([d65f8b2](https://github.com/luin/ioredis/commit/d65f8b2e6603a4de32f5d97e69a99be78e50708b))
# [4.27.0](https://github.com/luin/ioredis/compare/v4.26.0...v4.27.0) (2021-04-24)
### Features
* **sentinel:** detect failover from +switch-master messages ([#1328](https://github.com/luin/ioredis/issues/1328)) ([a464151](https://github.com/luin/ioredis/commit/a46415187d32bfdc974072403edb8aca2df282d6))
# [4.26.0](https://github.com/luin/ioredis/compare/v4.25.0...v4.26.0) (2021-04-08)
### Bug Fixes
* **cluster:** subscriber connection leaks ([81b9be0](https://github.com/luin/ioredis/commit/81b9be021d471796bba00ee7b08768df9d7e2689)), closes [#1325](https://github.com/luin/ioredis/issues/1325)
### Features
* **cluster:** apply provided connection name to internal connections ([2e388db](https://github.com/luin/ioredis/commit/2e388dbaa528d009b97b82c4dc362377165670a4))
# [4.25.0](https://github.com/luin/ioredis/compare/v4.24.6...v4.25.0) (2021-04-02)
### Features
* added commandTimeout option ([#1320](https://github.com/luin/ioredis/issues/1320)) ([56f0272](https://github.com/luin/ioredis/commit/56f02729958545e5b7e713436181b0dd46f8803a))
## [4.24.6](https://github.com/luin/ioredis/compare/v4.24.5...v4.24.6) (2021-03-31)
### Bug Fixes
* force disconnect after a timeout if socket is still half-open ([#1318](https://github.com/luin/ioredis/issues/1318)) ([6cacd17](https://github.com/luin/ioredis/commit/6cacd17e6ac4d9f995728ee09777e0a7f3b739d7))
## [4.24.5](https://github.com/luin/ioredis/compare/v4.24.4...v4.24.5) (2021-03-27)
### Bug Fixes
* select db in cluster mode causes unhandled errors ([#1311](https://github.com/luin/ioredis/issues/1311)) ([da3ec92](https://github.com/luin/ioredis/commit/da3ec92a406ab6c2f1517810f29f55a0c12712dc)), closes [#1310](https://github.com/luin/ioredis/issues/1310)
## [4.24.4](https://github.com/luin/ioredis/compare/v4.24.3...v4.24.4) (2021-03-24)
### Bug Fixes
* minor compatibility issues caused by TypeScript upgrade ([#1309](https://github.com/luin/ioredis/issues/1309)) ([c96139a](https://github.com/luin/ioredis/commit/c96139a531d2652eed5631a85ac4dc6a57f1048d)), closes [#1308](https://github.com/luin/ioredis/issues/1308)
## [4.24.3](https://github.com/luin/ioredis/compare/v4.24.2...v4.24.3) (2021-03-21)
### Bug Fixes
* support parallel script execution in pipelines ([#1304](https://github.com/luin/ioredis/issues/1304)) ([c917719](https://github.com/luin/ioredis/commit/c91771997e5e3a0196d380522b4750de9e84cc9b))
## [4.24.2](https://github.com/luin/ioredis/compare/v4.24.1...v4.24.2) (2021-03-14)
### Bug Fixes
* properly handle instant stream errors ([#1299](https://github.com/luin/ioredis/issues/1299)) ([0327ef5](https://github.com/luin/ioredis/commit/0327ef5a57481042d3f7d306917f55ef04f3a6cc))
## [4.24.1](https://github.com/luin/ioredis/compare/v4.24.0...v4.24.1) (2021-03-14)
### Bug Fixes
* **cluster:** reconnect when failing to refresh slots cache for all nodes ([8524eea](https://github.com/luin/ioredis/commit/8524eeaedaa2542f119f2b65ab8e2f15644b474e))
# [4.24.0](https://github.com/luin/ioredis/compare/v4.23.1...v4.24.0) (2021-03-14)
### Features
* **cluster:** support retrying MOVED with a delay ([#1254](https://github.com/luin/ioredis/issues/1254)) ([8599981](https://github.com/luin/ioredis/commit/8599981141e8357f5ae2706fffb55010490bf002))
## [4.23.1](https://github.com/luin/ioredis/compare/v4.23.0...v4.23.1) (2021-03-14)
### Bug Fixes
* **cluster:** issues when code is processed by babel ([#1298](https://github.com/luin/ioredis/issues/1298)) ([bfc194d](https://github.com/luin/ioredis/commit/bfc194dcad2af527e802d6f5b060f0b0779e840d)), closes [#1288](https://github.com/luin/ioredis/issues/1288)
# [4.23.0](https://github.com/luin/ioredis/compare/v4.22.0...v4.23.0) (2021-02-25)
### Features
* add support for DNS SRV records ([#1283](https://github.com/luin/ioredis/issues/1283)) ([13a8614](https://github.com/luin/ioredis/commit/13a861432c2331ca25038f6b4eb060ba7b865b47))
# [4.22.0](https://github.com/luin/ioredis/compare/v4.21.0...v4.22.0) (2021-02-06)
### Features
* add type support for scanStream ([#1287](https://github.com/luin/ioredis/issues/1287)) ([ad8ffa0](https://github.com/luin/ioredis/commit/ad8ffa06d68788de3c0703a70fe4c5b64ab4ac5b)), closes [#1279](https://github.com/luin/ioredis/issues/1279)
# [4.21.0](https://github.com/luin/ioredis/compare/v4.20.0...v4.21.0) (2021-02-06)
### Features
* upgrade command list to Redis 6.2 ([#1286](https://github.com/luin/ioredis/issues/1286)) ([6ef9c6e](https://github.com/luin/ioredis/commit/6ef9c6e839dee8be021bcd43a57eaee56ec2f573))
# [4.20.0](https://github.com/luin/ioredis/compare/v4.19.5...v4.20.0) (2021-02-05)
### Features
* support username in URI ([#1284](https://github.com/luin/ioredis/issues/1284)) ([cbc5421](https://github.com/luin/ioredis/commit/cbc54218e26bd20ac3725df2e70b810599112ef8))
## [4.19.5](https://github.com/luin/ioredis/compare/v4.19.4...v4.19.5) (2021-01-14)
### Bug Fixes
* password contains colons ([#1274](https://github.com/luin/ioredis/issues/1274)) ([37c6daf](https://github.com/luin/ioredis/commit/37c6dafafd51d817a3dfe4b4ca722fb709a209e7))
## [4.19.4](https://github.com/luin/ioredis/compare/v4.19.3...v4.19.4) (2020-12-13)
### Bug Fixes
* prevent duplicate intervals being set. ([#1244](https://github.com/luin/ioredis/issues/1244)) ([515d9ea](https://github.com/luin/ioredis/commit/515d9eaee8e2be0f31dc3fbf2264718bee2343f5)), closes [#1232](https://github.com/luin/ioredis/issues/1232) [#1226](https://github.com/luin/ioredis/issues/1226) [#1232](https://github.com/luin/ioredis/issues/1232) [/github.com/luin/ioredis/blob/v4.19.2/lib/cluster/index.ts#L311-L313](https://github.com//github.com/luin/ioredis/blob/v4.19.2/lib/cluster/index.ts/issues/L311-L313)
## [4.19.3](https://github.com/luin/ioredis/compare/v4.19.2...v4.19.3) (2020-12-13)
### Bug Fixes
* auth command should be not allowed in auto pipeline. ([#1242](https://github.com/luin/ioredis/issues/1242)) ([bafdd4b](https://github.com/luin/ioredis/commit/bafdd4b928f40d8ede5d890b3f7fab0b7139f50b))
## [4.19.2](https://github.com/luin/ioredis/compare/v4.19.1...v4.19.2) (2020-10-31)
### Bug Fixes
* Fix autopipeline and downgrade p-map to support Node 6. [[#1216](https://github.com/luin/ioredis/issues/1216)] ([1bc8ca0](https://github.com/luin/ioredis/commit/1bc8ca0d05ab830a04502acd1cfc2796aca256ec))
## [4.19.1](https://github.com/luin/ioredis/compare/v4.19.0...v4.19.1) (2020-10-28)
### Bug Fixes
* Make sure script caches interval is cleared. [[#1215](https://github.com/luin/ioredis/issues/1215)] ([d94f97d](https://github.com/luin/ioredis/commit/d94f97d6950035818a666c08447a9d5e0ef5f8c7))
# [4.19.0](https://github.com/luin/ioredis/compare/v4.18.0...v4.19.0) (2020-10-23)
### Bug Fixes
* Ensure delayed callbacks are always invoked. ([d6e78c3](https://github.com/luin/ioredis/commit/d6e78c306c8150c58277d60e51edac55a55523c2))
### Features
* Add autopipeline for commands and allow multi slot pipelines. ([aba3c74](https://github.com/luin/ioredis/commit/aba3c743c230ea6d10e6f3779214f34ebd9ae7ae)), closes [#536](https://github.com/luin/ioredis/issues/536)
# [4.18.0](https://github.com/luin/ioredis/compare/v4.17.3...v4.18.0) (2020-07-25)
### Features
* supports commands in Redis 6.0.6 ([c016265](https://github.com/luin/ioredis/commit/c016265028d746ab71ab2ad65e49a3fbe8c0f49c))
## [4.17.3](https://github.com/luin/ioredis/compare/v4.17.2...v4.17.3) (2020-05-30)
### Bug Fixes
* race conditions in `Redis#disconnect()` can cancel reconnection unexpectedly ([6fad73b](https://github.com/luin/ioredis/commit/6fad73b672014c07bd0db7a8e51c0be341908868)), closes [#1138](https://github.com/luin/ioredis/issues/1138) [#1007](https://github.com/luin/ioredis/issues/1007)
## [4.17.2](https://github.com/luin/ioredis/compare/v4.17.1...v4.17.2) (2020-05-30)
### Bug Fixes
* _readyCheck INFO parser's handling of colon characters ([#1127](https://github.com/luin/ioredis/issues/1127)) ([38a09e1](https://github.com/luin/ioredis/commit/38a09e1a06a54b811d839ecc5ff7669663eba619))
## [4.17.1](https://github.com/luin/ioredis/compare/v4.17.0...v4.17.1) (2020-05-16)
### Bug Fixes
* revert parsing username via URI due to potential breaking changes ([#1134](https://github.com/luin/ioredis/issues/1134)) ([225ef45](https://github.com/luin/ioredis/commit/225ef450e320678c0c553c37e2f49b7727d5c573))
# [4.17.0](https://github.com/luin/ioredis/compare/v4.16.3...v4.17.0) (2020-05-16)
### Features
* add auth support for Redis 6 ([#1130](https://github.com/luin/ioredis/issues/1130)) ([ad5b455](https://github.com/luin/ioredis/commit/ad5b45587b2e378c15fa879cc72580c391c3c18d))
## [4.16.3](https://github.com/luin/ioredis/compare/v4.16.2...v4.16.3) (2020-04-21)
### Bug Fixes
* scripts may not be loaded correctly in pipeline ([#1107](https://github.com/luin/ioredis/issues/1107)) ([072d460](https://github.com/luin/ioredis/commit/072d4604113e5562171d689b37c3cf73dcee18ad))
## [4.16.2](https://github.com/luin/ioredis/compare/v4.16.1...v4.16.2) (2020-04-11)
### Bug Fixes
* dismiss security alerts for dev dependencies [skip release] ([758b3f2](https://github.com/luin/ioredis/commit/758b3f29036c7830e963ac3d34d3ce9cc7c4cb52))
* handle connection after connect event was emitted ([#1095](https://github.com/luin/ioredis/issues/1095)) ([16a0610](https://github.com/luin/ioredis/commit/16a06102fa4fa537be926b7e68601c777f0c64b5)), closes [#977](https://github.com/luin/ioredis/issues/977)
## [4.16.1](https://github.com/luin/ioredis/compare/v4.16.0...v4.16.1) (2020-03-28)
### Bug Fixes
* abort incomplete pipelines upon reconnect ([#1084](https://github.com/luin/ioredis/issues/1084)) ([0013991](https://github.com/luin/ioredis/commit/0013991b7fbf239ffd74311266bb9e63e22b46cb)), closes [#965](https://github.com/luin/ioredis/issues/965)
# [4.16.0](https://github.com/luin/ioredis/compare/v4.15.1...v4.16.0) (2020-02-19)
### Features
* ability force custom scripts to be readOnly and execute on slaves ([#1057](https://github.com/luin/ioredis/issues/1057)) ([a24c3ab](https://github.com/luin/ioredis/commit/a24c3abcf4013e74e25424d2f6b91a2ae0de12b5))
## [4.15.1](https://github.com/luin/ioredis/compare/v4.15.0...v4.15.1) (2019-12-25)
### Bug Fixes
* ignore empty hosts returned by CLUSTER SLOTS ([#1025](https://github.com/luin/ioredis/issues/1025)) ([d79a8ef](https://github.com/luin/ioredis/commit/d79a8ef40f5670af6962b598752dc5a7aa96722c))
* prevent exception when send custom command ([04cad7f](https://github.com/luin/ioredis/commit/04cad7fbf2db5e14a478e2eb1dc825346abe41dd))
# [4.15.0](https://github.com/luin/ioredis/compare/v4.14.4...v4.15.0) (2019-11-29)
### Features
* support multiple fields for hset ([51b1478](https://github.com/luin/ioredis/commit/51b14786eef4c627c178de4967434e8d4a51ebe0))
## [4.14.4](https://github.com/luin/ioredis/compare/v4.14.3...v4.14.4) (2019-11-22)
### Bug Fixes
* improved performance of Pipeline.exec ([#991](https://github.com/luin/ioredis/issues/991)) ([86470a8](https://github.com/luin/ioredis/commit/86470a8912bff3907ab80e1b404dfcfa4fc7f24a))
## [4.14.3](https://github.com/luin/ioredis/compare/v4.14.2...v4.14.3) (2019-11-07)
### Bug Fixes
* update funding information ([c83cb05](https://github.com/luin/ioredis/commit/c83cb0524258e8090d0ae487c5d13cc873af2e27))
## [4.14.2](https://github.com/luin/ioredis/compare/v4.14.1...v4.14.2) (2019-10-23)
### Bug Fixes
* security deps updates [skip ci] ([a7095d7](https://github.com/luin/ioredis/commit/a7095d7ab66d9791c3c9a73ea3673c54dce5959d))
## [4.14.1](https://github.com/luin/ioredis/compare/v4.14.0...v4.14.1) (2019-08-27)
### Bug Fixes
* don’t clobber passed-in tls options with rediss:/ URLs ([#949](https://github.com/luin/ioredis/issues/949)) ([ceefcfa](https://github.com/luin/ioredis/commit/ceefcfa)), closes [#942](https://github.com/luin/ioredis/issues/942) [#940](https://github.com/luin/ioredis/issues/940) [#950](https://github.com/luin/ioredis/issues/950) [#948](https://github.com/luin/ioredis/issues/948)
# [4.14.0](https://github.com/luin/ioredis/compare/v4.13.1...v4.14.0) (2019-07-31)
### Features
* support rediss:// URL ([371bb9c](https://github.com/luin/ioredis/commit/371bb9c))
## [4.13.1](https://github.com/luin/ioredis/compare/v4.13.0...v4.13.1) (2019-07-22)
### Bug Fixes
* keep sentinels of options immutable ([bacb7e1](https://github.com/luin/ioredis/commit/bacb7e1)), closes [#936](https://github.com/luin/ioredis/issues/936)
# [4.13.0](https://github.com/luin/ioredis/compare/v4.12.2...v4.13.0) (2019-07-19)
### Bug Fixes
* **cluster:** suppress errors emitted from internal clients ([9a113ca](https://github.com/luin/ioredis/commit/9a113ca)), closes [#896](https://github.com/luin/ioredis/issues/896) [#899](https://github.com/luin/ioredis/issues/899)
### Features
* **cluster:** support binary keys ([b414ed9](https://github.com/luin/ioredis/commit/b414ed9)), closes [#637](https://github.com/luin/ioredis/issues/637)
## [4.12.2](https://github.com/luin/ioredis/compare/v4.12.1...v4.12.2) (2019-07-16)
### Bug Fixes
* **cluster:** prefer master when there're two same node for a slot ([8fb9f97](https://github.com/luin/ioredis/commit/8fb9f97))
* **cluster:** remove node immediately when slots are redistributed ([ecc13ad](https://github.com/luin/ioredis/commit/ecc13ad)), closes [#930](https://github.com/luin/ioredis/issues/930)
## [4.12.1](https://github.com/luin/ioredis/compare/v4.12.0...v4.12.1) (2019-07-15)
### Bug Fixes
* handle connecting immediately after "end" event ([#929](https://github.com/luin/ioredis/issues/929)) ([7bcd8a8](https://github.com/luin/ioredis/commit/7bcd8a8)), closes [#928](https://github.com/luin/ioredis/issues/928)
# [4.12.0](https://github.com/luin/ioredis/compare/v4.11.2...v4.12.0) (2019-07-14)
### Features
* **cluster:** add #duplicate() method ([#926](https://github.com/luin/ioredis/issues/926)) ([8b150c2](https://github.com/luin/ioredis/commit/8b150c2))
## [4.11.2](https://github.com/luin/ioredis/compare/v4.11.1...v4.11.2) (2019-07-13)
### Bug Fixes
* ETIMEDOUT error with Bluebird when connecting. ([#925](https://github.com/luin/ioredis/issues/925)) ([4bce38b](https://github.com/luin/ioredis/commit/4bce38b)), closes [#918](https://github.com/luin/ioredis/issues/918)
## [4.11.1](https://github.com/luin/ioredis/compare/v4.11.0...v4.11.1) (2019-06-26)
### Bug Fixes
* use connector as class not value ([#909](https://github.com/luin/ioredis/issues/909)) ([3fb2552](https://github.com/luin/ioredis/commit/3fb2552))
# [4.11.0](https://github.com/luin/ioredis/compare/v4.10.4...v4.11.0) (2019-06-25)
### Features
* support custom connectors ([#906](https://github.com/luin/ioredis/issues/906)) ([bf3fe29](https://github.com/luin/ioredis/commit/bf3fe29))
## [4.10.4](https://github.com/luin/ioredis/compare/v4.10.3...v4.10.4) (2019-06-11)
### Bug Fixes
* **cluster:** passing frozen natMap option causes crash ([3bc6165](https://github.com/luin/ioredis/commit/3bc6165)), closes [#887](https://github.com/luin/ioredis/issues/887)
## [4.10.3](https://github.com/luin/ioredis/compare/v4.10.2...v4.10.3) (2019-06-08)
### Bug Fixes
* **cluster:** reorder defaults arguments to prioritize user options ([#889](https://github.com/luin/ioredis/issues/889)) ([8da8d78](https://github.com/luin/ioredis/commit/8da8d78))
## [4.10.2](https://github.com/luin/ioredis/compare/v4.10.1...v4.10.2) (2019-06-08)
### Bug Fixes
* pipeline with transactions causes unhandled warnings ([#884](https://github.com/luin/ioredis/issues/884)) ([bbfd2fc](https://github.com/luin/ioredis/commit/bbfd2fc)), closes [#883](https://github.com/luin/ioredis/issues/883)
## [4.10.1](https://github.com/luin/ioredis/compare/v4.10.0...v4.10.1) (2019-06-08)
### Bug Fixes
* upgrade deps to resolve security vulnerabilities warnings ([#885](https://github.com/luin/ioredis/issues/885)) ([98c27cf](https://github.com/luin/ioredis/commit/98c27cf))
# [4.10.0](https://github.com/luin/ioredis/compare/v4.9.5...v4.10.0) (2019-05-23)
### Features
* upgrade to redis-commands@1.5.0 for streams support ([644f5cb](https://github.com/luin/ioredis/commit/644f5cb)), closes [#875](https://github.com/luin/ioredis/issues/875)
## [4.9.5](https://github.com/luin/ioredis/compare/v4.9.4...v4.9.5) (2019-05-15)
### Bug Fixes
* **cluster:** make blocking commands works with cluster ([#867](https://github.com/luin/ioredis/issues/867)) ([68db71b](https://github.com/luin/ioredis/commit/68db71b)), closes [#850](https://github.com/luin/ioredis/issues/850) [#850](https://github.com/luin/ioredis/issues/850)
## [4.9.4](https://github.com/luin/ioredis/compare/v4.9.3...v4.9.4) (2019-05-13)
### Bug Fixes
* handle non-utf8 command name ([#866](https://github.com/luin/ioredis/issues/866)) ([9ddb58b](https://github.com/luin/ioredis/commit/9ddb58b)), closes [#862](https://github.com/luin/ioredis/issues/862)
## [4.9.3](https://github.com/luin/ioredis/compare/v4.9.2...v4.9.3) (2019-05-07)
### Bug Fixes
* more meaningful errors when using pipeline after exec(). ([#858](https://github.com/luin/ioredis/issues/858)) ([0c3ef01](https://github.com/luin/ioredis/commit/0c3ef01))
## [4.9.2](https://github.com/luin/ioredis/compare/v4.9.1...v4.9.2) (2019-05-03)
### Bug Fixes
* removed flexbuffer dependency ([#856](https://github.com/luin/ioredis/issues/856)) ([35e0c5e](https://github.com/luin/ioredis/commit/35e0c5e))
## [4.9.1](https://github.com/luin/ioredis/compare/v4.9.0...v4.9.1) (2019-03-22)
### Bug Fixes
* use flexbuffer from GH with License ([#821](https://github.com/luin/ioredis/issues/821)) ([93ecd70](https://github.com/luin/ioredis/commit/93ecd70))
# [4.9.0](https://github.com/luin/ioredis/compare/v4.8.0...v4.9.0) (2019-03-18)
### Features
* **sentinel:** support Sentinel instances with authentication. ([#817](https://github.com/luin/ioredis/issues/817)) ([2437eae](https://github.com/luin/ioredis/commit/2437eae))
# [4.8.0](https://github.com/luin/ioredis/compare/v4.7.0...v4.8.0) (2019-03-12)
### Features
* nat support for sentinel connector ([#799](https://github.com/luin/ioredis/issues/799)) ([335b3e2](https://github.com/luin/ioredis/commit/335b3e2))
# [4.7.0](https://github.com/luin/ioredis/compare/v4.6.3...v4.7.0) (2019-03-12)
### Features
* add updateSentinels option to control new sentinel values being added to the original list ([#814](https://github.com/luin/ioredis/issues/814)) ([50a9db7](https://github.com/luin/ioredis/commit/50a9db7)), closes [#798](https://github.com/luin/ioredis/issues/798)
## [4.6.3](https://github.com/luin/ioredis/compare/v4.6.2...v4.6.3) (2019-02-03)
### Bug Fixes
* add second arg to "node error" to know which node failed ([#793](https://github.com/luin/ioredis/issues/793)) ([6049f6c](https://github.com/luin/ioredis/commit/6049f6c)), closes [#774](https://github.com/luin/ioredis/issues/774)
## [4.6.2](https://github.com/luin/ioredis/compare/v4.6.1...v4.6.2) (2019-02-02)
### Bug Fixes
* subscriber initialization when using Cluster ([#792](https://github.com/luin/ioredis/issues/792)) ([32c48ef](https://github.com/luin/ioredis/commit/32c48ef)), closes [#791](https://github.com/luin/ioredis/issues/791)
## [4.6.1](https://github.com/luin/ioredis/compare/v4.6.0...v4.6.1) (2019-01-29)
### Bug Fixes
* **Cluster:** ignore connection errors for subscriber. ([#790](https://github.com/luin/ioredis/issues/790)) ([f368c8a](https://github.com/luin/ioredis/commit/f368c8a)), closes [#768](https://github.com/luin/ioredis/issues/768)
# [4.6.0](https://github.com/luin/ioredis/compare/v4.5.1...v4.6.0) (2019-01-21)
### Features
* add maxLoadingRetryTime option when redis server not ready ([#784](https://github.com/luin/ioredis/issues/784)) ([0e7713f](https://github.com/luin/ioredis/commit/0e7713f))
## [4.5.1](https://github.com/luin/ioredis/compare/v4.5.0...v4.5.1) (2019-01-13)
### Performance Improvements
* add checking and loading scripts uniqueness in pipeline ([#781](https://github.com/luin/ioredis/issues/781)) ([66075ba](https://github.com/luin/ioredis/commit/66075ba))
# [4.5.0](https://github.com/luin/ioredis/compare/v4.4.0...v4.5.0) (2019-01-07)
### Features
* allow TLS when using Sentinel ([ebef8f5](https://github.com/luin/ioredis/commit/ebef8f5))
# [4.4.0](https://github.com/luin/ioredis/compare/v4.3.1...v4.4.0) (2019-01-04)
### Features
* support setting connectTimeout in Electron ([#770](https://github.com/luin/ioredis/issues/770)) ([2d591b7](https://github.com/luin/ioredis/commit/2d591b7))
## [4.3.1](https://github.com/luin/ioredis/compare/v4.3.0...v4.3.1) (2018-12-16)
### Bug Fixes
* **cluster:** handle connection errors by reconnection ([#762](https://github.com/luin/ioredis/issues/762)) ([21138af](https://github.com/luin/ioredis/commit/21138af)), closes [#753](https://github.com/luin/ioredis/issues/753)
# [4.3.0](https://github.com/luin/ioredis/compare/v4.2.3...v4.3.0) (2018-12-09)
### Features
* **cluster:** add NAT support ([#758](https://github.com/luin/ioredis/issues/758)) ([3702d67](https://github.com/luin/ioredis/commit/3702d67)), closes [#693](https://github.com/luin/ioredis/issues/693) [#365](https://github.com/luin/ioredis/issues/365)
## [4.2.3](https://github.com/luin/ioredis/compare/v4.2.2...v4.2.3) (2018-11-24)
### Bug Fixes
* MOVED slot redirection handler ([#749](https://github.com/luin/ioredis/issues/749)) ([bba418f](https://github.com/luin/ioredis/commit/bba418f))
## [4.2.2](https://github.com/luin/ioredis/compare/v4.2.1...v4.2.2) (2018-10-20)
## [4.2.1](https://github.com/luin/ioredis/compare/v4.2.0...v4.2.1) (2018-10-19)
# [4.2.0](https://github.com/luin/ioredis/compare/v4.1.0...v4.2.0) (2018-10-17)
### Features
* support customize dns lookup function ([#723](https://github.com/luin/ioredis/issues/723)) ([b9c4793](https://github.com/luin/ioredis/commit/b9c4793)), closes [antirez/redis#2410](https://github.com/antirez/redis/issues/2410)
<a name="4.1.0"></a>
# [4.1.0](https://github.com/luin/ioredis/compare/v4.0.0...v4.1.0) (2018-10-15)
### Bug Fixes
* **cluster:** quit() ignores errors caused by disconnected connection ([#720](https://github.com/luin/ioredis/issues/720)) ([fb3eb76](https://github.com/luin/ioredis/commit/fb3eb76))
* **cluster:** robust solution for pub/sub in cluster ([#697](https://github.com/luin/ioredis/issues/697)) ([13a5bc4](https://github.com/luin/ioredis/commit/13a5bc4)), closes [#696](https://github.com/luin/ioredis/issues/696)
* **cluster:** stop subscriber when disconnecting ([fb27b66](https://github.com/luin/ioredis/commit/fb27b66))
### Features
* **cluster:** re-select subscriber when the currenct one is failed ([c091f2e](https://github.com/luin/ioredis/commit/c091f2e))
### Performance Improvements
* remove lodash deps for smaller memory footprint ([80f4a45](https://github.com/luin/ioredis/commit/80f4a45))
* **cluster:** make disconnecting from cluster faster ([#721](https://github.com/luin/ioredis/issues/721)) ([ce46d6b](https://github.com/luin/ioredis/commit/ce46d6b))
<a name="4.0.2"></a>
## [4.0.2](https://github.com/luin/ioredis/compare/v4.0.1...v4.0.2) (2018-10-09)
### Bug Fixes
* **cluster:** subscription regards password setting ([47e2ab5](https://github.com/luin/ioredis/commit/47e2ab5)), closes [#718](https://github.com/luin/ioredis/issues/718)
### Performance Improvements
* reduce package bundle size ([eb68e9a](https://github.com/luin/ioredis/commit/eb68e9a))
<a name="4.0.1"></a>
## [4.0.1](https://github.com/luin/ioredis/compare/v4.0.0...v4.0.1) (2018-10-08)
### Bug Fixes
* **cluster:** robust solution for pub/sub in cluster ([#697](https://github.com/luin/ioredis/issues/697)) ([13a5bc4](https://github.com/luin/ioredis/commit/13a5bc4)), closes [#696](https://github.com/luin/ioredis/issues/696)
<a name="4.0.0"></a>
# [4.0.0](https://github.com/luin/ioredis/compare/v4.0.0-3...v4.0.0) (2018-08-14)
**This is a major release and contain breaking changes. Please read this changelog before upgrading.**
## Changes since 4.0.0-3:
### Bug Fixes
* port is ignored when path set to null ([d40a99e](https://github.com/luin/ioredis/commit/d40a99e)), closes [#668](https://github.com/luin/ioredis/issues/668)
### Features
* export Pipeline for inheritances enabling ([#675](https://github.com/luin/ioredis/issues/675)) ([ca58249](https://github.com/luin/ioredis/commit/ca58249))
* export ScanStream at package level ([#667](https://github.com/luin/ioredis/issues/667)) ([5eb4198](https://github.com/luin/ioredis/commit/5eb4198))
## Changes since 3.x
### Bug Fixes
* **Sentinel:** unreachable errors when sentinals are healthy ([7bf6fea](https://github.com/luin/ioredis/commit/7bf6fea))
* resolve warning for Buffer() in Node.js 10 ([6144c56](https://github.com/luin/ioredis/commit/6144c56))
* don't add cluster.info to the failover queue before ready ([491546d](https://github.com/luin/ioredis/commit/491546d))
* solves vulnerabilities dependencies ([2950b79](https://github.com/luin/ioredis/commit/2950b79))
* **Cluster:** issues when setting enableOfflineQueue to false ([#649](https://github.com/luin/ioredis/issues/649)) ([cfe4258](https://github.com/luin/ioredis/commit/cfe4258))
### Performance Improvements
* upgrade redis-parser for better performance.
### Features
* use native Promise instead of Bluebird, and allow users to switch back. ([da60b8b](https://github.com/luin/ioredis/commit/da60b8b))
* add maxRetriesPerRequest option to limit the retries attempts per command ([1babc13](https://github.com/luin/ioredis/commit/1babc13))
* `Redis#connect()` will be resolved when status is ready ([#648](https://github.com/luin/ioredis/issues/648)) ([f0c600b](https://github.com/luin/ioredis/commit/f0c600b))
* add debug details for connection pool ([9ec16b6](https://github.com/luin/ioredis/commit/9ec16b6))
* wait for ready state before resolving cluster.connect() ([7517a73](https://github.com/luin/ioredis/commit/7517a73))
### BREAKING CHANGES
* Drop support for < node v6
* **Use native Promise instead of Bluebird**. This change makes all the code that rely on the features provided by Bluebird not working
anymore. For example, `redis.get('foo').timeout(500)` now should be failed since the native
Promise doesn't support the `timeout` method. You can switch back to the Bluebird
implementation by setting `Redis.Promise`:
```
const Redis = require('ioredis')
Redis.Promise = require('bluebird')
const redis = new Redis()
// Use bluebird
assert.equal(redis.get().constructor, require('bluebird'))
// You can change the Promise implementation at any time:
Redis.Promise = global.Promise
assert.equal(redis.get().constructor, global.Promise)
```
* `Redis#connect()` will be resolved when status is ready
instead of `connect`:
```
const redis = new Redis({ lazyConnect: true })
redis.connect().then(() => {
assert(redis.status === 'ready')
})
```
* `Cluster#connect()` will be resolved when the connection
status become `ready` instead of `connect`.
* The maxRetriesPerRequest is set to 20 instead of null (same behavior as ioredis v3)
by default. So when a redis server is down, pending commands won't wait forever
until the connection become alive, instead, they only wait about 10s (depends on the
retryStrategy option)
* The `new` keyword is required explicitly. Calling `Redis` as a function like
Redis(/* options */)` is deprecated and will not be supported in the next major version,
use `new Redis(/* options */)` instead.
<a name="4.0.0-3"></a>
# [4.0.0-3](https://github.com/luin/ioredis/compare/v4.0.0-2...v4.0.0-3) (2018-07-22)
### Bug Fixes
* **Sentinel:** unreachable errors when sentinals are healthy ([7bf6fea](https://github.com/luin/ioredis/commit/7bf6fea))
* resolve warning for Buffer() in Node.js 10 ([6144c56](https://github.com/luin/ioredis/commit/6144c56))
<a name="4.0.0-2"></a>
# [4.0.0-2](https://github.com/luin/ioredis/compare/v4.0.0-1...v4.0.0-2) (2018-07-07)
Upgrade redis-parser to v3.
See release notes on [redis-parser repo](https://github.com/NodeRedis/node-redis-parser/releases/tag/v.3.0.0) for details.
<a name="4.0.0-1"></a>
# [4.0.0-1](https://github.com/luin/ioredis/compare/v4.0.0-0...v4.0.0-1) (2018-07-02)
### Bug Fixes
* remove unnecessary bluebird usage ([2502b1b](https://github.com/luin/ioredis/commit/2502b1b))
<a name="4.0.0-0"></a>
# [4.0.0-0](https://github.com/luin/ioredis/compare/v3.2.2...v4.0.0-0) (2018-07-01)
### Bug Fixes
* Deprecated `Redis()` in favor of `new Redis()` ([8e7c6f1](https://github.com/luin/ioredis/commit/8e7c6f1))
* don't add cluster.info to the failover queue before ready ([491546d](https://github.com/luin/ioredis/commit/491546d))
* solves vulnerabilities dependencies ([2950b79](https://github.com/luin/ioredis/commit/2950b79))
* **Cluster:** issues when setting enableOfflineQueue to false ([#649](https://github.com/luin/ioredis/issues/649)) ([cfe4258](https://github.com/luin/ioredis/commit/cfe4258))
### Features
* use native Promise instead of Bluebird, and allow users to switch back. ([da60b8b](https://github.com/luin/ioredis/commit/da60b8b))
* add maxRetriesPerRequest option to limit the retries attempts per command ([1babc13](https://github.com/luin/ioredis/commit/1babc13))
* `Redis#connect()` will be resolved when status is ready ([#648](https://github.com/luin/ioredis/issues/648)) ([f0c600b](https://github.com/luin/ioredis/commit/f0c600b))
* add debug details for connection pool ([9ec16b6](https://github.com/luin/ioredis/commit/9ec16b6))
* wait for ready state before resolving cluster.connect() ([7517a73](https://github.com/luin/ioredis/commit/7517a73))
### BREAKING CHANGES
* Drop support for < node v6
* Use native Promise instead of Bluebird. This change makes all the code that rely on the features provided by Bluebird not working
anymore. For example, `redis.get('foo').timeout(500)` now should be failed since the native
Promise doesn't support the `timeout` method. You can switch back to the Bluebird
implementation by setting `Redis.Promise`:
```
const Redis = require('ioredis')
Redis.Promise = require('bluebird')
const redis = new Redis()
// Use bluebird
assert.equal(redis.get().constructor, require('bluebird'))
// You can change the Promise implementation at any time:
Redis.Promise = global.Promise
assert.equal(redis.get().constructor, global.Promise)
```
* `Redis#connect()` will be resolved when status is ready
instead of `connect`:
```
const redis = new Redis({ lazyConnect: true })
redis.connect().then(() => {
assert(redis.status === 'ready')
})
```
* `Cluster#connect()` will be resolved when the connection
status become `ready` instead of `connect`.
* The maxRetriesPerRequest is set to 20 instead of null (same behavior as ioredis v3)
by default. So when a redis server is down, pending commands won't wait forever
until the connection become alive, instead, they only wait about 10s (depends on the
retryStrategy option)
* The `new` keyword is required explicitly. Calling `Redis` as a function like
`Redis(/* options */)` is deprecated and will not be supported in the next major version,
use `new Redis(/* options */)` instead.
<a name="3.2.2"></a>
## [3.2.2](https://github.com/luin/ioredis/compare/v3.2.1...v3.2.2) (2017-11-30)
<a name="3.2.1"></a>
## [3.2.1](https://github.com/luin/ioredis/compare/v3.2.0...v3.2.1) (2017-10-04)
### Bug Fixes
* **Cluster:** empty key name was sent to random nodes ([e42f30f](https://github.com/luin/ioredis/commit/e42f30f))
<a name="3.2.0"></a>
# [3.2.0](https://github.com/luin/ioredis/compare/v3.1.4...v3.2.0) (2017-10-01)
### Features
* truncate large/long debug output arguments ([#523](https://github.com/luin/ioredis/issues/523)) ([cf18554](https://github.com/luin/ioredis/commit/cf18554))
<a name="3.1.4"></a>
## [3.1.4](https://github.com/luin/ioredis/compare/v3.1.3...v3.1.4) (2017-08-13)
We mistakenly used `Object.assign` to replace `lodash.assign` in v3.1.3, which is not supported
by the old Node.js version (0.10.x). This change was a BC change and shouldn't happen without changing
the major version, so we added `lodash.assign` back.
<a name="3.1.3"></a>
## [3.1.3](https://github.com/luin/ioredis/compare/v3.1.2...v3.1.3) (2017-08-13)
### Bug Fixes
* allow convertObjectToArray to handle objects with no prototype ([#507](https://github.com/luin/ioredis/issues/507)) ([8e17920](https://github.com/luin/ioredis/commit/8e17920))
<a name="3.1.2"></a>
## [3.1.2](https://github.com/luin/ioredis/compare/v3.1.1...v3.1.2) (2017-07-26)
### Bug Fixes
* stop mutating the arguments when calling multi ([#480](https://github.com/luin/ioredis/issues/480)) ([a380030](https://github.com/luin/ioredis/commit/a380030))
<a name="3.1.1"></a>
## [3.1.1](https://github.com/luin/ioredis/compare/v3.1.0...v3.1.1) (2017-05-31)
### Bug Fixes
* show error name the error stack for Node.js 8 ([a628aa7](https://github.com/luin/ioredis/commit/a628aa7))
<a name="3.1.0"></a>
# [3.1.0](https://github.com/luin/ioredis/compare/v3.0.0...v3.1.0) (2017-05-30)
### Bug Fixes
* non-owned properties cause empty args for mset & hmset ([#469](https://github.com/luin/ioredis/issues/469)) ([e7b6352](https://github.com/luin/ioredis/commit/e7b6352))
### Features
* **cluster:** add option to control timeout on cluster slots refresh ([#475](https://github.com/luin/ioredis/issues/475)) ([493d095](https://github.com/luin/ioredis/commit/493d095))
<a name="3.0.0"></a>
# [3.0.0](https://github.com/luin/ioredis/compare/v3.0.0-2...v3.0.0) (2017-05-18)
### Features
* **pipeline:** add #length to get the command count ([a6060cb](https://github.com/luin/ioredis/commit/a6060cb)), closes [#461](https://github.com/luin/ioredis/issues/461)
* **sentinel:** allow connection to IPv6-only sentinels ([#463](https://github.com/luin/ioredis/issues/463)) ([a389f3c](https://github.com/luin/ioredis/commit/a389f3c))
<a name="3.0.0-2"></a>
# [3.0.0-2](https://github.com/luin/ioredis/compare/v3.0.0-1...v3.0.0-2) (2017-05-03)
### Bug Fixes
* restore the default connectTimeout to 10000 ([dc8256e](https://github.com/luin/ioredis/commit/dc8256e))
<a name="3.0.0-1"></a>
# [3.0.0-1](https://github.com/luin/ioredis/compare/v3.0.0-0...v3.0.0-1) (2017-04-16)
### Features
* add debug logs for resolved sentinel nodes ([8f3d3f7](https://github.com/luin/ioredis/commit/8f3d3f7))
* report error on Sentinel connection refused ([#445](https://github.com/luin/ioredis/issues/445)) ([#446](https://github.com/luin/ioredis/issues/446)) ([286a5bc](https://github.com/luin/ioredis/commit/286a5bc))
* set default port of sentinels to 26379. ([#441](https://github.com/luin/ioredis/issues/441)) ([539fe41](https://github.com/luin/ioredis/commit/539fe41))
### BREAKING CHANGES
* The default port of sentinels are now 26379 instead of 6379. This shouldn't break your app in most case since few setups has the sentinel server running on 6379, but if it's your case and the port isn't set explicitly, please go to update it.
<a name="3.0.0-0"></a>
# [3.0.0-0](https://github.com/luin/ioredis/compare/v2.5.0...v3.0.0-0) (2017-01-26)
This is a performance-focused release. We finially switch to the new version of JavaScript parser and drop the support for hiredis (Thanks to the lovely community!).
Also, we switch to [denque](https://github.com/Salakar/denque) to improve the queueing performance.
Let us know if there's any issue when using this pre-release.
### Other Changes
* increase the default reconnection interval ([c5fefb7](https://github.com/luin/ioredis/commit/c5fefb7)), closes [#414](https://github.com/luin/ioredis/issues/414)
### BREAKING CHANGES
* Although the interface doesn't change after upgrading the js parser, there may be still some potential internal differences that may break the applications which rely on them. Also, force a major version bump emphasizes the dropping of the hiredis.
<a name="2.5.0"></a>
# [2.5.0](https://github.com/luin/ioredis/compare/v2.4.3...v2.5.0) (2017-01-06)
### Features
* quit immediately when in reconnecting state (#410) ([a6f04f2](https://github.com/luin/ioredis/commit/a6f04f2))
<a name="2.4.3"></a>
## [2.4.3](https://github.com/luin/ioredis/compare/v2.4.2...v2.4.3) (2016-12-15)
### Bug Fixes
* wait all the commands in a pipeline before sending #411 (#413) ([bfa879a](https://github.com/luin/ioredis/commit/bfa879a))
<a name="2.4.2"></a>
## [2.4.2](https://github.com/luin/ioredis/compare/v2.4.1...v2.4.2) (2016-12-04)
### Bug Fixes
* handle error when creating tls connection ([904f433](https://github.com/luin/ioredis/commit/904f433))
<a name="2.4.1"></a>
## [2.4.1](https://github.com/luin/ioredis/compare/v2.4.0...v2.4.1) (2016-12-04)
### Performance Improvements
* by default call setNoDelay on the stream (#406) ([990a221](https://github.com/luin/ioredis/commit/990a221))
<a name="2.4.0"></a>
# [2.4.0](https://github.com/luin/ioredis/compare/v2.3.1...v2.4.0) (2016-09-24)
### Features
* Sentinel preferredSlaves option ([#370](https://github.com/luin/ioredis/issues/370)) ([6ddcc99](https://github.com/luin/ioredis/commit/6ddcc99))
<a name="2.3.1"></a>
## [2.3.1](https://github.com/luin/ioredis/compare/v2.3.0...v2.3.1) (2016-09-24)
### Bug Fixes
* prevent sentinel from getting duplicated nodes ([0338677](https://github.com/luin/ioredis/commit/0338677))
<a name="2.3.0"></a>
## [2.3.0](https://github.com/luin/ioredis/compare/v2.2.0...v2.3.0) (2016-08-11)
### Bug Fixes
* reject with general error in Redis#connect ([#354](https://github.com/luin/ioredis/issues/354)) ([8f7a436](https://github.com/luin/ioredis/commit/8f7a436))
### Features
* **cluster:** add lazy connect support ([#352](https://github.com/luin/ioredis/issues/352)) ([f1cadff](https://github.com/luin/ioredis/commit/f1cadff))
<a name="2.2.0"></a>
## [2.2.0](https://github.com/luin/ioredis/compare/v2.1.0...v2.2.0) (2016-06-28)
### Bug Fixes
* **cluster:** ensure node exists before being redirected via an ASK (#341) ([5d9d0d3](https://github.com/luin/ioredis/commit/5d9d0d3))
### Features
* **cluster:** add Cluster#quit() to quit cluster gracefully. (#339) ([68c4ccc](https://github.com/luin/ioredis/commit/68c4ccc)), closes [#315](https://github.com/luin/ioredis/issues/315)
<a name="2.1.0"></a>
## [2.1.0](https://github.com/luin/ioredis/compare/v2.0.1...v2.1.0) (2016-06-22)
### Bug Fixes
* remove unnecessary unhandled error warnings ([#322](https://github.com/luin/ioredis/issues/322)) ([a1ff2f6](https://github.com/luin/ioredis/commit/a1ff2f6))
### Features
* **sentinel:** update sentinels after getting master ([e3f14b2](https://github.com/luin/ioredis/commit/e3f14b2))
### Performance Improvements
* **cluster:** improve the performance of calculating slots ([#323](https://github.com/luin/ioredis/issues/323)) ([3ab4e8a](https://github.com/luin/ioredis/commit/3ab4e8a))
<a name="2.0.1"></a>
## [2.0.1](https://github.com/luin/ioredis/compare/v2.0.0...v2.0.1) (2016-06-01)
### Bug Fixes
* fix transaction with dropBufferSupport:true([47a2d9a](https://github.com/luin/ioredis/commit/47a2d9a))
<a name="2.0.0"></a>
## [2.0.0](https://github.com/luin/ioredis/compare/v2.0.0-rc4...v2.0.0) (2016-05-29)
Refer to [Breaking Changes between V1 and V2](https://github.com/luin/ioredis/wiki/Breaking-changes-between-v1-and-v2) for all breaking changes.
Changes since 2.0.0-rc4:
### Features
* include source and database in monitor events ([#308](https://github.com/luin/ioredis/issues/308)) ([a0d5b25](https://github.com/luin/ioredis/commit/a0d5b25))
### Performance Improvements
* improve the performance of checking flags ([#312](https://github.com/luin/ioredis/issues/312)) ([236da27](https://github.com/luin/ioredis/commit/236da27))
<a name="2.0.0-rc4"></a>
## [2.0.0-rc4](https://github.com/luin/ioredis/compare/v2.0.0-rc3...v2.0.0-rc4) (2016-05-08)
### Bug Fixes
* reconnect when ready check failed([3561fab](https://github.com/luin/ioredis/commit/3561fab))
* remove data handler when flushing command queue([b1c761c](https://github.com/luin/ioredis/commit/b1c761c))
* won't emit error again when password is wrong([dfdebfe](https://github.com/luin/ioredis/commit/dfdebfe))
### Features
* add dropBufferSupport option to improve the performance ([#293](https://github.com/luin/ioredis/issues/293))([1a8700c](https://github.com/luin/ioredis/commit/1a8700c))
* add support for Node.js v6 ([#295](https://github.com/luin/ioredis/issues/295))([a87f405](https://github.com/luin/ioredis/commit/a87f405))
* emit authentication related errors with "error" event([9dc25b4](https://github.com/luin/ioredis/commit/9dc25b4))
* print logs for unhandled error event([097fdbc](https://github.com/luin/ioredis/commit/097fdbc))
### BREAKING CHANGES
* Authentication related errors are emited with "error" event,
instead of "authError" event
<a name="2.0.0-rc3"></a>
## [2.0.0-rc3](https://github.com/luin/ioredis/compare/v2.0.0-rc2...v2.0.0-rc3) (2016-05-02)
### Bug Fixes
* fix wrong host not causing error ([25c300e](https://github.com/luin/ioredis/commit/25c300e)), closes [#287](https://github.com/luin/ioredis/issues/287)
* reconnect when getting fatal error (#292) ([1cf2ac1](https://github.com/luin/ioredis/commit/1cf2ac1))
### Features
* **deps:** upgrade redis-commands package ([df08250](https://github.com/luin/ioredis/commit/df08250))
<a name="2.0.0-rc2"></a>
## [2.0.0-rc2](https://github.com/luin/ioredis/compare/v2.0.0-rc1...v2.0.0-rc2) (2016-04-10)
### Bug Fixes
* **CLUSTER:** fix cluster not disconnected when called disconnect method (#281) ([91998e3](https://github.com/luin/ioredis/commit/91998e3)), closes [(#281](https://github.com/(/issues/281)
* **sentinel:** improve the error message when connection to sentinel is rejected ([3ca30d8](https://github.com/luin/ioredis/commit/3ca30d8)), closes [#280](https://github.com/luin/ioredis/issues/280)
### Features
* add stringNumbers option to return numbers as JavaScript strings (#282) ([2a33fc7](https://github.com/luin/ioredis/commit/2a33fc7)), closes [#273](https://github.com/luin/ioredis/issues/273)
<a name="2.0.0-rc1"></a>
## [2.0.0-rc1](https://github.com/luin/ioredis/compare/v2.0.0-alpha3...v2.0.0-rc1) (2016-03-18)
### Features
* **dependencies**: upgrade all dependencies to the newest version ([3fdafc8](https://github.com/luin/ioredis/commit/3fdafc8)).
<a name="2.0.0-alpha3"></a>
## [2.0.0-alpha3](https://github.com/luin/ioredis/compare/v2.0.0-alpha2...v2.0.0-alpha3) (2016-03-13)
### Bug Fixes
* **auth:** emit authError when the server requiring a password ([c5ca754](https://github.com/luin/ioredis/commit/c5ca754))
### Features
* **cluster:** add enableReadyCheck option for cluster ([b63cdc7](https://github.com/luin/ioredis/commit/b63cdc7))
* **cluster:** redirect on TRYAGAIN error ([b1a4b62](https://github.com/luin/ioredis/commit/b1a4b62))
* **cluster:** support update startupNodes in clusterRetryStrategy ([4a46766](https://github.com/luin/ioredis/commit/4a46766))
* **transaction:** transform replies of transactions ([e0b1883](https://github.com/luin/ioredis/commit/e0b1883)), closes [#158](https://github.com/luin/ioredis/issues/158)
### BREAKING CHANGES
1. Reply transformers is supported inside transactions.
2. `Pipeline#execBuffer()` is deprecated. Use `Pipeline#exec()` instead.
<a name="2.0.0-alpha2"></a>
## [2.0.0-alpha2](https://github.com/luin/ioredis/compare/v2.0.0-alpha1...v2.0.0-alpha2) (2016-02-29)
### Bug Fixes
* **cluster:** fix memory leaking in sendCommand method ([410af51](https://github.com/luin/ioredis/commit/410af51))
### Features
* **cluster:** add the option for a custom node selector in scaleReads ([6795b1e](https://github.com/luin/ioredis/commit/6795b1e))
<a name="2.0.0-alpha1"></a>
## [2.0.0-alpha1](https://github.com/luin/ioredis/compare/v1.15.0...v2.0.0-alpha1) (2016-02-10)
### Bug Fixes
* **cluster:** avoid command.reject being overwritten twice ([d0a0017](https://github.com/luin/ioredis/commit/d0a0017))
* **cluster:** fix not connecting to the unknown nodes ([0dcb768](https://github.com/luin/ioredis/commit/0dcb768))
* **cluster:** set retryDelayOnFailover from 2000ms to 200ms ([72fd804](https://github.com/luin/ioredis/commit/72fd804))
### Features
* **cluster:** support scaling reads to slaves ([98bdec2](https://github.com/luin/ioredis/commit/98bdec2)), closes [#170](https://github.com/luin/ioredis/issues/170)
* **redis:** support readonly mode for cluster ([0a4186e](https://github.com/luin/ioredis/commit/0a4186e))
### BREAKING CHANGES
* **cluster:** `Cluster#masterNodes` and `Cluster#nodes` is removed. Use `Cluster#nodes('masters')` and `Cluster#nodes('all')` instead.
* **cluster:** `Cluster#to()` is removed. Use `Promise.all(Cluster#nodes().map(function (node) {}))` instead.
* **cluster:** Option `readOnly` is removed. Check out `scaleReads` option.
<a name="1.15.1"></a>
## [1.15.1](https://github.com/luin/ioredis/compare/v1.15.0...v1.15.1) (2016-02-19)
* select db on connect event to prevent subscribe errors ([829bf26](https://github.com/luin/ioredis/commit/829bf26)), closes [#255](https://github.com/luin/ioredis/issues/255)
<a name="1.15.0"></a>
## [1.15.0](https://github.com/luin/ioredis/compare/v1.14.0...v1.15.0) (2016-01-31)
### Bug Fixes
* "MOVED" err not crashing process when slot was not assigned ([6974d4d](https://github.com/luin/ioredis/commit/6974d4d))
* remove extra typeof in .to cluster helper ([a7b0bfe](https://github.com/luin/ioredis/commit/a7b0bfe))
### Features
* revisit of .to(nodeGroup) command ([ba12e47](https://github.com/luin/ioredis/commit/ba12e47))
## v1.14.0 - January 4, 2016
* Support returning buffers for transactions ([#223](https://github.com/luin/ioredis/issues/223)).
## v1.13.2 - December 30, 2015
* Add argument transformer for msetnx to support Map ([#218](https://github.com/luin/ioredis/issues/218)).
## v1.13.1 - December 20, 2015
* Fix `mset` transformer not supporting keyPrefix ([#217](https://github.com/luin/ioredis/issues/217)).
## v1.13.0 - December 13, 2015
* [Cluster] Select a random node when the target node is closed.
* [Cluster] `maxRedirections` also works for `CLUSTERDOWN`.
## v1.12.2 - December 6, 2015
* [Cluster] Fix failover queue not being processed. [Shahar Mor](https://github.com/shaharmor).
## v1.12.1 - December 5, 2015
* [Cluster] Add queue support for failover and CLUSTERDOWN handling. [Shahar Mor](https://github.com/shaharmor).
* Emits "error" when connection is down for `scanStream` ([#199](https://github.com/luin/ioredis/issues/199)).
## v1.11.1 - November 26, 2015
* [Sentinel] Emits "error" when all sentinels are unreachable ([#200](https://github.com/luin/ioredis/issues/200)).
## v1.11.0 - November 19, 2015
* Emits "select" event when the database changed.
* [Cluster] Supports scanStream ([#175](https://github.com/luin/ioredis/issues/175)).
* Update debug module to 2.2.0
* Update bluebird module to 2.9.34
## v1.10.0 - October 24, 2015
* [Cluster] Support redis schema url.
* [Cluster] Support specifying password for each node.
* Add an option for setting connection name. [cgiovanacci](https://github.com/cgiovanacci).
* Switch to the previous db before re-subscribing channels.
* Listen to the "secureConnect" event when connect via TLS. [Jeffrey Jen](https://github.com/jeffjen).
* Improve parser performance.
## v1.9.1 - October 2, 2015
* Emits "authError" event when the password is wrong([#164](https://github.com/luin/ioredis/issues/164)).
* Fixed wrong debug output when using sentinels. [Colm Hally](https://github.com/ColmHally)
* Discard slave if flagged with s_down or o_down. [mtlima](https://github.com/mtlima)
## v1.9.0 - September 18, 2015
* Support TLS.
* Support reconnecting on the specified error.
## v1.8.0 - September 9, 2015
* Add keepAlive option(defaults to `true`).
* Fix compatible issues of Buffer with Node.js 4.0.
## v1.7.6 - September 1, 2015
* Fix errors when sending command to a failed cluster([#56](https://github.com/luin/ioredis/issues/56)).
## v1.7.5 - August 16, 2015
* Fix for allNodes array containing nodes not serving the specified slot. [henstock](https://github.com/henstock)
## v1.7.4 - August 13, 2015
* Restore the previous state before resending the unfulfilled commands. [Jay Merrifield](https://github.com/fracmak)
* Fix empty pipeline not resolving as empty array. [Philip Kannegaard Hayes](https://github.com/phlip9)
## v1.7.3 - August 3, 2015
* Handle watch-exec rollback correctly([#199](https://github.com/luin/ioredis/pull/119)). [Andrew Newdigate](https://github.com/suprememoocow)
## v1.7.2 - July 30, 2015
* Fix not running callback in pipeline custom command([#117](https://github.com/luin/ioredis/pull/117)). [Philip Kannegaard Hayes](https://github.com/phlip9)
* Fixes status debug message in case of Unix socket path([#114](https://github.com/luin/ioredis/pull/114)). [Thalis Kalfigkopoulos](https://github.com/tkalfigo)
## v1.7.1 - July 26, 2015
* Re-subscribe previous channels after reconnection([#110](https://github.com/luin/ioredis/pull/110)).
## v1.7.0 - July 23, 2015
* Support transparent key prefixing([#105](https://github.com/luin/ioredis/pull/105)). [Danny Guo](https://github.com/dguo)
## v1.6.1 - July 12, 2015
* Fix `Redis.Command` not being exported correctly([#100](https://github.com/luin/ioredis/issues/100)).
## v1.6.0 - July 11, 2015
* Add a streaming interface to `SCAN` commands.
* Support GEO commands.
## v1.5.12 - July 7, 2015
* Fix the order of received commands([#91](https://github.com/luin/ioredis/issues/91)).
## v1.5.11 - July 7, 2015
* Allow omitting callback in `exec`.
## v1.5.10 - July 6, 2015
* Add `send_command` method for compatibility([#90](https://github.com/luin/ioredis/issues/90)).
## v1.5.9 - July 4, 2015
* Fix connection error emitting before listening to `error` event([#80](https://github.com/luin/ioredis/issues/80)).
## v1.5.8 - July 3, 2015
* Fix `pmessage` gets `undefined` in cluster mode([#88](https://github.com/luin/ioredis/issues/88)). [Kris Linquist](https://github.com/klinquist)
## v1.5.7 - July 1, 2015
* Fix subscriptions lost after reconnection([#85](https://github.com/luin/ioredis/issues/85)).
## v1.5.6 - June 28, 2015
* Silent error when redis server has cluster support disabled([#82](https://github.com/luin/ioredis/issues/82)).
## v1.5.5 - June 25, 2015
* Fix storing wrong redis host internally.
## v1.5.4 - June 25, 2015
* Fix masterNodes not being removed correctly.
## v1.5.3 - June 24, 2015
* Fix sometimes monitor leads command queue error.
## v1.5.2 - June 24, 2015
* Fix `enableReadyCheck` is always `false` in monitor mode([#77](https://github.com/luin/ioredis/issues/77)).
## v1.5.1 - June 16, 2015
* Fix getting NaN db index([#74](https://github.com/luin/ioredis/issues/74)).
## v1.5.0 - June 13, 2015
* Uses double ended queue instead of Array for better performance.
* Resolves a bug with cluster where a subscribe is sent to a disconnected node([#63](https://github.com/luin/ioredis/pull/63)). [Ari Aosved](https://github.com/devaos).
* Adds ReadOnly mode for Cluster mode([#69](https://github.com/luin/ioredis/pull/69)). [Nakul Ganesh](https://github.com/luin/ioredis/pull/69).
* Adds `Redis.print`([#71](https://github.com/luin/ioredis/pull/71)). [Frank Murphy](https://github.com/frankvm04).
## v1.4.0 - June 3, 2015
* Continue monitoring after reconnection([#52](https://github.com/luin/ioredis/issues/52)).
* Support pub/sub in Cluster mode([#54](https://github.com/luin/ioredis/issues/54)).
* Auto-reconnect when none of startup nodes is ready([#56](https://github.com/luin/ioredis/issues/56)).
## v1.3.6 - May 22, 2015
* Support Node.js 0.10.16
* Fix unfulfilled commands being sent to the wrong db([#42](https://github.com/luin/ioredis/issues/42)).
## v1.3.5 - May 21, 2015
* Fix possible memory leak warning of Cluster.
* Stop reconnecting when disconnected manually.
## v1.3.4 - May 21, 2015
* Add missing Promise definition in node 0.10.x.
## v1.3.3 - May 19, 2015
* Fix possible memory leak warning.
## v1.3.2 - May 18, 2015
* The constructor of `pipeline`/`multi` accepts a batch of commands.
## v1.3.1 - May 16, 2015
* Improve the performance of sending commands([#35](https://github.com/luin/ioredis/issues/35)). [@AVVS](https://github.com/AVVS).
## v1.3.0 - May 15, 2015
* Support pipeline redirection in Cluster mode.
## v1.2.7 - May 15, 2015
* `Redis#connect` returns a promise.
## v1.2.6 - May 13, 2015
* Fix showFriendlyErrorStack not working in pipeline.
## v1.2.5 - May 12, 2015
* Fix errors when sending commands after connection being closed.
## v1.2.4 - May 9, 2015
* Try a random node when the target slot isn't served by the cluster.
* Remove `refreshAfterFails` option.
* Try random node when refresh slots.
## v1.2.3 - May 9, 2015
* Fix errors when `numberOfKeys` is `0`.
## v1.2.2 - May 8, 2015
* Add `retryDelayOnClusterDown` option to handle CLUSTERDOWN error.
* Fix `multi` commands sometimes doesn't return a promise.
## v1.2.1 - May 7, 2015
* Fix `sendCommand` sometimes doesn't return a promise.
## v1.2.0 - May 4, 2015
* Add `autoResendUnfulfilledCommands` option.
## v1.1.4 - May 3, 2015
* Support get built-in commands.
## v1.1.3 - May 2, 2015
* Fix buffer supporting in pipeline. [@AVVS](https://github.com/AVVS).
## v1.1.2 - May 2, 2015
* Fix error of sending command to wrong node when slot is 0.
## v1.1.1 - May 2, 2015
* Support Transaction and pipelining in cluster mode.
## v1.1.0 - May 1, 2015
* Support cluster auto reconnection.
* Add `maxRedirections` option to Cluster.
* Remove `roleRetryDelay` option in favor of `sentinelRetryStrategy`.
* Improve compatibility with node_redis.
* More stable sentinel connection.
## v1.0.13 - April 27, 2015
* Support SORT, ZUNIONSTORE and ZINTERSTORE in Cluster.
## v1.0.12 - April 27, 2015
* Support for defining custom commands in Cluster.
* Use native array instead of fastqueue for better performance.
## v1.0.11 - April 26, 2015
* Add `showFriendlyErrorStack` option for outputing friendly error stack.
## v1.0.10 - April 25, 2015
* Improve performance for calculating slots.
## v1.0.9 - April 25, 2015
* Support single node commands in cluster mode.
## v1.0.8 - April 25, 2015
* Add promise supports in Cluster.
## v1.0.7 - April 25, 2015
* Add `autoResubscribe` option to prevent auto re-subscribe.
* Add `Redis#end` for compatibility.
* Add `Redis.createClient`(was `Redis#createClient`).
## v1.0.6 - April 24, 2015
* Support setting connect timeout.
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at i@zihua.li. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2015-2022 Zihua Li
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
[](https://github.com/redis/ioredis)
[](https://github.com/redis/ioredis/actions/workflows/release.yml?query=branch%3Amain)
[](https://coveralls.io/github/luin/ioredis?branch=main)
[](http://commitizen.github.io/cz-cli/)
[](https://github.com/semantic-release/semantic-release)
[](https://discord.gg/redis)
[](https://www.twitch.tv/redisinc)
[](https://www.youtube.com/redisinc)
[](https://twitter.com/redisinc)
A robust, performance-focused and full-featured [Redis](http://redis.io) client for [Node.js](https://nodejs.org).
Supports Redis >= 2.6.12. Completely compatible with Redis 7.x.
ioredis is a stable project and maintenance is done on a best-effort basis for relevant issues (contributions to ioredis will still be evaluated, reviewed, and merged when they benefit the project). For new projects, node-redis is the recommended client library. [node-redis](https://github.com/redis/node-redis) is the open-source (MIT license) Redis JavaScript client library redesigned from the ground up and actively maintained. [node-redis](https://github.com/redis/node-redis) supports new (hash-field expiration) and future commands and the capabilities available in Redis Stack and Redis 8 (search, JSON, time-series, probabilistic data structures).
# Features
ioredis is a robust, full-featured Redis client that is
used in the world's biggest online commerce company [Alibaba](http://www.alibaba.com/) and many other awesome companies.
0. Full-featured. It supports [Cluster](http://redis.io/topics/cluster-tutorial), [Sentinel](https://redis.io/docs/latest/operate/oss_and_stack/management/sentinel/), [Streams](https://redis.io/topics/streams-intro), [Pipelining](http://redis.io/topics/pipelining), and of course [Lua scripting](http://redis.io/commands/eval), [Redis Functions](https://redis.io/topics/functions-intro), [Pub/Sub](http://redis.io/topics/pubsub) (with the support of binary messages).
1. High performance 🚀.
2. Delightful API 😄. It works with Node callbacks and Native promises.
3. Transformation of command arguments and replies.
4. Transparent key prefixing.
5. Abstraction for Lua scripting, allowing you to [define custom commands](https://github.com/redis/ioredis#lua-scripting).
6. Supports [binary data](https://github.com/redis/ioredis#handle-binary-data).
7. Supports [TLS](https://github.com/redis/ioredis#tls-options) 🔒.
8. Supports offline queue and ready checking.
9. Supports ES6 types, such as `Map` and `Set`.
10. Supports GEO commands 📍.
11. Supports Redis ACL.
12. Sophisticated error handling strategy.
13. Supports NAT mapping.
14. Supports autopipelining.
**100% written in TypeScript and official declarations are provided:**
<img width="837" src="resources/ts-screenshot.png" alt="TypeScript Screenshot" />
# Versions
| Version | Branch | Node.js Version | Redis Version |
| -------------- | ------ | --------------- | --------------- |
| 5.x.x (latest) | main | >= 12 | 2.6.12 ~ latest |
| 4.x.x | v4 | >= 8 | 2.6.12 ~ 7 |
Refer to [CHANGELOG.md](CHANGELOG.md) for features and bug fixes introduced in v5.
🚀 [Upgrading from v4 to v5](https://github.com/redis/ioredis/wiki/Upgrading-from-v4-to-v5)
# Links
- [API Documentation](https://redis.github.io/ioredis/) ([Redis](https://redis.github.io/ioredis/classes/Redis.html), [Cluster](https://redis.github.io/ioredis/classes/Cluster.html))
- [Changelog](CHANGELOG.md)
<hr>
# Quick Start
## Install
```shell
npm install ioredis
```
In a TypeScript project, you may want to add TypeScript declarations for Node.js:
```shell
npm install --save-dev @types/node
```
## Basic Usage
```javascript
// Import ioredis.
// You can also use `import { Redis } from "ioredis"`
// if your project is a TypeScript project,
// Note that `import Redis from "ioredis"` is still supported,
// but will be deprecated in the next major version.
const Redis = require("ioredis");
// Create a Redis instance.
// By default, it will connect to localhost:6379.
// We are going to cover how to specify connection options soon.
const redis = new Redis();
redis.set("mykey", "value"); // Returns a promise which resolves to "OK" when the command succeeds.
// ioredis supports the node.js callback style
redis.get("mykey", (err, result) => {
if (err) {
console.error(err);
} else {
console.log(result); // Prints "value"
}
});
// Or ioredis returns a promise if the last argument isn't a function
redis.get("mykey").then((result) => {
console.log(result); // Prints "value"
});
redis.zadd("sortedSet", 1, "one", 2, "dos", 4, "quatro", 3, "three");
redis.zrange("sortedSet", 0, 2, "WITHSCORES").then((elements) => {
// ["one", "1", "dos", "2", "three", "3"] as if the command was `redis> ZRANGE sortedSet 0 2 WITHSCORES`
console.log(elements);
});
// All arguments are passed directly to the redis server,
// so technically ioredis supports all Redis commands.
// The format is: redis[SOME_REDIS_COMMAND_IN_LOWERCASE](ARGUMENTS_ARE_JOINED_INTO_COMMAND_STRING)
// so the following statement is equivalent to the CLI: `redis> SET mykey hello EX 10`
redis.set("mykey", "hello", "EX", 10);
```
See the `examples/` folder for more examples. For example:
- [TTL](examples/ttl.js)
- [Strings](examples/string.js)
- [Hashes](examples/hash.js)
- [Lists](examples/list.js)
- [Sets](examples/set.js)
- [Sorted Sets](examples/zset.js)
- [Streams](examples/stream.js)
- [Redis Modules](examples/module.js) e.g. RedisJSON
All Redis commands are supported. See [the documentation](https://redis.github.io/ioredis/classes/Redis.html) for details.
## Connect to Redis
When a new `Redis` instance is created,
a connection to Redis will be created at the same time.
You can specify which Redis to connect to by:
```javascript
new Redis(); // Connect to 127.0.0.1:6379
new Redis(6380); // 127.0.0.1:6380
new Redis(6379, "192.168.1.1"); // 192.168.1.1:6379
new Redis("/tmp/redis.sock");
new Redis({
port: 6379, // Redis port
host: "127.0.0.1", // Redis host
username: "default", // needs Redis >= 6
password: "my-top-secret",
db: 0, // Defaults to 0
});
```
You can also specify connection options as a [`redis://` URL](http://www.iana.org/assignments/uri-schemes/prov/redis) or [`rediss://` URL](https://www.iana.org/assignments/uri-schemes/prov/rediss) when using [TLS encryption](#tls-options):
```javascript
// Connect to 127.0.0.1:6380, db 4, using password "authpassword":
new Redis("redis://:authpassword@127.0.0.1:6380/4");
// Username can also be passed via URI.
new Redis("redis://username:authpassword@127.0.0.1:6380/4");
```
See [API Documentation](https://redis.github.io/ioredis/index.html#RedisOptions) for all available options.
## Pub/Sub
Redis provides several commands for developers to implement the [Publish–subscribe pattern](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern). There are two roles in this pattern: publisher and subscriber. Publishers are not programmed to send their messages to specific subscribers. Rather, published messages are characterized into channels, without knowledge of what (if any) subscribers there may be.
By leveraging Node.js's built-in events module, ioredis makes pub/sub very straightforward to use. Below is a simple example that consists of two files, one is publisher.js that publishes messages to a channel, the other is subscriber.js that listens for messages on specific channels.
```javascript
// publisher.js
const Redis = require("ioredis");
const redis = new Redis();
setInterval(() => {
const message = { foo: Math.random() };
// Publish to my-channel-1 or my-channel-2 randomly.
const channel = `my-channel-${1 + Math.round(Math.random())}`;
// Message can be either a string or a buffer
redis.publish(channel, JSON.stringify(message));
console.log("Published %s to %s", message, channel);
}, 1000);
```
```javascript
// subscriber.js
const Redis = require("ioredis");
const redis = new Redis();
redis.subscribe("my-channel-1", "my-channel-2", (err, count) => {
if (err) {
// Just like other commands, subscribe() can fail for some reasons,
// ex network issues.
console.error("Failed to subscribe: %s", err.message);
} else {
// `count` represents the number of channels this client are currently subscribed to.
console.log(
`Subscribed successfully! This client is currently subscribed to ${count} channels.`
);
}
});
redis.on("message", (channel, message) => {
console.log(`Received ${message} from ${channel}`);
});
// There's also an event called 'messageBuffer', which is the same as 'message' except
// it returns buffers instead of strings.
// It's useful when the messages are binary data.
redis.on("messageBuffer", (channel, message) => {
// Both `channel` and `message` are buffers.
console.log(channel, message);
});
```
It's worth noticing that a connection (aka a `Redis` instance) can't play both roles at the same time. More specifically, when a client issues `subscribe()` or `psubscribe()`, it enters the "subscriber" mode. From that point, only commands that modify the subscription set are valid. Namely, they are: `subscribe`, `psubscribe`, `unsubscribe`, `punsubscribe`, `ping`, and `quit`. When the subscription set is empty (via `unsubscribe`/`punsubscribe`), the connection is put back into the regular mode.
If you want to do pub/sub in the same file/process, you should create a separate connection:
```javascript
const Redis = require("ioredis");
const sub = new Redis();
const pub = new Redis();
sub.subscribe(/* ... */); // From now, `sub` enters the subscriber mode.
sub.on("message" /* ... */);
setInterval(() => {
// `pub` can be used to publish messages, or send other regular commands (e.g. `hgetall`)
// because it's not in the subscriber mode.
pub.publish(/* ... */);
}, 1000);
```
`PSUBSCRIBE` is also supported in a similar way when you want to subscribe all channels whose name matches a pattern:
```javascript
redis.psubscribe("pat?ern", (err, count) => {});
// Event names are "pmessage"/"pmessageBuffer" instead of "message/messageBuffer".
redis.on("pmessage", (pattern, channel, message) => {});
redis.on("pmessageBuffer", (pattern, channel, message) => {});
```
## Streams
Redis v5 introduces a new data type called streams. It doubles as a communication channel for building streaming architectures and as a log-like data structure for persisting data. With ioredis, the usage can be pretty straightforward. Say we have a producer publishes messages to a stream with `redis.xadd("mystream", "*", "randomValue", Math.random())` (You may find the [official documentation of Streams](https://redis.io/topics/streams-intro) as a starter to understand the parameters used), to consume the messages, we'll have a consumer with the following code:
```javascript
const Redis = require("ioredis");
const redis = new Redis();
const processMessage = (message) => {
console.log("Id: %s. Data: %O", message[0], message[1]);
};
async function listenForMessage(lastId = "$") {
// `results` is an array, each element of which corresponds to a key.
// Because we only listen to one key (mystream) here, `results` only contains
// a single element. See more: https://redis.io/commands/xread#return-value
const results = await redis.xread("BLOCK", 0, "STREAMS", "mystream", lastId);
const [key, messages] = results[0]; // `key` equals to "mystream"
messages.forEach(processMessage);
// Pass the last id of the results to the next round.
await listenForMessage(messages[messages.length - 1][0]);
}
listenForMessage();
```
## Expiration
Redis can set a timeout to expire your key, after the timeout has expired the key will be automatically deleted. (You can find the [official Expire documentation](https://redis.io/commands/expire/) to understand better the different parameters you can use), to set your key to expire in 60 seconds, we will have the following code:
```javascript
redis.set("key", "data", "EX", 60);
// Equivalent to redis command "SET key data EX 60", because on ioredis set method,
// all arguments are passed directly to the redis server.
```
## Handle Binary Data
Binary data support is out of the box. Pass buffers to send binary data:
```javascript
redis.set("foo", Buffer.from([0x62, 0x75, 0x66]));
```
Every command that returns a [bulk string](https://redis.io/docs/reference/protocol-spec/#resp-bulk-strings)
has a variant command with a `Buffer` suffix. The variant command returns a buffer instead of a UTF-8 string:
```javascript
const result = await redis.getBuffer("foo");
// result is `<Buffer 62 75 66>`
```
It's worth noticing that you don't need the `Buffer` suffix variant in order to **send** binary data. That means
in most case you should just use `redis.set()` instead of `redis.setBuffer()` unless you want to get the old value
with the `GET` parameter:
```javascript
const result = await redis.setBuffer("foo", "new value", "GET");
// result is `<Buffer 62 75 66>` as `GET` indicates returning the old value.
```
## Pipelining
If you want to send a batch of commands (e.g. > 5), you can use pipelining to queue
the commands in memory and then send them to Redis all at once. This way the performance improves by 50%~300% (See [benchmark section](#benchmarks)).
`redis.pipeline()` creates a `Pipeline` instance. You can call any Redis
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
const pipeline = redis.pipeline();
pipeline.set("foo", "bar");
pipeline.del("cc");
pipeline.exec((err, results) => {
// `err` is always null, and `results` is an array of responses
// corresponding to the sequence of queued commands.
// Each response follows the format `[err, result]`.
});
// You can even chain the commands:
redis
.pipeline()
.set("foo", "bar")
.del("cc")
.exec((err, results) => {});
// `exec` also returns a Promise:
const promise = redis.pipeline().set("foo", "bar").get("foo").exec();
promise.then((result) => {
// result === [[null, 'OK'], [null, 'bar']]
});
```
Each chained command can also have a callback, which will be invoked when the command
gets a reply:
```javascript
redis
.pipeline()
.set("foo", "bar")
.get("foo", (err, result) => {
// result === 'bar'
})
.exec((err, result) => {
// result[1][1] === 'bar'
});
```
In addition to adding commands to the `pipeline` queue individually, you can also pass an array of commands and arguments to the constructor:
```javascript
redis
.pipeline([
["set", "foo", "bar"],
["get", "foo"],
])
.exec(() => {
/* ... */
});
```
`#length` property shows how many commands in the pipeline:
```javascript
const length = redis.pipeline().set("foo", "bar").get("foo").length;
// length === 2
```
## Transaction
Most of the time, the transaction commands `multi` & `exec` are used together with pipeline.
Therefore, when `multi` is called, a `Pipeline` instance is created automatically by default,
so you can use `multi` just like `pipeline`:
```javascript
redis
.multi()
.set("foo", "bar")
.get("foo")
.exec((err, results) => {
// results === [[null, 'OK'], [null, 'bar']]
});
```
If there's a syntax error in the transaction's command chain (e.g. wrong number of arguments, wrong command name, etc),
then none of the commands would be executed, and an error is returned:
```javascript
redis
.multi()
.set("foo")
.set("foo", "new value")
.exec((err, results) => {
// err:
// { [ReplyError: EXECABORT Transaction discarded because of previous errors.]
// name: 'ReplyError',
// message: 'EXECABORT Transaction discarded because of previous errors.',
// command: { name: 'exec', args: [] },
// previousErrors:
// [ { [ReplyError: ERR wrong number of arguments for 'set' command]
// name: 'ReplyError',
// message: 'ERR wrong number of arguments for \'set\' command',
// command: [Object] } ] }
});
```
In terms of the interface, `multi` differs from `pipeline` in that when specifying a callback
to each chained command, the queueing state is passed to the callback instead of the result of the command:
```javascript
redis
.multi()
.set("foo", "bar", (err, result) => {
// result === 'QUEUED'
})
.exec(/* ... */);
```
If you want to use transaction without pipeline, pass `{ pipeline: false }` to `multi`,
and every command will be sent to Redis immediately without waiting for an `exec` invocation:
```javascript
redis.multi({ pipeline: false });
redis.set("foo", "bar");
redis.get("foo");
redis.exec((err, result) => {
// result === [[null, 'OK'], [null, 'bar']]
});
```
The constructor of `multi` also accepts a batch of commands:
```javascript
redis
.multi([
["set", "foo", "bar"],
["get", "foo"],
])
.exec(() => {
/* ... */
});
```
Inline transactions are supported by pipeline, which means you can group a subset of commands
in the pipeline into a transaction:
```javascript
redis
.pipeline()
.get("foo")
.multi()
.set("foo", "bar")
.get("foo")
.exec()
.get("foo")
.exec();
```
## Lua Scripting
ioredis supports all of the scripting commands such as `EVAL`, `EVALSHA` and `SCRIPT`.
However, it's tedious to use in real world scenarios since developers have to take
care of script caching and to detect when to use `EVAL` and when to use `EVALSHA`.
ioredis exposes a `defineCommand` method to make scripting much easier to use:
```javascript
const redis = new Redis();
// This will define a command myecho:
redis.defineCommand("myecho", {
numberOfKeys: 2,
lua: "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}",
});
// Now `myecho` can be used just like any other ordinary command,
// and ioredis will try to use `EVALSHA` internally when possible for better performance.
redis.myecho("k1", "k2", "a1", "a2", (err, result) => {
// result === ['k1', 'k2', 'a1', 'a2']
});
// `myechoBuffer` is also defined automatically to return buffers instead of strings:
redis.myechoBuffer("k1", "k2", "a1", "a2", (err, result) => {
// result[0] equals to Buffer.from('k1');
});
// And of course it works with pipeline:
redis.pipeline().set("foo", "bar").myecho("k1", "k2", "a1", "a2").exec();
```
### Dynamic Keys
If the number of keys can't be determined when defining a command, you can
omit the `numberOfKeys` property and pass the number of keys as the first argument
when you call the command:
```javascript
redis.defineCommand("echoDynamicKeyNumber", {
lua: "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}",
});
// Now you have to pass the number of keys as the first argument every time
// you invoke the `echoDynamicKeyNumber` command:
redis.echoDynamicKeyNumber(2, "k1", "k2", "a1", "a2", (err, result) => {
// result === ['k1', 'k2', 'a1', 'a2']
});
```
### As Constructor Options
Besides `defineCommand()`, you can also define custom commands with the `scripts` constructor option:
```javascript
const redis = new Redis({
scripts: {
myecho: {
numberOfKeys: 2,
lua: "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}",
},
},
});
```
### TypeScript Usages
You can refer to [the example](examples/typescript/scripts.ts) for how to declare your custom commands.
## Transparent Key Prefixing
This feature allows you to specify a string that will automatically be prepended
to all the keys in a command, which makes it easier to manage your key
namespaces.
**Warning** This feature won't apply to commands like [KEYS](http://redis.io/commands/KEYS) and [SCAN](http://redis.io/commands/scan) that take patterns rather than actual keys([#239](https://github.com/redis/ioredis/issues/239)),
and this feature also won't apply to the replies of commands even if they are key names ([#325](https://github.com/redis/ioredis/issues/325)).
```javascript
const fooRedis = new Redis({ keyPrefix: "foo:" });
fooRedis.set("bar", "baz"); // Actually sends SET foo:bar baz
fooRedis.defineCommand("myecho", {
numberOfKeys: 2,
lua: "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}",
});
// Works well with pipelining/transaction
fooRedis
.pipeline()
// Sends SORT foo:list BY foo:weight_*->fieldname
.sort("list", "BY", "weight_*->fieldname")
// Supports custom commands
// Sends EVALSHA xxx foo:k1 foo:k2 a1 a2
.myecho("k1", "k2", "a1", "a2")
.exec();
```
## Transforming Arguments & Replies
Most Redis commands take one or more Strings as arguments,
and replies are sent back as a single String or an Array of Strings. However, sometimes
you may want something different. For instance, it would be more convenient if the `HGETALL`
command returns a hash (e.g. `{ key: val1, key2: v2 }`) rather than an array of key values (e.g. `[key1, val1, key2, val2]`).
ioredis has a flexible system for transforming arguments and replies. There are two types
of transformers, argument transformer and reply transformer:
```javascript
const Redis = require("ioredis");
// Here's the built-in argument transformer converting
// hmset('key', { k1: 'v1', k2: 'v2' })
// or
// hmset('key', new Map([['k1', 'v1'], ['k2', 'v2']]))
// into
// hmset('key', 'k1', 'v1', 'k2', 'v2')
Redis.Command.setArgumentTransformer("hmset", (args) => {
if (args.length === 2) {
if (args[1] instanceof Map) {
// utils is a internal module of ioredis
return [args[0], ...utils.convertMapToArray(args[1])];
}
if (typeof args[1] === "object" && args[1] !== null) {
return [args[0], ...utils.convertObjectToArray(args[1])];
}
}
return args;
});
// Here's the built-in reply transformer converting the HGETALL reply
// ['k1', 'v1', 'k2', 'v2']
// into
// { k1: 'v1', 'k2': 'v2' }
Redis.Command.setReplyTransformer("hgetall", (result) => {
if (Array.isArray(result)) {
const obj = {};
for (let i = 0; i < result.length; i += 2) {
obj[result[i]] = result[i + 1];
}
return obj;
}
return result;
});
```
There are three built-in transformers, two argument transformers for `hmset` & `mset` and
a reply transformer for `hgetall`. Transformers for `hmset` and `hgetall` were mentioned
above, and the transformer for `mset` is similar to the one for `hmset`:
```javascript
redis.mset({ k1: "v1", k2: "v2" });
redis.get("k1", (err, result) => {
// result === 'v1';
});
redis.mset(
new Map([
["k3", "v3"],
["k4", "v4"],
])
);
redis.get("k3", (err, result) => {
// result === 'v3';
});
```
Another useful example of a reply transformer is one that changes `hgetall` to return array of arrays instead of objects which avoids an unwanted conversation of hash keys to strings when dealing with binary hash keys:
```javascript
Redis.Command.setReplyTransformer("hgetall", (result) => {
const arr = [];
for (let i = 0; i < result.length; i += 2) {
arr.push([result[i], result[i + 1]]);
}
return arr;
});
redis.hset("h1", Buffer.from([0x01]), Buffer.from([0x02]));
redis.hset("h1", Buffer.from([0x03]), Buffer.from([0x04]));
redis.hgetallBuffer("h1", (err, result) => {
// result === [ [ <Buffer 01>, <Buffer 02> ], [ <Buffer 03>, <Buffer 04> ] ];
});
```
## Monitor
Redis supports the MONITOR command,
which lets you see all commands received by the Redis server across all client connections,
including from other client libraries and other computers.
The `monitor` method returns a monitor instance.
After you send the MONITOR command, no other commands are valid on that connection. ioredis will emit a monitor event for every new monitor message that comes across.
The callback for the monitor event takes a timestamp from the Redis server and an array of command arguments.
Here is a simple example:
```javascript
redis.monitor((err, monitor) => {
monitor.on("monitor", (time, args, source, database) => {});
});
```
Here is another example illustrating an `async` function and `monitor.disconnect()`:
```javascript
async () => {
const monitor = await redis.monitor();
monitor.on("monitor", console.log);
// Any other tasks
monitor.disconnect();
};
```
## Streamify Scanning
Redis 2.8 added the `SCAN` command to incrementally iterate through the keys in the database. It's different from `KEYS` in that
`SCAN` only returns a small number of elements each call, so it can be used in production without the downside
of blocking the server for a long time. However, it requires recording the cursor on the client side each time
the `SCAN` command is called in order to iterate through all the keys correctly. Since it's a relatively common use case, ioredis
provides a streaming interface for the `SCAN` command to make things much easier. A readable stream can be created by calling `scanStream`:
```javascript
const redis = new Redis();
// Create a readable stream (object mode)
const stream = redis.scanStream();
stream.on("data", (resultKeys) => {
// `resultKeys` is an array of strings representing key names.
// Note that resultKeys may contain 0 keys, and that it will sometimes
// contain duplicates due to SCAN's implementation in Redis.
for (let i = 0; i < resultKeys.length; i++) {
console.log(resultKeys[i]);
}
});
stream.on("end", () => {
console.log("all keys have been visited");
});
```
`scanStream` accepts an option, with which you can specify the `MATCH` pattern, the `TYPE` filter, and the `COUNT` argument:
```javascript
const stream = redis.scanStream({
// only returns keys following the pattern of `user:*`
match: "user:*",
// only return objects that match a given type,
// (requires Redis >= 6.0)
type: "zset",
// returns approximately 100 elements per call
count: 100,
});
```
Just like other commands, `scanStream` has a binary version `scanBufferStream`, which returns an array of buffers. It's useful when
the key names are not utf8 strings.
There are also `hscanStream`, `zscanStream` and `sscanStream` to iterate through elements in a hash, zset and set. The interface of each is
similar to `scanStream` except the first argument is the key name:
```javascript
const stream = redis.zscanStream("myhash", {
match: "age:??",
});
```
The `hscanStream` also accepts the `noValues` option to specify whether Redis should return only the keys in the hash table without their corresponding values.
```javascript
const stream = redis.hscanStream("myhash", {
match: "age:??",
noValues: true,
});
```
You can learn more from the [Redis documentation](http://redis.io/commands/scan).
**Useful Tips**
It's pretty common that doing an async task in the `data` handler. We'd like the scanning process to be paused until the async task to be finished. `Stream#pause()` and `Stream#resume()` do the trick. For example if we want to migrate data in Redis to MySQL:
```javascript
const stream = redis.scanStream();
stream.on("data", (resultKeys) => {
// Pause the stream from scanning more keys until we've migrated the current keys.
stream.pause();
Promise.all(resultKeys.map(migrateKeyToMySQL)).then(() => {
// Resume the stream here.
stream.resume();
});
});
stream.on("end", () => {
console.log("done migration");
});
```
## Auto-reconnect
By default, ioredis will try to reconnect when the connection to Redis is lost
except when the connection is closed manually by `redis.disconnect()` or `redis.quit()`.
It's very flexible to control how long to wait to reconnect after disconnection
using the `retryStrategy` option:
```javascript
const redis = new Redis({
// This is the default value of `retryStrategy`
retryStrategy(times) {
const delay = Math.min(times * 50, 2000);
return delay;
},
});
```
`retryStrategy` is a function that will be called when the connection is lost.
The argument `times` means this is the nth reconnection being made and
the return value represents how long (in ms) to wait to reconnect. When the
return value isn't a number, ioredis will stop trying to reconnect, and the connection
will be lost forever if the user doesn't call `redis.connect()` manually.
When reconnected, the client will auto subscribe to channels that the previous connection subscribed to.
This behavior can be disabled by setting the `autoResubscribe` option to `false`.
And if the previous connection has some unfulfilled commands (most likely blocking commands such as `brpop` and `blpop`),
the client will resend them when reconnected. This behavior can be disabled by setting the `autoResendUnfulfilledCommands` option to `false`.
By default, all pending commands will be flushed with an error every 20 retry attempts. That makes sure commands won't wait forever when the connection is down. You can change this behavior by setting `maxRetriesPerRequest`:
```javascript
const redis = new Redis({
maxRetriesPerRequest: 1,
});
```
Set maxRetriesPerRequest to `null` to disable this behavior, and every command will wait forever until the connection is alive again (which is the default behavior before ioredis v4).
### Blocking Command Timeout
ioredis can apply a client-side timeout to blocking commands (such as `blpop`, `brpop`, `bzpopmin`, `bzmpop`, `blmpop`, `xread`, `xreadgroup`, etc.). This protects against scenarios where the TCP connection becomes a zombie (e.g., due to a silent network failure like a Docker network disconnect) and Redis never replies.
This feature is **opt-in**. It is **disabled by default** and is only enabled
when `blockingTimeout` is set to a positive number of milliseconds. If
`blockingTimeout` is omitted, `0`, or negative (for example `-1`), ioredis
does not arm any client-side timeouts for blocking commands and their
behavior matches Redis exactly.
```javascript
const redis = new Redis({
blockingTimeout: 30000, // Enable blocking timeout protection
});
```
When enabled:
- For commands with a finite timeout (e.g., `blpop("key", 5)`), ioredis sets a client-side deadline based on the command's timeout plus a small grace period (`blockingTimeoutGrace`, default 100ms). If no reply arrives before the deadline, the command resolves with `null`—the same value Redis returns when a blocking command times out normally.
- For commands that block forever (e.g., `timeout = 0` or `BLOCK 0`), the `blockingTimeout` value is used as a safety net.
### Reconnect on Error
Besides auto-reconnect when the connection is closed, ioredis supports reconnecting on certain Redis errors using the `reconnectOnError` option. Here's an example that will reconnect when receiving `READONLY` error:
```javascript
const redis = new Redis({
reconnectOnError(err) {
const targetError = "READONLY";
if (err.message.includes(targetError)) {
// Only reconnect when the error contains "READONLY"
return true; // or `return 1;`
}
},
});
```
This feature is useful when using Amazon ElastiCache instances with Auto-failover disabled. On these instances, test your `reconnectOnError` handler by manually promoting the replica node to the primary role using the AWS console. The following writes fail with the error `READONLY`. Using `reconnectOnError`, we can force the connection to reconnect on this error in order to connect to the new master. Furthermore, if the `reconnectOnError` returns `2`, ioredis will resend the failed command after reconnecting.
On ElastiCache instances with Auto-failover enabled, `reconnectOnError` does not execute. Instead of returning a Redis error, AWS closes all connections to the master endpoint until the new primary node is ready. ioredis reconnects via `retryStrategy` instead of `reconnectOnError` after about a minute. On ElastiCache instances with Auto-failover enabled, test failover events with the `Failover primary` option in the AWS console.
## Connection Events
The Redis instance will emit some events about the state of the connection to the Redis server.
| Event | Description |
| :----------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| connect | emits when a connection is established to the Redis server. |
| ready | If `enableReadyCheck` is `true`, client will emit `ready` when the server reports that it is ready to receive commands (e.g. finish loading data from disk).<br>Otherwise, `ready` will be emitted immediately right after the `connect` event. |
| error | emits when an error occurs while connecting.<br>However, ioredis emits all `error` events silently (only emits when there's at least one listener) so that your application won't crash if you're not listening to the `error` event.<br>When `redis.connect()` is explicitly called the error will also be rejected from the returned promise, in addition to emitting it. If `redis.connect()` is not called explicitly and `lazyConnect` is true, ioredis will try to connect automatically on the first command and emit the `error` event silently. |
| close | emits when an established Redis server connection has closed. |
| reconnecting | emits after `close` when a reconnection will be made. The argument of the event is the time (in ms) before reconnecting. |
| end | emits after `close` when no more reconnections will be made, or the connection is failed to establish. |
| wait | emits when `lazyConnect` is set and will wait for the first command to be called before connecting. |
You can also check out the `Redis#status` property to get the current connection status.
Besides the above connection events, there are several other custom events:
| Event | Description |
| :----- | :------------------------------------------------------------------ |
| select | emits when the database changed. The argument is the new db number. |
## Offline Queue
When a command can't be processed by Redis (being sent before the `ready` event), by default, it's added to the offline queue and will be
executed when it can be processed. You can disable this feature by setting the `enableOfflineQueue`
option to `false`:
```javascript
const redis = new Redis({ enableOfflineQueue: false });
```
## TLS Options
Redis doesn't support TLS natively, however if the redis server you want to connect to is hosted behind a TLS proxy (e.g. [stunnel](https://www.stunnel.org/)) or is offered by a PaaS service that supports TLS connection (e.g. [Redis.com](https://redis.com/)), you can set the `tls` option:
```javascript
const redis = new Redis({
host: "localhost",
tls: {
// Refer to `tls.connect()` section in
// https://nodejs.org/api/tls.html
// for all supported options
ca: fs.readFileSync("cert.pem"),
},
});
```
Alternatively, specify the connection through a [`rediss://` URL](https://www.iana.org/assignments/uri-schemes/prov/rediss).
```javascript
const redis = new Redis("rediss://redis.my-service.com");
```
If you do not want to use a connection string, you can also specify an empty `tls: {}` object:
```javascript
const redis = new Redis({
host: "redis.my-service.com",
tls: {},
});
```
### TLS Profiles
> **Warning**
> TLS profiles described in this section are going to be deprecated in the next major version. Please provide TLS options explicitly.
To make it easier to configure we provide a few pre-configured TLS profiles that can be specified by setting the `tls` option to the profile's name or specifying a `tls.profile` option in case you need to customize some values of the profile.
Profiles:
- `RedisCloudFixed`: Contains the CA for [Redis.com](https://redis.com/) Cloud fixed subscriptions
- `RedisCloudFlexible`: Contains the CA for [Redis.com](https://redis.com/) Cloud flexible subscriptions
```javascript
const redis = new Redis({
host: "localhost",
tls: "RedisCloudFixed",
});
const redisWithClientCertificate = new Redis({
host: "localhost",
tls: {
profile: "RedisCloudFixed",
key: "123",
},
});
```
<hr>
## Sentinel
ioredis supports Sentinel out of the box. It works transparently as all features that work when
you connect to a single node also work when you connect to a sentinel group. Make sure to run Redis >= 2.8.12 if you want to use this feature. Sentinels have a default port of 26379.
To connect using Sentinel, use:
```javascript
const redis = new Redis({
sentinels: [
{ host: "localhost", port: 26379 },
{ host: "localhost", port: 26380 },
],
name: "mymaster",
});
redis.set("foo", "bar");
```
The arguments passed to the constructor are different from the ones you use to connect to a single node, where:
- `name` identifies a group of Redis instances composed of a master and one or more slaves (`mymaster` in the example);
- `sentinelPassword` (optional) password for Sentinel instances.
- `sentinels` are a list of sentinels to connect to. The list does not need to enumerate all your sentinel instances, but a few so that if one is down the client will try the next one.
- `role` (optional) with a value of `slave` will return a random slave from the Sentinel group.
- `preferredSlaves` (optional) can be used to prefer a particular slave or set of slaves based on priority. It accepts a function or array.
- `enableTLSForSentinelMode` (optional) set to true if connecting to sentinel instances that are encrypted
ioredis **guarantees** that the node you connected to is always a master even after a failover. When a failover happens, instead of trying to reconnect to the failed node (which will be demoted to slave when it's available again), ioredis will ask sentinels for the new master node and connect to it. All commands sent during the failover are queued and will be executed when the new connection is established so that none of the commands will be lost.
It's possible to connect to a slave instead of a master by specifying the option `role` with the value of `slave` and ioredis will try to connect to a random slave of the specified master, with the guarantee that the connected node is always a slave. If the current node is promoted to master due to a failover, ioredis will disconnect from it and ask the sentinels for another slave node to connect to.
If you specify the option `preferredSlaves` along with `role: 'slave'` ioredis will attempt to use this value when selecting the slave from the pool of available slaves. The value of `preferredSlaves` should either be a function that accepts an array of available slaves and returns a single result, or an array of slave values priorities by the lowest `prio` value first with a default value of `1`.
```javascript
// available slaves format
const availableSlaves = [{ ip: "127.0.0.1", port: "31231", flags: "slave" }];
// preferredSlaves array format
let preferredSlaves = [
{ ip: "127.0.0.1", port: "31231", prio: 1 },
{ ip: "127.0.0.1", port: "31232", prio: 2 },
];
// preferredSlaves function format
preferredSlaves = function (availableSlaves) {
for (let i = 0; i < availableSlaves.length; i++) {
const slave = availableSlaves[i];
if (slave.ip === "127.0.0.1") {
if (slave.port === "31234") {
return slave;
}
}
}
// if no preferred slaves are available a random one is used
return false;
};
const redis = new Redis({
sentinels: [
{ host: "127.0.0.1", port: 26379 },
{ host: "127.0.0.1", port: 26380 },
],
name: "mymaster",
role: "slave",
preferredSlaves: preferredSlaves,
});
```
Besides the `retryStrategy` option, there's also a `sentinelRetryStrategy` in Sentinel mode which will be invoked when all the sentinel nodes are unreachable during connecting. If `sentinelRetryStrategy` returns a valid delay time, ioredis will try to reconnect from scratch. The default value of `sentinelRetryStrategy` is:
```javascript
function (times) {
const delay = Math.min(times * 10, 1000);
return delay;
}
```
## Cluster
Redis Cluster provides a way to run a Redis installation where data is automatically sharded across multiple Redis nodes.
You can connect to a Redis Cluster like this:
```javascript
const Redis = require("ioredis");
const cluster = new Redis.Cluster([
{
port: 6380,
host: "127.0.0.1",
},
{
port: 6381,
host: "127.0.0.1",
},
]);
cluster.set("foo", "bar");
cluster.get("foo", (err, res) => {
// res === 'bar'
});
```
`Cluster` constructor accepts two arguments, where:
0. The first argument is a list of nodes of the cluster you want to connect to.
Just like Sentinel, the list does not need to enumerate all your cluster nodes,
but a few so that if one is unreachable the client will try the next one, and the client will discover other nodes automatically when at least one node is connected.
1. The second argument is the options, where:
- `clusterRetryStrategy`: When none of the startup nodes are reachable, `clusterRetryStrategy` will be invoked. When a number is returned,
ioredis will try to reconnect to the startup nodes from scratch after the specified delay (in ms). Otherwise, an error of "None of startup nodes is available" will be returned.
The default value of this option is:
```javascript
function (times) {
const delay = Math.min(100 + times * 2, 2000);
return delay;
}
```
It's possible to modify the `startupNodes` property in order to switch to another set of nodes here:
```javascript
function (times) {
this.startupNodes = [{ port: 6790, host: '127.0.0.1' }];
return Math.min(100 + times * 2, 2000);
}
```
- `dnsLookup`: Alternative DNS lookup function (`dns.lookup()` is used by default). It may be useful to override this in special cases, such as when AWS ElastiCache used with TLS enabled.
- `enableOfflineQueue`: Similar to the `enableOfflineQueue` option of `Redis` class.
- `enableReadyCheck`: When enabled, "ready" event will only be emitted when `CLUSTER INFO` command
reporting the cluster is ready for handling commands. Otherwise, it will be emitted immediately after "connect" is emitted.
- `scaleReads`: Config where to send the read queries. See below for more details.
- `maxRedirections`: When a cluster related error (e.g. `MOVED`, `ASK` and `CLUSTERDOWN` etc.) is received, the client will redirect the
command to another node. This option limits the max redirections allowed when sending a command. The default value is `16`.
- `retryDelayOnFailover`: If the target node is disconnected when sending a command,
ioredis will retry after the specified delay. The default value is `100`. You should make sure `retryDelayOnFailover * maxRedirections > cluster-node-timeout`
to insure that no command will fail during a failover.
- `retryDelayOnClusterDown`: When a cluster is down, all commands will be rejected with the error of `CLUSTERDOWN`. If this option is a number (by default, it is `100`), the client
will resend the commands after the specified time (in ms).
- `retryDelayOnTryAgain`: If this option is a number (by default, it is `100`), the client
will resend the commands rejected with `TRYAGAIN` error after the specified time (in ms).
- `retryDelayOnMoved`: By default, this value is `0` (in ms), which means when a `MOVED` error is received, the client will resend
the command instantly to the node returned together with the `MOVED` error. However, sometimes it takes time for a cluster to become
state stabilized after a failover, so adding a delay before resending can prevent a ping pong effect.
- `redisOptions`: Default options passed to the constructor of `Redis` when connecting to a node.
- `slotsRefreshTimeout`: Milliseconds before a timeout occurs while refreshing slots from the cluster (default `1000`).
- `slotsRefreshInterval`: Milliseconds between every automatic slots refresh (by default, it is disabled).
### Read-Write Splitting
A typical redis cluster contains three or more masters and several slaves for each master. It's possible to scale out redis cluster by sending read queries to slaves and write queries to masters by setting the `scaleReads` option.
`scaleReads` is "master" by default, which means ioredis will never send any queries to slaves. There are other three available options:
1. "all": Send write queries to masters and read queries to masters or slaves randomly.
2. "slave": Send write queries to masters and read queries to slaves.
3. a custom `function(nodes, command): node`: Will choose the custom function to select to which node to send read queries (write queries keep being sent to master). The first node in `nodes` is always the master serving the relevant slots. If the function returns an array of nodes, a random node of that list will be selected.
For example:
```javascript
const cluster = new Redis.Cluster(
[
/* nodes */
],
{
scaleReads: "slave",
}
);
cluster.set("foo", "bar"); // This query will be sent to one of the masters.
cluster.get("foo", (err, res) => {
// This query will be sent to one of the slaves.
});
```
**NB** In the code snippet above, the `res` may not be equal to "bar" because of the lag of replication between the master and slaves.
### Running Commands to Multiple Nodes
Every command will be sent to exactly one node. For commands containing keys, (e.g. `GET`, `SET` and `HGETALL`), ioredis sends them to the node that serving the keys, and for other commands not containing keys, (e.g. `INFO`, `KEYS` and `FLUSHDB`), ioredis sends them to a random node.
Sometimes you may want to send a command to multiple nodes (masters or slaves) of the cluster, you can get the nodes via `Cluster#nodes()` method.
`Cluster#nodes()` accepts a parameter role, which can be "master", "slave" and "all" (default), and returns an array of `Redis` instance. For example:
```javascript
// Send `FLUSHDB` command to all slaves:
const slaves = cluster.nodes("slave");
Promise.all(slaves.map((node) => node.flushdb()));
// Get keys of all the masters:
const masters = cluster.nodes("master");
Promise.all(
masters
.map((node) => node.keys())
.then((keys) => {
// keys: [['key1', 'key2'], ['key3', 'key4']]
})
);
```
### NAT Mapping
Sometimes the cluster is hosted within a internal network that can only be accessed via a NAT (Network Address Translation) instance. See [Accessing ElastiCache from outside AWS](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/accessing-elasticache.html) as an example.
You can specify nat mapping rules via `natMap` option:
```javascript
const cluster = new Redis.Cluster(
[
{
host: "203.0.113.73",
port: 30001,
},
],
{
natMap: {
"10.0.1.230:30001": { host: "203.0.113.73", port: 30001 },
"10.0.1.231:30001": { host: "203.0.113.73", port: 30002 },
"10.0.1.232:30001": { host: "203.0.113.73", port: 30003 },
},
}
);
```
Or you can specify this parameter through function:
```javascript
const cluster = new Redis.Cluster(
[
{
host: "203.0.113.73",
port: 30001,
},
],
{
natMap: (key) => {
if(key.includes('30001')) {
return { host: "203.0.113.73", port: 30001 };
}
return null;
},
}
);
```
This option is also useful when the cluster is running inside a Docker container.
Also it works for Clusters in cloud infrastructure where cluster nodes connected through dedicated subnet.
Specifying through may be useful if you don't know concrete internal host and know only node port.
### Transaction and Pipeline in Cluster Mode
Almost all features that are supported by `Redis` are also supported by `Redis.Cluster`, e.g. custom commands, transaction and pipeline.
However there are some differences when using transaction and pipeline in Cluster mode:
0. All keys in a pipeline should belong to slots served by the same node, since ioredis sends all commands in a pipeline to the same node.
1. You can't use `multi` without pipeline (aka `cluster.multi({ pipeline: false })`). This is because when you call `cluster.multi({ pipeline: false })`, ioredis doesn't know which node the `multi` command should be sent to.
When any commands in a pipeline receives a `MOVED` or `ASK` error, ioredis will resend the whole pipeline to the specified node automatically if all of the following conditions are satisfied:
0. All errors received in the pipeline are the same. For example, we won't resend the pipeline if we got two `MOVED` errors pointing to different nodes.
1. All commands executed successfully are readonly commands. This makes sure that resending the pipeline won't have side effects.
### Pub/Sub
Pub/Sub in cluster mode works exactly as the same as in standalone mode. Internally, when a node of the cluster receives a message, it will broadcast the message to the other nodes. ioredis makes sure that each message will only be received once by strictly subscribing one node at the same time.
```javascript
const nodes = [
/* nodes */
];
const pub = new Redis.Cluster(nodes);
const sub = new Redis.Cluster(nodes);
sub.on("message", (channel, message) => {
console.log(channel, message);
});
sub.subscribe("news", () => {
pub.publish("news", "highlights");
});
```
### Sharded Pub/Sub
For sharded Pub/Sub, use the `spublish` and `ssubscribe` commands instead of the traditional `publish` and `subscribe`. With the old commands, the Redis cluster handles message propagation behind the scenes, allowing you to publish or subscribe to any node without considering sharding. However, this approach has scalability limitations that are addressed with sharded Pub/Sub. Here’s what you need to know:
1. Instead of a single subscriber connection, there is now one subscriber connection per shard. Because of the potential overhead, you can enable or disable the use of the cluster subscriber group with the `shardedSubscribers` option. By default, this option is set to `false`, meaning sharded subscriptions are disabled. You should enable this option when establishing your cluster connection before using `ssubscribe`.
2. All channel names that you pass to a single `ssubscribe` need to map to the same hash slot. You can call `ssubscribe` multiple times on the same cluster client instance to subscribe to channels across slots. The cluster's subscriber group takes care of forwarding the `ssubscribe` command to the shard that is responsible for the channels.
The following basic example shows you how to use sharded Pub/Sub:
```javascript
const cluster: Cluster = new Cluster([{host: host, port: port}], {shardedSubscribers: true});
//Register the callback
cluster.on("smessage", (channel, message) => {
console.log(message);
});
//Subscribe to the channels on the same slot
cluster.ssubscribe("channel{my}:1", "channel{my}:2").then( ( count: number ) => {
console.log(count);
}).catch( (err) => {
console.log(err);
});
//Publish a message
cluster.spublish("channel{my}:1", "This is a test message to my first channel.").then((value: number) => {
console.log("Published a message to channel{my}:1");
});
```
### Events
| Event | Description |
| :----------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| connect | emits when a connection is established to the Redis server. |
| ready | emits when `CLUSTER INFO` reporting the cluster is able to receive commands (if `enableReadyCheck` is `true`) or immediately after `connect` event (if `enableReadyCheck` is false). |
| error | emits when an error occurs while connecting with a property of `lastNodeError` representing the last node error received. This event is emitted silently (only emitting if there's at least one listener). |
| close | emits when an established Redis server connection has closed. |
| reconnecting | emits after `close` when a reconnection will be made. The argument of the event is the time (in ms) before reconnecting. |
| end | emits after `close` when no more reconnections will be made. |
| +node | emits when a new node is connected. |
| -node | emits when a node is disconnected. |
| node error | emits when an error occurs when connecting to a node. The second argument indicates the address of the node. |
### Password
Setting the `password` option to access password-protected clusters:
```javascript
const Redis = require("ioredis");
const cluster = new Redis.Cluster(nodes, {
redisOptions: {
password: "your-cluster-password",
},
});
```
If some of nodes in the cluster using a different password, you should specify them in the first parameter:
```javascript
const Redis = require("ioredis");
const cluster = new Redis.Cluster(
[
// Use password "password-for-30001" for 30001
{ port: 30001, password: "password-for-30001" },
// Don't use password when accessing 30002
{ port: 30002, password: null },
// Other nodes will use "fallback-password"
],
{
redisOptions: {
password: "fallback-password",
},
}
);
```
### Special Note: Aws Elasticache Clusters with TLS
AWS ElastiCache for Redis (Clustered Mode) supports TLS encryption. If you use
this, you may encounter errors with invalid certificates. To resolve this
issue, construct the `Cluster` with the `dnsLookup` option as follows:
```javascript
const cluster = new Redis.Cluster(
[
{
host: "clustercfg.myCluster.abcdefg.xyz.cache.amazonaws.com",
port: 6379,
},
],
{
dnsLookup: (address, callback) => callback(null, address),
redisOptions: {
tls: {},
},
}
);
```
<hr>
## Autopipelining
In standard mode, when you issue multiple commands, ioredis sends them to the server one by one. As described in Redis pipeline documentation, this is a suboptimal use of the network link, especially when such link is not very performant.
The TCP and network overhead negatively affects performance. Commands are stuck in the send queue until the previous ones are correctly delivered to the server. This is a problem known as Head-Of-Line blocking (HOL).
ioredis supports a feature called “auto pipelining”. It can be enabled by setting the option `enableAutoPipelining` to `true`. No other code change is necessary.
In auto pipelining mode, all commands issued during an event loop are enqueued in a pipeline automatically managed by ioredis. At the end of the iteration, the pipeline is executed and thus all commands are sent to the server at the same time.
This feature can dramatically improve throughput and avoids HOL blocking. In our benchmarks, the improvement was between 35% and 50%.
While an automatic pipeline is executing, all new commands will be enqueued in a new pipeline which will be executed as soon as the previous finishes.
When using Redis Cluster, one pipeline per node is created. Commands are assigned to pipelines according to which node serves the slot.
A pipeline will thus contain commands using different slots but that ultimately are assigned to the same node.
Note that the same slot limitation within a single command still holds, as it is a Redis limitation.
### Example of Automatic Pipeline Enqueuing
This sample code uses ioredis with automatic pipeline enabled.
```javascript
const Redis = require("./built");
const http = require("http");
const db = new Redis({ enableAutoPipelining: true });
const server = http.createServer((request, response) => {
const key = new URL(request.url, "https://localhost:3000/").searchParams.get(
"key"
);
db.get(key, (err, value) => {
response.writeHead(200, { "Content-Type": "text/plain" });
response.end(value);
});
});
server.listen(3000);
```
When Node receives requests, it schedules them to be processed in one or more iterations of the events loop.
All commands issued by requests processing during one iteration of the loop will be wrapped in a pipeline automatically created by ioredis.
In the example above, the pipeline will have the following contents:
```
GET key1
GET key2
GET key3
...
GET keyN
```
When all events in the current loop have been processed, the pipeline is executed and thus all commands are sent to the server at the same time.
While waiting for pipeline response from Redis, Node will still be able to process requests. All commands issued by request handler will be enqueued in a new automatically created pipeline. This pipeline will not be sent to the server yet.
As soon as a previous automatic pipeline has received all responses from the server, the new pipeline is immediately sent without waiting for the events loop iteration to finish.
This approach increases the utilization of the network link, reduces the TCP overhead and idle times and therefore improves throughput.
### Benchmarks
Here's some of the results of our tests for a single node.
Each iteration of the test runs 1000 random commands on the server.
| | Samples | Result | Tolerance |
| ------------------------- | ------- | ------------- | --------- |
| default | 1000 | 174.62 op/sec | ± 0.45 % |
| enableAutoPipelining=true | 1500 | 233.33 op/sec | ± 0.88 % |
And here's the same test for a cluster of 3 masters and 3 replicas:
| | Samples | Result | Tolerance |
| ------------------------- | ------- | ------------- | --------- |
| default | 1000 | 164.05 op/sec | ± 0.42 % |
| enableAutoPipelining=true | 3000 | 235.31 op/sec | ± 0.94 % |
# Error Handling
All the errors returned by the Redis server are instances of `ReplyError`, which can be accessed via `Redis`:
```javascript
const Redis = require("ioredis");
const redis = new Redis();
// This command causes a reply error since the SET command requires two arguments.
redis.set("foo", (err) => {
err instanceof Redis.ReplyError;
});
```
This is the error stack of the `ReplyError`:
```
ReplyError: ERR wrong number of arguments for 'set' command
at ReplyParser._parseResult (/app/node_modules/ioredis/lib/parsers/javascript.js:60:14)
at ReplyParser.execute (/app/node_modules/ioredis/lib/parsers/javascript.js:178:20)
at Socket.<anonymous> (/app/node_modules/ioredis/lib/redis/event_handler.js:99:22)
at Socket.emit (events.js:97:17)
at readableAddChunk (_stream_readable.js:143:16)
at Socket.Readable.push (_stream_readable.js:106:10)
at TCP.onread (net.js:509:20)
```
By default, the error stack doesn't make any sense because the whole stack happens in the ioredis
module itself, not in your code. So it's not easy to find out where the error happens in your code.
ioredis provides an option `showFriendlyErrorStack` to solve the problem. When you enable
`showFriendlyErrorStack`, ioredis will optimize the error stack for you:
```javascript
const Redis = require("ioredis");
const redis = new Redis({ showFriendlyErrorStack: true });
redis.set("foo");
```
And the output will be:
```
ReplyError: ERR wrong number of arguments for 'set' command
at Object.<anonymous> (/app/index.js:3:7)
at Module._compile (module.js:446:26)
at Object.Module._extensions..js (module.js:464:10)
at Module.load (module.js:341:32)
at Function.Module._load (module.js:296:12)
at Function.Module.runMain (module.js:487:10)
at startup (node.js:111:16)
at node.js:799:3
```
This time the stack tells you that the error happens on the third line in your code. Pretty sweet!
However, it would decrease the performance significantly to optimize the error stack. So by
default, this option is disabled and can only be used for debugging purposes. You **shouldn't** use this feature in a production environment.
# Running tests
Start a Redis server on 127.0.0.1:6379, and then:
```shell
npm test
```
`FLUSH ALL` will be invoked after each test, so make sure there's no valuable data in it before running tests.
If your testing environment does not let you spin up a Redis server [ioredis-mock](https://github.com/stipsan/ioredis-mock) is a drop-in replacement you can use in your tests. It aims to behave identically to ioredis connected to a Redis server so that your integration tests is easier to write and of better quality.
# Debug
You can set the `DEBUG` env to `ioredis:*` to print debug info:
```shell
$ DEBUG=ioredis:* node app.js
```
# Join in!
I'm happy to receive bug reports, fixes, documentation enhancements, and any other improvements.
And since I'm not a native English speaker, if you find any grammar mistakes in the documentation, please also let me know. :)
# Contributors
This project exists thanks to all the people who contribute:
<a href="https://github.com/redis/ioredis/graphs/contributors"><img src="https://opencollective.com/ioredis/contributors.svg?width=890&showBtn=false" /></a>
# License
MIT
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fluin%2Fioredis?ref=badge_large)
================================================
FILE: benchmarks/autopipelining-cluster.ts
================================================
import { cronometro } from "cronometro";
import { readFileSync } from "fs";
import { join } from "path";
import Cluster from "../lib/cluster";
const numNodes = parseInt(process.env.NODES || "3", 10);
const iterations = parseInt(process.env.ITERATIONS || "10000", 10);
const batchSize = parseInt(process.env.BATCH_SIZE || "1000", 10);
const keys = readFileSync(
join(__dirname, `fixtures/cluster-${numNodes}.txt`),
"utf-8"
).split("\n");
const configuration = Array.from(Array(numNodes), (_, i) => ({
host: "127.0.0.1",
port: 30000 + i + 1,
}));
let cluster;
function command(): string {
const choice = Math.random();
if (choice < 0.3) {
return "ttl";
} else if (choice < 0.6) {
return "exists";
}
return "get";
}
function test() {
const index = Math.floor(Math.random() * keys.length);
return Promise.all(
Array.from(Array(batchSize)).map(() => cluster[command()](keys[index]))
);
}
function after(cb) {
cluster.quit();
cb();
}
cronometro(
{
default: {
test,
before(cb) {
cluster = new Cluster(configuration);
cb();
},
after,
},
"enableAutoPipelining=true": {
test,
before(cb) {
cluster = new Cluster(configuration, { enableAutoPipelining: true });
cb();
},
after,
},
},
{
iterations,
print: { compare: true },
}
);
================================================
FILE: benchmarks/autopipelining-single.ts
================================================
import { cronometro } from "cronometro";
import { readFileSync } from "fs";
import { join } from "path";
import Redis from "../lib/Redis";
const iterations = parseInt(process.env.ITERATIONS || "10000", 10);
const batchSize = parseInt(process.env.BATCH_SIZE || "1000", 10);
const keys = readFileSync(
join(__dirname, "fixtures/cluster-3.txt"),
"utf-8"
).split("\n");
let redis;
function command(): string {
const choice = Math.random();
if (choice < 0.3) {
return "ttl";
} else if (choice < 0.6) {
return "exists";
}
return "get";
}
function test() {
const index = Math.floor(Math.random() * keys.length);
return Promise.all(
Array.from(Array(batchSize)).map(() => redis[command()](keys[index]))
);
}
function after(cb) {
redis.quit();
cb();
}
cronometro(
{
default: {
test,
before(cb) {
redis = new Redis();
cb();
},
after,
},
"enableAutoPipelining=true": {
test,
before(cb) {
redis = new Redis({ enableAutoPipelining: true });
cb();
},
after,
},
},
{
iterations,
print: { compare: true },
}
);
================================================
FILE: benchmarks/dropBuffer.ts
================================================
import { cronometro } from "cronometro";
import Redis from "../lib/Redis";
let redis;
cronometro(
{
default: {
test() {
return redis.set("foo", "bar");
},
before(cb) {
redis = new Redis();
cb();
},
after(cb) {
redis.quit();
cb();
},
},
"dropBufferSupport=true": {
test() {
return redis.set("foo", "bar");
},
before(cb) {
redis = new Redis({ dropBufferSupport: true });
cb();
},
after(cb) {
redis.quit();
cb();
},
},
},
{
print: { compare: true },
}
);
================================================
FILE: benchmarks/errorStack.ts
================================================
import { cronometro } from "cronometro";
import Redis from "../lib/Redis";
let redis;
cronometro(
{
default: {
test() {
return redis.set("foo", "bar");
},
before(cb) {
redis = new Redis();
cb();
},
after(cb) {
redis.quit();
cb();
},
},
"showFriendlyErrorStack=true": {
test() {
return redis.set("foo", "bar");
},
before(cb) {
redis = new Redis({ showFriendlyErrorStack: true });
cb();
},
after(cb) {
redis.quit();
cb();
},
},
},
{
print: { compare: true },
}
);
================================================
FILE: benchmarks/fixtures/generate.ts
================================================
"use strict";
const start = process.hrtime.bigint();
import * as calculateSlot from "cluster-key-slot";
import { writeFileSync } from "fs";
import { join } from "path";
import { v4 as uuid } from "uuid";
// Input parameters
const numKeys = parseInt(process.env.KEYS || "1000000", 10);
const numNodes = parseInt(process.env.NODES || "3", 10);
// Prepare topology
const maxSlot = 16384;
const destination = join(__dirname, `cluster-${numNodes}.txt`);
const counts = Array.from(Array(numNodes), () => 0);
const keys = [];
/*
This algorithm is taken and adapted from Redis source code
See: https://github.com/redis/redis/blob/d9f970d8d3f0b694f1e8915cab6d4eab9cfb2ef1/src/redis-cli.c#L5453
*/
const nodes = []; // This only holds starting slot, since the ending slot can be computed out of the next one
let first = 0;
let cursor = 0;
const slotsPerNode = maxSlot / numNodes;
for (let i = 0; i < numNodes; i++) {
let last = Math.round(cursor + slotsPerNode - 1);
if (last > maxSlot || i === numNodes - 1) {
last = maxSlot - 1;
}
if (last < first) {
last = first;
}
nodes.push(first);
first = last + 1;
cursor += slotsPerNode;
}
// Generate keys and also track slot allocations
for (let i = 0; i < numKeys; i++) {
const key = uuid();
const slot = calculateSlot(key);
const node = nodes.findIndex(
(start, i) => i === numNodes - 1 || (slot >= start && slot < nodes[i + 1])
);
counts[node]++;
keys.push(key);
}
// Save keys
writeFileSync(destination, keys.join("\n"));
// Print summary
console.log(
`Generated ${numKeys} keys in ${(
Number(process.hrtime.bigint() - start) / 1e6
).toFixed(2)} ms `
);
for (let i = 0; i < numNodes; i++) {
const from = nodes[i];
const to = (i === numNodes - 1 ? maxSlot : nodes[i + 1]) - 1;
console.log(
` - Generated ${
counts[i]
} keys for node(s) serving slots ${from}-${to} (${(
(counts[i] * 100) /
numKeys
).toFixed(2)} %)`
);
}
================================================
FILE: benchmarks/fixtures/insert.ts
================================================
import { readFileSync } from "fs";
import { join } from "path";
import Redis from "../../lib";
import Cluster from "../../lib/cluster";
async function main() {
const numNodes = parseInt(process.env.NODES || "3", 10);
let redis;
if (process.env.CLUSTER === "true") {
const configuration = Array.from(Array(numNodes), (_, i) => ({
host: "127.0.0.1",
port: 30000 + i + 1,
}));
redis = new Cluster(configuration);
console.log("Inserting fixtures keys in the cluster ...");
} else {
redis = new Redis();
console.log("Inserting fixtures keys in the server ...");
}
// Use Redis to set the keys
const start = process.hrtime.bigint();
const keys = readFileSync(
join(__dirname, `cluster-${numNodes}.txt`),
"utf-8"
).split("\n");
const keysCount = keys.length;
while (keys.length) {
const promises = [];
for (const key of keys.splice(0, 1000)) {
promises.push(redis.set(key, key));
}
await Promise.all(promises);
}
console.log(
`Inserted ${keysCount} keys in ${(
Number(process.hrtime.bigint() - start) / 1e6
).toFixed(2)} ms.`
);
process.exit(0);
}
main().catch(console.error);
================================================
FILE: bin/argumentTypes.js
================================================
const typeMaps = require("./typeMaps");
module.exports = {
debug: [
[{ name: "subcommand", type: "string" }],
[
{ name: "subcommand", type: "string" },
{ name: "args", type: typeMaps.string("args"), multiple: true },
],
],
};
================================================
FILE: bin/index.js
================================================
const returnTypes = require("./returnTypes");
const argumentTypes = require("./argumentTypes");
const sortArguments = require("./sortArguments");
const typeMaps = require("./typeMaps");
const overrides = require("./overrides");
const { getCommanderInterface } = require("@ioredis/interface-generator");
const HEADER = `/**
* This file is generated by @ioredis/interface-generator.
* Don't edit it manually. Instead, run \`npm run generate\` to update
* this file.
*/
`;
const ignoredCommands = ["monitor", "multi"];
const commands = require("@ioredis/commands")
.list.filter((name) => !ignoredCommands.includes(name))
.sort();
const fs = require("fs");
const path = require("path");
const template = fs.readFileSync(path.join(__dirname, "/template.ts"), "utf8");
async function main() {
const interface = await getCommanderInterface({
commands,
complexityLimit: 50,
redisOpts: {
port: process.env.REDIS_PORT,
},
overrides,
returnTypes,
argumentTypes,
sortArguments,
typeMaps: typeMaps,
ignoredBufferVariant: [
"incrbyfloat",
"type",
"info",
"latency",
"lolwut",
"memory",
"cluster",
"geopos",
],
});
fs.writeFileSync(
path.join(__dirname, "..", "lib/utils/RedisCommander.ts"),
HEADER + template.replace("////", () => interface)
);
}
main()
.catch(console.error)
.then(() => process.exit(0));
================================================
FILE: bin/overrides.js
================================================
const msetOverrides = {
overwrite: false,
defs: [
"$1(object: object, callback?: Callback<'OK'>): Result<'OK', Context>",
"$1(map: Map<string | Buffer | number, string | Buffer | number>, callback?: Callback<'OK'>): Result<'OK', Context>",
],
};
module.exports = {
hgetall: {
overwrite: true,
defs: [
"$1(key: RedisKey, callback?: Callback<Record<string, string>>): Result<Record<string, string>, Context>",
"$1Buffer(key: RedisKey, callback?: Callback<Record<string, Buffer>>): Result<Record<string, Buffer>, Context>",
],
},
mset: msetOverrides,
msetnx: msetOverrides,
hset: {
overwrite: false,
defs: [
"$1(key: RedisKey, object: object, callback?: Callback<number>): Result<number, Context>",
"$1(key: RedisKey, map: Map<string | Buffer | number, string | Buffer | number>, callback?: Callback<number>): Result<number, Context>",
],
},
hmset: {
overwrite: false,
defs: [
"$1(key: RedisKey, object: object, callback?: Callback<'OK'>): Result<'OK', Context>",
"$1(key: RedisKey, map: Map<string | Buffer | number, string | Buffer | number>, callback?: Callback<'OK'>): Result<'OK', Context>",
],
},
exec: {
overwrite: true,
defs: [
"exec(callback?: Callback<[error: Error | null, result: unknown][] | null>): Promise<[error: Error | null, result: unknown][] | null>;",
],
},
};
================================================
FILE: bin/returnTypes.js
================================================
const hasToken = (types, token) => {
if (Array.isArray(token)) return token.some((t) => hasToken(types, t));
return types.find((type) => type.includes(token));
};
const matchSubcommand = (types, subcommand) => {
if (Array.isArray(subcommand))
return subcommand.some((s) => matchSubcommand(types, s));
return types[0].includes(subcommand);
};
module.exports = {
multi: "ChainableCommander",
get: "string | null",
set: (types) => {
if (hasToken(types, "GET")) return "string | null";
if (hasToken(types, ["NX", "XX"])) return "'OK' | null";
return "'OK'";
},
function: (types) => {
if (
matchSubcommand(types, [
"LOAD",
"DELETE",
"DUMP",
"FLUSH",
"KILL",
"RESTORE",
])
) {
return "string";
}
if (matchSubcommand(types, ["LIST"])) {
return "unknown[]";
}
},
ping: (types) => {
return types.length ? "string" : "'PONG'";
},
latency: (types) => {
if (matchSubcommand(types, ["HELP", "LATEST", "HISTORY"])) {
return "unknown[]";
}
if (matchSubcommand(types, "RESET")) {
return "number";
}
if (matchSubcommand(types, ["DOCTOR", "GRAPH"])) {
return "string";
}
},
cluster: (types) => {
if (matchSubcommand(types, "SLOTS")) {
return "[startSlotRange: number, endSlotRange: number, ...nodes: [host: string, port: number, nodeId: string, info: unknown[]][]][]";
}
if (
matchSubcommand(types, [
"ADDSLOTS",
"ADDSLOTSRANGE",
"DELSLOTS",
"DELSLOTSRANGE",
"FAILOVER",
"FLUSHSLOTS",
"FORGET",
"MEET",
"REPLICATE",
"RESET",
"SAVECONFIG",
"SET-CONFIG-EPOCH",
"SETSLOT",
])
) {
return "'OK'";
}
if (matchSubcommand(types, "BUMPEPOCH")) {
return "'BUMPED' | 'STILL'";
}
if (
matchSubcommand(types, [
"COUNT-FAILURE-REPORTS",
"COUNTKEYSINSLOT",
"KEYSLOT",
])
) {
return "number";
}
if (matchSubcommand(types, "GETKEYSINSLOT")) {
return "string[]";
}
if (matchSubcommand(types, ["INFO", "MYID"])) {
return "string";
}
if (matchSubcommand(types, "LINKS")) {
return "unknown[]";
}
},
append: "number",
asking: "'OK'",
auth: "'OK'",
bgrewriteaof: "string",
bgsave: "'OK'",
bitcount: "number",
bitfield_ro: "unknown[]",
bitop: "number",
bitpos: "number",
blpop: "[string, string] | null",
brpop: "[string, string] | null",
brpoplpush: "string | null",
blmove: "string | null",
lmpop: "[key: string, members: string[]] | null",
blmpop: "[key: string, members: string[]] | null",
bzpopmin: "[key: string, member: string, score: string] | null",
bzpopmax: "[key: string, member: string, score: string] | null",
command: "unknown[]",
copy: "number",
dbsize: "number",
decr: "number",
decrby: "number",
del: "number",
discard: "'OK'",
dump: "string",
echo: "string",
exec: "[error: Error, result: unknown][] | null",
exists: "number",
expire: "number",
expireat: "number",
expiretime: "number",
failover: "'OK'",
flushall: "'OK'",
flushdb: "'OK'",
geoadd: "number",
geohash: "string[]",
geopos: "([longitude: string, latitude: string] | null)[]",
geodist: "string | null",
georadius: "unknown[]",
geosearch: "unknown[]",
geosearchstore: "number",
getbit: "number",
getdel: "string | null",
getex: "string | null",
getrange: "string",
getset: "string | null",
hdel: "number",
hello: "unknown[]",
hexists: "number",
hexpire: "number[]",
hpexpire: "number[]",
hget: "string | null",
hgetall: "[field: string, value: string][]",
hincrby: "number",
hincrbyfloat: "string",
hkeys: "string[]",
hlen: "number",
hmget: "(string | null)[]",
hmset: "'OK'",
hset: "number",
hsetnx: "number",
acl: (types) => {
if (matchSubcommand(types, "SAVE")) return '"OK"';
if (matchSubcommand(types, "DELUSER")) return "number";
if (matchSubcommand(types, "WHOAMI")) return "string";
if (matchSubcommand(types, "DRYRUN")) return "string";
if (matchSubcommand(types, "GENPASS")) return "string";
if (matchSubcommand(types, "GETUSER")) return "string[] | null";
if (matchSubcommand(types, "LIST")) return "string[]";
if (matchSubcommand(types, "USERS")) return "string[]";
if (matchSubcommand(types, "LOAD")) return '"OK"';
if (matchSubcommand(types, "SETUSER")) return '"OK"';
},
client: (types) => {
if (matchSubcommand(types, "CACHING")) return '"OK"';
if (matchSubcommand(types, "PAUSE")) return '"OK"';
if (matchSubcommand(types, "UNPAUSE")) return '"OK"';
if (matchSubcommand(types, "SETNAME")) return '"OK"';
if (matchSubcommand(types, "GETNAME")) return "string | null";
if (matchSubcommand(types, "GETREDIR")) return "number";
if (matchSubcommand(types, "INFO")) return "string";
if (matchSubcommand(types, "ID")) return "number";
},
memory: (types) => {
if (matchSubcommand(types, "MALLOC-STATS")) return "string";
if (matchSubcommand(types, "PURGE")) return '"OK"';
if (matchSubcommand(types, "HELP")) return "unknown[]";
if (matchSubcommand(types, "STATS")) return "unknown[]";
if (matchSubcommand(types, "USAGE")) return "number | null";
if (matchSubcommand(types, "DOCTOR")) return "string";
},
hrandfield: "string | unknown[] | null",
hstrlen: "number",
hvals: "string[]",
incr: "number",
incrby: "number",
incrbyfloat: "string",
info: "string",
lolwut: "string",
keys: "string[]",
lastsave: "number",
lindex: "string | null",
linsert: "number",
llen: "number",
lpop: (types) => {
return types.some((type) => type.includes("number"))
? "string[] | null"
: "string | null";
},
lpos: (types) => {
return hasToken(types, "COUNT") ? "number[]" : "number | null";
},
lpush: "number",
lpushx: "number",
lrange: "string[]",
lrem: "number",
lset: "'OK'",
ltrim: "'OK'",
mget: "(string | null)[]",
migrate: "'OK'",
move: "number",
mset: "'OK'",
msetnx: "number",
persist: "number",
pexpire: "number",
pexpireat: "number",
pexpiretime: "number",
pfadd: "number",
pfcount: "number",
pfmerge: "'OK'",
pubsub: "unknown[]",
pttl: "number",
publish: "number",
quit: "'OK'",
randomkey: "string | null",
readonly: "'OK'",
readwrite: "'OK'",
rename: "'OK'",
renamenx: "number",
reset: "'OK'",
restore: "'OK'",
role: "unknown[]",
rpop: (types) => {
return types.some((type) => type.includes("number"))
? "string[] | null"
: "string | null";
},
rpoplpush: "string",
lmove: "string",
rpush: "number",
rpushx: "number",
sadd: "number",
save: "'OK'",
scard: "number",
sdiff: "string[]",
sdiffstore: "number",
select: "'OK'",
setbit: "number",
setex: "'OK'",
setnx: "number",
setrange: "number",
shutdown: "'OK'",
sinter: "string[]",
sintercard: "number",
sinterstore: "number",
sismember: "number",
smismember: "number[]",
slaveof: "'OK'",
replicaof: "'OK'",
smembers: "string[]",
smove: "number",
sort: "number" | "unknown[]",
sortRo: "unknown[]",
spop: (types) => (types.length > 1 ? "string[]" : "string | null"),
srandmember: (types) => (types.length > 1 ? "string[]" : "string | null"),
srem: "number",
strlen: "number",
sunion: "string[]",
sunionstore: "number",
swapdb: "'OK'",
time: "number[]",
touch: "number",
ttl: "number",
type: "string",
unlink: "number",
unwatch: "'OK'",
wait: "number",
watch: "'OK'",
zadd: (types) => {
if (types.find((type) => type.includes("INCR"))) {
if (types.find((type) => type.includes("XX") || type.includes("NX"))) {
return "string | null";
}
return "string";
}
return "number";
},
zcard: "number",
zcount: "number",
zdiff: "string[]",
zdiffstore: "number",
zincrby: "string",
zinter: "string[]",
zintercard: "number",
zinterstore: "number",
zlexcount: "number",
zpopmax: "string[]",
zpopmin: "string[]",
zrandmember: (types) => {
return types.some((type) => type.includes("number"))
? "string[]"
: "string | null";
},
zrangestore: "number",
zrange: "string[]",
zrangebylex: "string[]",
zrevrangebylex: "string[]",
zrangebyscore: "string[]",
zrank: "number | null",
zrem: "number",
zremrangebylex: "number",
zremrangebyrank: "number",
zremrangebyscore: "number",
zrevrange: "string[]",
zrevrangebyscore: "string[]",
zrevrank: "number | null",
zscore: "string | null",
zunion: "string[]",
zmscore: "(string | null)[]",
zunionstore: "number",
scan: "[cursor: string, elements: string[]]",
sscan: "[cursor: string, elements: string[]]",
hscan: "[cursor: string, elements: string[]]",
zscan: "[cursor: string, elements: string[]]",
xadd: "string | null",
xtrim: "number",
xdel: "number",
xrange: "[id: string, fields: string[]][]",
xrevrange: "[id: string, fields: string[]][]",
xlen: "number",
xread: "[key: string, items: [id: string, fields: string[]][]][] | null",
xreadgroup: "unknown[]",
xack: "number",
xclaim: "unknown[]",
xautoclaim: "unknown[]",
xpending: "unknown[]",
};
================================================
FILE: bin/sortArguments.js
================================================
module.exports = {
set: (args) => {
const sorted = args.sort((a, b) => {
const order = ["key", "value", "expiration", "condition", "get"];
const indexA = order.indexOf(a.name);
const indexB = order.indexOf(b.name);
if (indexA === -1) {
throw new Error('Invalid argument name: "' + a.name + '"');
}
if (indexB === -1) {
throw new Error('Invalid argument name: "' + b.name + '"');
}
return indexA - indexB;
});
return sorted;
},
};
================================================
FILE: bin/template.ts
================================================
import { Callback } from "../types";
export type RedisKey = string | Buffer;
export type RedisValue = string | Buffer | number;
// Inspired by https://github.com/mmkal/handy-redis/blob/main/src/generated/interface.ts.
// Should be fixed with https://github.com/Microsoft/TypeScript/issues/1213
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface ResultTypes<Result, Context> {
default: Promise<Result>;
pipeline: ChainableCommander;
}
export interface ChainableCommander
extends RedisCommander<{ type: "pipeline" }> {
length: number;
}
export type ClientContext = { type: keyof ResultTypes<unknown, unknown> };
export type Result<T, Context extends ClientContext> =
// prettier-break
ResultTypes<T, Context>[Context["type"]];
interface RedisCommander<Context extends ClientContext = { type: "default" }> {
/**
* Call arbitrary commands.
*
* `redis.call('set', 'foo', 'bar')` is the same as `redis.set('foo', 'bar')`,
* so the only case you need to use this method is when the command is not
* supported by ioredis.
*
* ```ts
* redis.call('set', 'foo', 'bar');
* redis.call('get', 'foo', (err, value) => {
* // value === 'bar'
* });
* ```
*/
call(command: string, callback?: Callback<unknown>): Result<unknown, Context>;
call(
command: string,
args: (string | Buffer | number)[],
callback?: Callback<unknown>
): Result<unknown, Context>;
call(
...args: [
command: string,
...args: (string | Buffer | number)[],
callback: Callback<unknown>
]
): Result<unknown, Context>;
call(
...args: [command: string, ...args: (string | Buffer | number)[]]
): Result<unknown, Context>;
callBuffer(
command: string,
callback?: Callback<unknown>
): Result<unknown, Context>;
callBuffer(
command: string,
args: (string | Buffer | number)[],
callback?: Callback<unknown>
): Result<unknown, Context>;
callBuffer(
...args: [
command: string,
...args: (string | Buffer | number)[],
callback: Callback<unknown>
]
): Result<unknown, Context>;
callBuffer(
...args: [command: string, ...args: (string | Buffer | number)[]]
): Result<unknown, Context>;
////
}
export default RedisCommander;
================================================
FILE: bin/typeMaps.js
================================================
module.exports = {
key: "RedisKey",
string: (name) =>
[
"value",
"member",
"element",
"arg",
"id",
"pivot",
"threshold",
"start",
"end",
"max",
"min",
].some((pattern) => name.toLowerCase().includes(pattern))
? "string | Buffer | number"
: "string | Buffer",
pattern: "string",
number: () => "number | string",
};
================================================
FILE: docs/.nojekyll
================================================
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
================================================
FILE: docs/assets/highlight.css
================================================
:root {
--light-hl-0: #001080;
--dark-hl-0: #9CDCFE;
--light-hl-1: #000000;
--dark-hl-1: #D4D4D4;
--light-hl-2: #795E26;
--dark-hl-2: #DCDCAA;
--light-hl-3: #A31515;
--dark-hl-3: #CE9178;
--light-hl-4: #0000FF;
--dark-hl-4: #569CD6;
--light-hl-5: #008000;
--dark-hl-5: #6A9955;
--light-hl-6: #0070C1;
--dark-hl-6: #4FC1FF;
--light-hl-7: #AF00DB;
--dark-hl-7: #C586C0;
--light-hl-8: #098658;
--dark-hl-8: #B5CEA8;
--light-code-background: #F5F5F5;
--dark-code-background: #1E1E1E;
}
@media (prefers-color-scheme: light) { :root {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--code-background: var(--light-code-background);
} }
@media (prefers-color-scheme: dark) { :root {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--code-background: var(--dark-code-background);
} }
body.light {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--code-background: var(--light-code-background);
}
body.dark {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--code-background: var(--dark-code-background);
}
.hl-0 { color: var(--hl-0); }
.hl-1 { color: var(--hl-1); }
.hl-2 { color: var(--hl-2); }
.hl-3 { color: var(--hl-3); }
.hl-4 { color: var(--hl-4); }
.hl-5 { color: var(--hl-5); }
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
.hl-8 { color: var(--hl-8); }
pre, code { background: var(--code-background); }
================================================
FILE: docs/assets/icons.css
================================================
.tsd-kind-icon {
display: block;
position: relative;
padding-left: 20px;
text-indent: -20px;
}
.tsd-kind-icon:before {
content: "";
display: inline-block;
vertical-align: middle;
width: 17px;
height: 17px;
margin: 0 3px 2px 0;
background-image: url(./icons.png);
}
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
.tsd-kind-icon:before {
background-image: url(./icons@2x.png);
background-size: 238px 204px;
}
}
.tsd-signature.tsd-kind-icon:before {
background-position: 0 -153px;
}
.tsd-kind-object-literal > .tsd-kind-icon:before {
background-position: 0px -17px;
}
.tsd-kind-object-literal.tsd-is-protected > .tsd-kind-icon:before {
background-position: -17px -17px;
}
.tsd-kind-object-literal.tsd-is-private > .tsd-kind-icon:before {
background-position: -34px -17px;
}
.ts
gitextract_79gv0u86/ ├── .eslintrc.json ├── .github/ │ ├── CONTRIBUTING.md │ ├── FUNDING.yml │ ├── stale.yml │ └── workflows/ │ ├── manual.yml │ ├── push-requests.yml │ ├── release.yml │ ├── stale-issues.yml │ ├── test.yml │ └── test_with_cov.yml ├── .gitignore ├── .prettierignore ├── .releaserc.json ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── benchmarks/ │ ├── autopipelining-cluster.ts │ ├── autopipelining-single.ts │ ├── dropBuffer.ts │ ├── errorStack.ts │ └── fixtures/ │ ├── generate.ts │ └── insert.ts ├── bin/ │ ├── argumentTypes.js │ ├── index.js │ ├── overrides.js │ ├── returnTypes.js │ ├── sortArguments.js │ ├── template.ts │ └── typeMaps.js ├── docs/ │ ├── .nojekyll │ ├── assets/ │ │ ├── highlight.css │ │ ├── icons.css │ │ ├── main.js │ │ ├── search.js │ │ └── style.css │ ├── classes/ │ │ ├── Cluster.html │ │ └── Redis.html │ ├── index.html │ └── interfaces/ │ ├── ChainableCommander.html │ ├── ClusterOptions.html │ ├── CommonRedisOptions.html │ ├── SentinelAddress.html │ └── SentinelConnectionOptions.html ├── examples/ │ ├── basic_operations.js │ ├── custom_connector.js │ ├── express/ │ │ ├── README.md │ │ ├── app.js │ │ ├── bin/ │ │ │ └── www │ │ ├── package.json │ │ ├── public/ │ │ │ └── stylesheets/ │ │ │ └── style.css │ │ ├── redis.js │ │ ├── routes/ │ │ │ ├── index.js │ │ │ └── users.js │ │ └── views/ │ │ ├── error.jade │ │ ├── index.jade │ │ ├── layout.jade │ │ └── users.jade │ ├── hash.js │ ├── list.js │ ├── module.js │ ├── redis_streams.js │ ├── set.js │ ├── stream.js │ ├── string.js │ ├── ttl.js │ ├── typescript/ │ │ ├── package.json │ │ └── scripts.ts │ └── zset.js ├── lib/ │ ├── Command.ts │ ├── DataHandler.ts │ ├── Pipeline.ts │ ├── Redis.ts │ ├── ScanStream.ts │ ├── Script.ts │ ├── SubscriptionSet.ts │ ├── autoPipelining.ts │ ├── cluster/ │ │ ├── ClusterOptions.ts │ │ ├── ClusterSubscriber.ts │ │ ├── ClusterSubscriberGroup.ts │ │ ├── ConnectionPool.ts │ │ ├── DelayQueue.ts │ │ ├── ShardedSubscriber.ts │ │ ├── index.ts │ │ └── util.ts │ ├── connectors/ │ │ ├── AbstractConnector.ts │ │ ├── ConnectorConstructor.ts │ │ ├── SentinelConnector/ │ │ │ ├── FailoverDetector.ts │ │ │ ├── SentinelIterator.ts │ │ │ ├── index.ts │ │ │ └── types.ts │ │ ├── StandaloneConnector.ts │ │ └── index.ts │ ├── constants/ │ │ └── TLSProfiles.ts │ ├── errors/ │ │ ├── ClusterAllFailedError.ts │ │ ├── MaxRetriesPerRequestError.ts │ │ └── index.ts │ ├── index.ts │ ├── redis/ │ │ ├── RedisOptions.ts │ │ └── event_handler.ts │ ├── transaction.ts │ ├── types.ts │ └── utils/ │ ├── Commander.ts │ ├── RedisCommander.ts │ ├── applyMixin.ts │ ├── argumentParsers.ts │ ├── debug.ts │ ├── index.ts │ └── lodash.ts ├── package.json ├── test/ │ ├── cluster/ │ │ ├── basic.ts │ │ ├── cluster_subscriber_group.ts │ │ └── docker/ │ │ ├── Dockerfile │ │ └── main.sh │ ├── docker-compose.yml │ ├── functional/ │ │ ├── auth.ts │ │ ├── autopipelining.ts │ │ ├── blocking_timeout.ts │ │ ├── client_info.ts │ │ ├── cluster/ │ │ │ ├── ClusterSubscriber.ts │ │ │ ├── ask.ts │ │ │ ├── autopipelining.ts │ │ │ ├── clusterdown.ts │ │ │ ├── connect.ts │ │ │ ├── disconnection.ts │ │ │ ├── dnsLookup.ts │ │ │ ├── duplicate.ts │ │ │ ├── index.ts │ │ │ ├── maxRedirections.ts │ │ │ ├── moved.ts │ │ │ ├── nat.ts │ │ │ ├── pipeline.ts │ │ │ ├── pub_sub.ts │ │ │ ├── quit.ts │ │ │ ├── resolveSrv.ts │ │ │ ├── scripting.ts │ │ │ ├── spub_ssub.ts │ │ │ ├── tls.ts │ │ │ ├── transaction.ts │ │ │ └── tryagain.ts │ │ ├── commandTimeout.ts │ │ ├── commands/ │ │ │ ├── hexpireat.ts │ │ │ ├── hexpiretime.ts │ │ │ ├── hgetdel.ts │ │ │ ├── hgetex.ts │ │ │ ├── hpersist.ts │ │ │ ├── hpexpireat.ts │ │ │ ├── hpexpiretime.ts │ │ │ ├── hpttl.ts │ │ │ ├── hsetex.ts │ │ │ ├── httl.ts │ │ │ ├── xdelex.ts │ │ │ └── xtrim.ts │ │ ├── connection.ts │ │ ├── disconnection.ts │ │ ├── duplicate.ts │ │ ├── elasticache.ts │ │ ├── exports.ts │ │ ├── fatal_error.ts │ │ ├── hexpire.ts │ │ ├── hgetall.ts │ │ ├── hpexpire.ts │ │ ├── lazy_connect.ts │ │ ├── maxRetriesPerRequest.ts │ │ ├── monitor.ts │ │ ├── pipeline.ts │ │ ├── pub_sub.ts │ │ ├── ready_check.ts │ │ ├── reconnect_on_error.ts │ │ ├── scan_stream.ts │ │ ├── scripting.ts │ │ ├── select.ts │ │ ├── send_command.ts │ │ ├── sentinel.ts │ │ ├── sentinel_nat.ts │ │ ├── show_friendly_error_stack.ts │ │ ├── socketTimeout.ts │ │ ├── spub_ssub.ts │ │ ├── string_numbers.ts │ │ ├── tls.ts │ │ ├── transaction.ts │ │ ├── transformer.ts │ │ └── watch-exec.ts │ ├── helpers/ │ │ ├── global.ts │ │ ├── mock_server.ts │ │ └── util.ts │ ├── scenario/ │ │ ├── sharded-pub-sub/ │ │ │ ├── basic.test.ts │ │ │ ├── connection-lifecycle.test.ts │ │ │ ├── failure-recovery.multi.test.ts │ │ │ └── failure-recovery.single.test.ts │ │ └── utils/ │ │ ├── command-runner.ts │ │ ├── fault-injector.ts │ │ ├── message-tracker.ts │ │ └── test.util.ts │ ├── typing/ │ │ ├── commands.test-d.ts │ │ ├── events.test-.ts │ │ ├── options.test-d.ts │ │ ├── pipeline.test-d.ts │ │ └── transformers.test-d.ts │ └── unit/ │ ├── DataHandler.ts │ ├── autoPipelining.ts │ ├── clusters/ │ │ ├── ConnectionPool.ts │ │ └── index.ts │ ├── command.ts │ ├── commander.ts │ ├── connectors/ │ │ ├── SentinelConnector/ │ │ │ └── SentinelIterator.ts │ │ └── connector.ts │ ├── debug.ts │ ├── index.ts │ ├── pipeline.ts │ ├── redis.ts │ └── utils.ts └── tsconfig.json
SYMBOL INDEX (105 symbols across 17 files)
FILE: benchmarks/autopipelining-cluster.ts
function command (line 19) | function command(): string {
function test (line 31) | function test() {
function after (line 39) | function after(cb) {
method before (line 48) | before(cb) {
method before (line 57) | before(cb) {
FILE: benchmarks/autopipelining-single.ts
function command (line 14) | function command(): string {
function test (line 26) | function test() {
function after (line 34) | function after(cb) {
method before (line 43) | before(cb) {
method before (line 52) | before(cb) {
FILE: benchmarks/dropBuffer.ts
method test (line 9) | test() {
method before (line 12) | before(cb) {
method after (line 16) | after(cb) {
method test (line 22) | test() {
method before (line 25) | before(cb) {
method after (line 29) | after(cb) {
FILE: benchmarks/errorStack.ts
method test (line 9) | test() {
method before (line 12) | before(cb) {
method after (line 16) | after(cb) {
method test (line 22) | test() {
method before (line 25) | before(cb) {
method after (line 29) | after(cb) {
FILE: benchmarks/fixtures/insert.ts
function main (line 6) | async function main() {
FILE: bin/index.js
constant HEADER (line 8) | const HEADER = `/**
function main (line 26) | async function main() {
FILE: bin/template.ts
type RedisKey (line 3) | type RedisKey = string | Buffer;
type RedisValue (line 4) | type RedisValue = string | Buffer | number;
type ResultTypes (line 9) | interface ResultTypes<Result, Context> {
type ChainableCommander (line 14) | interface ChainableCommander
type ClientContext (line 19) | type ClientContext = { type: keyof ResultTypes<unknown, unknown> };
type Result (line 20) | type Result<T, Context extends ClientContext> =
type RedisCommander (line 24) | interface RedisCommander<Context extends ClientContext = { type: "defaul...
FILE: docs/assets/main.js
function N (line 2) | function N(t,e){ce.push({selector:e,constructor:t})}
method constructor (line 2) | constructor(){this.createComponents(document.body)}
method createComponents (line 2) | createComponents(e){ce.forEach(r=>{e.querySelectorAll(r.selector).forEac...
method constructor (line 2) | constructor(e){this.el=e.el}
method constructor (line 2) | constructor(){this.listeners={}}
method addEventListener (line 2) | addEventListener(e,r){e in this.listeners||(this.listeners[e]=[]),this.l...
method removeEventListener (line 2) | removeEventListener(e,r){if(!(e in this.listeners))return;let n=this.lis...
method dispatchEvent (line 2) | dispatchEvent(e){if(!(e.type in this.listeners))return!0;let r=this.list...
method constructor (line 2) | constructor(){super();this.scrollTop=0;this.lastY=0;this.width=0;this.he...
method triggerResize (line 2) | triggerResize(){let r=new CustomEvent("resize",{detail:{width:this.width...
method onResize (line 2) | onResize(){this.width=window.innerWidth||0,this.height=window.innerHeigh...
method onScroll (line 2) | onScroll(){this.scrollTop=window.scrollY||0;let r=new CustomEvent("scrol...
method hideShowToolbar (line 2) | hideShowToolbar(){var n;let r=this.showToolbar;this.showToolbar=this.las...
method constructor (line 2) | constructor(r){super(r);this.anchors=[];this.index=-1;Q.instance.addEven...
method createAnchors (line 2) | createAnchors(){let r=window.location.href;r.indexOf("#")!=-1&&(r=r.subs...
method onResize (line 2) | onResize(){let r;for(let i=0,s=this.anchors.length;i<s;i++){r=this.ancho...
method onScroll (line 2) | onScroll(r){let n=r.detail.scrollTop+5,i=this.anchors,s=i.length-1,o=thi...
function ye (line 2) | function ye(){let t=document.getElementById("tsd-search");if(!t)return;l...
function Ae (line 2) | function Ae(t,e,r,n){r.addEventListener("input",he(()=>{He(t,e,r,n)},200...
function Ve (line 2) | function Ve(t,e){t.index||window.searchData&&(e.classList.remove("loadin...
function He (line 2) | function He(t,e,r,n){var o,a;if(Ve(n,t),!n.index||!n.data)return;e.textC...
function me (line 2) | function me(t,e){var n,i;let r=t.querySelector(".current");if(!r)r=t.que...
function ze (line 2) | function ze(t,e){let r=t.querySelector(".current");if(r||(r=t.querySelec...
function ve (line 2) | function ve(t,e){if(e==="")return t;let r=t.toLocaleLowerCase(),n=e.toLo...
function se (line 2) | function se(t){return t.replace(/[&<>"'"]/g,e=>Ne[e])}
method constructor (line 2) | constructor(e,r){this.signature=e,this.description=r}
method addClass (line 2) | addClass(e){return this.signature.classList.add(e),this.description.clas...
method removeClass (line 2) | removeClass(e){return this.signature.classList.remove(e),this.descriptio...
method constructor (line 2) | constructor(r){super(r);this.groups=[];this.index=-1;this.createGroups()...
method setIndex (line 2) | setIndex(r){if(r<0&&(r=0),r>this.groups.length-1&&(r=this.groups.length-...
method createGroups (line 2) | createGroups(){let r=this.el.children;if(r.length<2)return;this.containe...
method onClick (line 2) | onClick(r){this.groups.forEach((n,i)=>{n.signature===r.currentTarget&&th...
method constructor (line 2) | constructor(r){super(r);this.className=this.el.dataset.toggle||"",this.e...
method setActive (line 2) | setActive(r){if(this.active==r)return;this.active=r,document.documentEle...
method onPointerUp (line 2) | onPointerUp(r){A||(this.setActive(!0),r.preventDefault())}
method onDocumentPointerDown (line 2) | onDocumentPointerDown(r){if(this.active){if(r.target.closest(".col-menu,...
method onDocumentPointerUp (line 2) | onDocumentPointerUp(r){if(!A&&this.active&&r.target.closest(".col-menu")...
method constructor (line 2) | constructor(e,r){this.key=e,this.value=r,this.defaultValue=r,this.initia...
method initialize (line 2) | initialize(){}
method setValue (line 2) | setValue(e){if(this.value==e)return;let r=this.value;this.value=e,window...
method initialize (line 2) | initialize(){let r=document.querySelector("#tsd-filter-"+this.key);!r||(...
method handleValueChange (line 2) | handleValueChange(r,n){!this.checkbox||(this.checkbox.checked=this.value...
method fromLocalStorage (line 2) | fromLocalStorage(r){return r=="true"}
method toLocalStorage (line 2) | toLocalStorage(r){return r?"true":"false"}
method initialize (line 2) | initialize(){document.documentElement.classList.add("toggle-"+this.key+t...
method handleValueChange (line 2) | handleValueChange(r,n){this.select.querySelectorAll("li.selected").forEa...
method fromLocalStorage (line 2) | fromLocalStorage(r){return r}
method toLocalStorage (line 2) | toLocalStorage(r){return r}
method constructor (line 2) | constructor(r){super(r);this.optionVisibility=new le("visibility","priva...
method isSupported (line 2) | static isSupported(){try{return typeof window.localStorage!="undefined"}...
function we (line 2) | function we(t){let e=localStorage.getItem("tsd-theme")||"os";t.value=e,b...
function be (line 2) | function be(t){switch(t){case"os":document.body.classList.remove("light"...
FILE: examples/custom_connector.js
class AsyncSentinelConnector (line 5) | class AsyncSentinelConnector extends Redis.SentinelConnector {
method constructor (line 6) | constructor(options = {}) {
method connect (line 16) | connect(eventEmitter) {
FILE: examples/hash.js
function main (line 4) | async function main() {
FILE: examples/list.js
function main (line 4) | async function main() {
FILE: examples/module.js
function main (line 4) | async function main() {
FILE: examples/redis_streams.js
function main (line 7) | async function main() {
FILE: examples/set.js
function main (line 4) | async function main() {
FILE: examples/ttl.js
function main (line 4) | async function main() {
FILE: lib/SubscriptionSet.ts
type AddSet (line 3) | type AddSet = CommandNameFlags["ENTER_SUBSCRIBER_MODE"][number];
type DelSet (line 4) | type DelSet = CommandNameFlags["EXIT_SUBSCRIBER_MODE"][number];
class SubscriptionSet (line 9) | class SubscriptionSet {
method add (line 16) | add(set: AddSet, channel: string) {
method del (line 20) | del(set: DelSet, channel: string) {
method channels (line 24) | channels(set: AddSet | DelSet): string[] {
method isEmpty (line 28) | isEmpty(): boolean {
function mapSet (line 37) | function mapSet(set: AddSet | DelSet): AddSet {
FILE: lib/autoPipelining.ts
function executeAutoPipeline (line 25) | function executeAutoPipeline(client, slotKey: string) {
function shouldUseAutoPipelining (line 81) | function shouldUseAutoPipelining(
function getFirstValueInFlattenedArray (line 95) | function getFirstValueInFlattenedArray(
function executeWithAutoPipelining (line 116) | function executeWithAutoPipelining(
Copy disabled (too large)
Download .json
Condensed preview — 213 files, each showing path, character count, and a content snippet. Download the .json file for the full structured content (20,652K chars).
[
{
"path": ".eslintrc.json",
"chars": 1922,
"preview": "{\n \"extends\": [\n \"eslint:recommended\",\n \"plugin:@typescript-eslint/recommended\",\n \"prettier\"\n ],\n \"ignorePat"
},
{
"path": ".github/CONTRIBUTING.md",
"chars": 1848,
"preview": "# Contributing to this repository\n\nThanks for contributing to ioredis! 👏\n\nThe goal of ioredis is to become a Redis clien"
},
{
"path": ".github/FUNDING.yml",
"chars": 60,
"preview": "# These are supported funding model platforms\n\ngithub: luin\n"
},
{
"path": ".github/stale.yml",
"chars": 363,
"preview": "daysUntilStale: 365\ndaysUntilClose: 7\nexemptLabels:\n - pinned\n - security\n - bug\n - discussion\nstaleLabel: wontfix\nm"
},
{
"path": ".github/workflows/manual.yml",
"chars": 264,
"preview": "name: Manual\n\non:\n workflow_dispatch:\n inputs:\n branch:\n description: 'Branch to run the workflow on'\n "
},
{
"path": ".github/workflows/push-requests.yml",
"chars": 125,
"preview": "name: Pull Requests\n\non:\n pull_request:\n branches: [main]\n\njobs:\n test:\n uses: ./.github/workflows/test_with_cov"
},
{
"path": ".github/workflows/release.yml",
"chars": 709,
"preview": "name: Release\n\non: workflow_dispatch\n\nconcurrency:\n group: release_version\n cancel-in-progress: true\n\njobs:\n test:\n "
},
{
"path": ".github/workflows/stale-issues.yml",
"chars": 3711,
"preview": "name: \"Stale Issue Management\"\non:\n schedule:\n # Run daily at midnight UTC\n - cron: \"0 0 * * *\"\n workflow_dispat"
},
{
"path": ".github/workflows/test.yml",
"chars": 923,
"preview": "on:\n workflow_call:\n inputs:\n branch:\n required: false\n type: string\n\njobs:\n test:\n runs-on: "
},
{
"path": ".github/workflows/test_with_cov.yml",
"chars": 1259,
"preview": "on:\n workflow_call:\n\njobs:\n test:\n runs-on: ubuntu-latest\n strategy:\n fail-fast: false\n matrix:\n "
},
{
"path": ".gitignore",
"chars": 111,
"preview": "node_modules\n*.cpuprofile\n/test.*\n/.idea\nbuilt\n\n.nyc_output\ncoverage\n\n.vscode\nbenchmarks/fixtures/*.txt\n\n*.rdb\n"
},
{
"path": ".prettierignore",
"chars": 54,
"preview": "package*.json\nbuilt/\nnode_modules/\ncoverage/\n.vscode/\n"
},
{
"path": ".releaserc.json",
"chars": 754,
"preview": "{\n \"branches\": [\n \"main\",\n {\n \"name\": \"beta\",\n \"channel\": \"beta\",\n \"tag\": \"beta\",\n \"prereleas"
},
{
"path": "CHANGELOG.md",
"chars": 89231,
"preview": "## [5.10.1](https://github.com/luin/ioredis/compare/v5.10.0...v5.10.1) (2026-03-19)\n\n\n### Bug Fixes\n\n* **cluster:** lazi"
},
{
"path": "CODE_OF_CONDUCT.md",
"chars": 3342,
"preview": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, w"
},
{
"path": "LICENSE",
"chars": 1080,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2015-2022 Zihua Li\n\nPermission is hereby granted, free of charge, to any person obt"
},
{
"path": "README.md",
"chars": 64126,
"preview": "[](https://github.com/redis/ioredis)\n\n[![Build Sta"
},
{
"path": "benchmarks/autopipelining-cluster.ts",
"chars": 1377,
"preview": "import { cronometro } from \"cronometro\";\nimport { readFileSync } from \"fs\";\nimport { join } from \"path\";\nimport Cluster "
},
{
"path": "benchmarks/autopipelining-single.ts",
"chars": 1152,
"preview": "import { cronometro } from \"cronometro\";\nimport { readFileSync } from \"fs\";\nimport { join } from \"path\";\nimport Redis fr"
},
{
"path": "benchmarks/dropBuffer.ts",
"chars": 634,
"preview": "import { cronometro } from \"cronometro\";\nimport Redis from \"../lib/Redis\";\n\nlet redis;\n\ncronometro(\n {\n default: {\n "
},
{
"path": "benchmarks/errorStack.ts",
"chars": 644,
"preview": "import { cronometro } from \"cronometro\";\nimport Redis from \"../lib/Redis\";\n\nlet redis;\n\ncronometro(\n {\n default: {\n "
},
{
"path": "benchmarks/fixtures/generate.ts",
"chars": 1962,
"preview": "\"use strict\";\n\nconst start = process.hrtime.bigint();\n\nimport * as calculateSlot from \"cluster-key-slot\";\nimport { write"
},
{
"path": "benchmarks/fixtures/insert.ts",
"chars": 1188,
"preview": "import { readFileSync } from \"fs\";\nimport { join } from \"path\";\nimport Redis from \"../../lib\";\nimport Cluster from \"../."
},
{
"path": "bin/argumentTypes.js",
"chars": 255,
"preview": "const typeMaps = require(\"./typeMaps\");\n\nmodule.exports = {\n debug: [\n [{ name: \"subcommand\", type: \"string\" }],\n "
},
{
"path": "bin/index.js",
"chars": 1426,
"preview": "const returnTypes = require(\"./returnTypes\");\nconst argumentTypes = require(\"./argumentTypes\");\nconst sortArguments = re"
},
{
"path": "bin/overrides.js",
"chars": 1404,
"preview": "const msetOverrides = {\n overwrite: false,\n defs: [\n \"$1(object: object, callback?: Callback<'OK'>): Result<'OK', C"
},
{
"path": "bin/returnTypes.js",
"chars": 9297,
"preview": "const hasToken = (types, token) => {\n if (Array.isArray(token)) return token.some((t) => hasToken(types, t));\n return "
},
{
"path": "bin/sortArguments.js",
"chars": 510,
"preview": "module.exports = {\n set: (args) => {\n const sorted = args.sort((a, b) => {\n const order = [\"key\", \"value\", \"exp"
},
{
"path": "bin/template.ts",
"chars": 2276,
"preview": "import { Callback } from \"../types\";\n\nexport type RedisKey = string | Buffer;\nexport type RedisValue = string | Buffer |"
},
{
"path": "bin/typeMaps.js",
"chars": 408,
"preview": "module.exports = {\n key: \"RedisKey\",\n string: (name) =>\n [\n \"value\",\n \"member\",\n \"element\",\n \"a"
},
{
"path": "docs/.nojekyll",
"chars": 143,
"preview": "TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `github"
},
{
"path": "docs/assets/highlight.css",
"chars": 2325,
"preview": ":root {\n --light-hl-0: #001080;\n --dark-hl-0: #9CDCFE;\n --light-hl-1: #000000;\n --dark-hl-1: #D4D4D4;\n --"
},
{
"path": "docs/assets/icons.css",
"chars": 35195,
"preview": ".tsd-kind-icon {\n display: block;\n position: relative;\n padding-left: 20px;\n text-indent: -20px;\n}\n.tsd-kind"
},
{
"path": "docs/assets/main.js",
"chars": 43311,
"preview": "(()=>{var Ce=Object.create;var ue=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPrope"
},
{
"path": "docs/assets/search.js",
"chars": 329725,
"preview": "window.searchData = JSON.parse(\"{\\\"kinds\\\":{\\\"32\\\":\\\"Variable\\\",\\\"128\\\":\\\"Class\\\",\\\"256\\\":\\\"Interface\\\",\\\"512\\\":\\\"Constr"
},
{
"path": "docs/assets/style.css",
"chars": 32865,
"preview": "@import url(\"./icons.css\");\n\n:root {\n /* Light */\n --light-color-background: #fcfcfc;\n --light-color-secondary-"
},
{
"path": "docs/classes/Cluster.html",
"chars": 6459391,
"preview": "<!DOCTYPE html><html class=\"default\"><head><meta charSet=\"utf-8\"/><meta http-equiv=\"x-ua-compatible\" content=\"IE=edge\"/>"
},
{
"path": "docs/classes/Redis.html",
"chars": 6523500,
"preview": "<!DOCTYPE html><html class=\"default\"><head><meta charSet=\"utf-8\"/><meta http-equiv=\"x-ua-compatible\" content=\"IE=edge\"/>"
},
{
"path": "docs/index.html",
"chars": 31385,
"preview": "<!DOCTYPE html><html class=\"default\"><head><meta charSet=\"utf-8\"/><meta http-equiv=\"x-ua-compatible\" content=\"IE=edge\"/>"
},
{
"path": "docs/interfaces/ChainableCommander.html",
"chars": 5940672,
"preview": "<!DOCTYPE html><html class=\"default\"><head><meta charSet=\"utf-8\"/><meta http-equiv=\"x-ua-compatible\" content=\"IE=edge\"/>"
},
{
"path": "docs/interfaces/ClusterOptions.html",
"chars": 46489,
"preview": "<!DOCTYPE html><html class=\"default\"><head><meta charSet=\"utf-8\"/><meta http-equiv=\"x-ua-compatible\" content=\"IE=edge\"/>"
},
{
"path": "docs/interfaces/CommonRedisOptions.html",
"chars": 62644,
"preview": "<!DOCTYPE html><html class=\"default\"><head><meta charSet=\"utf-8\"/><meta http-equiv=\"x-ua-compatible\" content=\"IE=edge\"/>"
},
{
"path": "docs/interfaces/SentinelAddress.html",
"chars": 8109,
"preview": "<!DOCTYPE html><html class=\"default\"><head><meta charSet=\"utf-8\"/><meta http-equiv=\"x-ua-compatible\" content=\"IE=edge\"/>"
},
{
"path": "docs/interfaces/SentinelConnectionOptions.html",
"chars": 33819,
"preview": "<!DOCTYPE html><html class=\"default\"><head><meta charSet=\"utf-8\"/><meta http-equiv=\"x-ua-compatible\" content=\"IE=edge\"/>"
},
{
"path": "examples/basic_operations.js",
"chars": 1895,
"preview": "const Redis = require(\"ioredis\");\nconst redis = new Redis({\n port: Number(process.env.redisPort || 6379),\n host: proce"
},
{
"path": "examples/custom_connector.js",
"chars": 1459,
"preview": "const Redis = require(\"ioredis\");\nconst MyService = require(\"path/to/my/service\");\n\n// Create a custom connector that fe"
},
{
"path": "examples/express/README.md",
"chars": 369,
"preview": "## Express Example\n\nThis example demonstrates how to use ioredis in a web application.\n\nThe idea is to create a shared R"
},
{
"path": "examples/express/app.js",
"chars": 1081,
"preview": "const createError = require(\"http-errors\");\nconst express = require(\"express\");\nconst path = require(\"path\");\nconst cook"
},
{
"path": "examples/express/bin/www",
"chars": 1593,
"preview": "#!/usr/bin/env node\n\n/**\n * Module dependencies.\n */\n\nvar app = require('../app');\nvar debug = require('debug')('express"
},
{
"path": "examples/express/package.json",
"chars": 320,
"preview": "{\n \"name\": \"express\",\n \"version\": \"0.0.0\",\n \"private\": true,\n \"scripts\": {\n \"start\": \"node ./bin/www\"\n },\n \"dep"
},
{
"path": "examples/express/redis.js",
"chars": 250,
"preview": "const Redis = require(\"ioredis\");\nconst redis = new Redis();\n\n// Create a shared Redis instance for the entire applicati"
},
{
"path": "examples/express/routes/index.js",
"chars": 274,
"preview": "const express = require(\"express\");\nconst redis = require(\"../redis\");\nconst router = express.Router();\n\n/* GET home pag"
},
{
"path": "examples/express/routes/users.js",
"chars": 426,
"preview": "const express = require(\"express\");\nconst redis = require(\"../redis\");\nconst router = express.Router();\n\n/* GET users li"
},
{
"path": "examples/express/views/error.jade",
"chars": 84,
"preview": "extends layout\n\nblock content\n h1= message\n h2= error.status\n pre #{error.stack}\n"
},
{
"path": "examples/express/views/index.jade",
"chars": 233,
"preview": "extends layout\n\nblock content\n h1= ioredis\n p We have \n a(href=\"/users\") #{count} users\n\n form(method=\"post\","
},
{
"path": "examples/express/views/users.jade",
"chars": 87,
"preview": "extends layout\n\nblock content\n h1= ioredis\n ul\n each user in users\n li= user\n"
},
{
"path": "examples/hash.js",
"chars": 1198,
"preview": "const Redis = require(\"ioredis\");\nconst redis = new Redis();\n\nasync function main() {\n const user = {\n name: \"Bob\",\n"
},
{
"path": "examples/list.js",
"chars": 789,
"preview": "const Redis = require(\"ioredis\");\nconst redis = new Redis();\n\nasync function main() {\n const numbers = [1, 3, 5, 7, 9];"
},
{
"path": "examples/module.js",
"chars": 403,
"preview": "const Redis = require(\"ioredis\");\nconst redis = new Redis();\n\nasync function main() {\n // Redis#call() can be used to c"
},
{
"path": "examples/redis_streams.js",
"chars": 1291,
"preview": "const Redis = require(\"ioredis\");\nconst redis = new Redis();\n\n// you may find this read https://redis.io/topics/streams-"
},
{
"path": "examples/set.js",
"chars": 526,
"preview": "const Redis = require(\"ioredis\");\nconst redis = new Redis();\n\nasync function main() {\n const numbers = [1, 3, 5, 7, 9];"
},
{
"path": "examples/ttl.js",
"chars": 1587,
"preview": "const Redis = require(\"ioredis\");\nconst redis = new Redis();\n\nasync function main() {\n await redis.set(\"foo\", \"bar\");\n "
},
{
"path": "examples/typescript/package.json",
"chars": 293,
"preview": "{\n \"name\": \"typescript\",\n \"version\": \"0.0.0\",\n \"description\": \"\",\n \"private\": true,\n \"main\": \"index.js\",\n \"scripts"
},
{
"path": "lib/SubscriptionSet.ts",
"chars": 1124,
"preview": "import { CommandNameFlags } from \"./Command\";\n\ntype AddSet = CommandNameFlags[\"ENTER_SUBSCRIBER_MODE\"][number];\ntype Del"
},
{
"path": "lib/autoPipelining.ts",
"chars": 6035,
"preview": "import { isArguments, noop } from \"./utils/lodash\";\nimport * as calculateSlot from \"cluster-key-slot\";\nimport asCallback"
}
]
// ... and 148 more files (download for full content)
About this extraction
This page contains the full source code of the redis/ioredis GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 213 files (19.9 MB), approximately 5.0M tokens, and a symbol index with 105 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.