diff options
471 files changed, 41508 insertions, 0 deletions
diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..eb1ca03 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,8 @@ +[bumpversion] +current_version = 1.13.0 +commit = True +tag = True + +[bumpversion:file:iredis/__init__.py] + +[bumpversion:file:pyproject.toml] @@ -0,0 +1,5 @@ +[flake8] +ignore = D203,W503,W605,C901,E203 +exclude = .git,__pycache__,build,dist,venv +max-complexity = 14 +max-line-length = 120 diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..9db21e2 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +patreon: laixintao +custom: ["https://www.kawabangga.com/sponsor", "http://paypal.me/laixintao"] diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..2e27a96 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,146 @@ +name: Release + +on: + push: + tags: + - v* + +jobs: + release-pypi: + name: release-pypi + runs-on: ubuntu-latest + + # FIXME + # help test shouldn't depends on this to run + services: + redis: + image: redis:5 + ports: + - 6379:6379 + options: --entrypoint redis-server + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v1 + with: + python-version: 3.7 + architecture: 'x64' + - name: Cache venv + uses: actions/cache@v1 + with: + path: venv + # Look to see if there is a cache hit for the corresponding requirements file + key: ubuntu-latest-poetryenv-${{ hashFiles('poetry.lock') }} + - name: Install Dependencies + run: | + python3 -m venv venv + . venv/bin/activate + pip install -U pip + pip install poetry + poetry install + python -c "import sys; print(sys.version)" + pip list + - name: Poetry Build + run: | + . venv/bin/activate + poetry build + - name: Test Build + run: | + python3 -m venv fresh_env + . fresh_env/bin/activate + pip install dist/*.whl + + iredis -h + iredis help GET + + - name: Upload to Pypi + env: + PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: | + . venv/bin/activate + poetry publish --username __token__ --password ${PASSWORD} + + release-binary: + name: Release Executable Binary. + runs-on: ubuntu-latest + + # FIXME + # help test shouldn't depends on this to run + services: + redis: + image: redis + ports: + - 6379:6379 + options: --entrypoint redis-server + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v1 + with: + python-version: 3.7 + architecture: 'x64' + - name: Cache venv + uses: actions/cache@v1 + with: + path: venv + # Look to see if there is a cache hit for the corresponding requirements file + key: ubuntu-latest-poetryenv-${{ hashFiles('poetry.lock') }} + - name: Install Dependencies + run: | + python3 -m venv venv + . venv/bin/activate + pip install pip + pip install poetry + poetry install + python -c "import sys; print(sys.version)" + pip list + - name: Poetry Build + run: | + . venv/bin/activate + poetry build + - name: Test Build + run: | + python3 -m venv fresh_env + . fresh_env/bin/activate + pip install dist/*.whl + + iredis -h + iredis help GET + + - name: Executable Build + run: | + # pyoxidizer doesn't know the wheel path, and it doesn't support passing env vars + export WHEEL_PATH=`ls ./dist/iredis*.whl` + envsubst '$WHEEL_PATH' < pyoxidizer.template.bzl > pyoxidizer.bzl + pip install pyoxidizer + pyoxidizer build --release install + cd ./build/x86*/release/install + tar -zcf ../../../iredis.tar.gz lib/ iredis + cd - + + - name: Test Executable + run: | + ./build/x86*/release/install/iredis -h + ./build/x86*/release/install/iredis help GET + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./build/iredis.tar.gz + asset_name: iredis.tar.gz + asset_content_type: application/gzip diff --git a/.github/workflows/test-binary-build.yaml b/.github/workflows/test-binary-build.yaml new file mode 100644 index 0000000..11e720a --- /dev/null +++ b/.github/workflows/test-binary-build.yaml @@ -0,0 +1,77 @@ +name: Test binary build. + +on: + pull_request: + push: + branches: + - master + +jobs: + test-release-binary: + name: Test Build Executable Binary. You can download from Artifact after building. + runs-on: ubuntu-latest + + # FIXME + # help test shouldn't depends on this to run + services: + redis: + image: redis + ports: + - 6379:6379 + options: --entrypoint redis-server + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v1 + with: + python-version: 3.7 + architecture: 'x64' + - name: Cache venv + uses: actions/cache@v1 + with: + path: venv + # Look to see if there is a cache hit for the corresponding requirements file + key: ubuntu-latest-poetryenv-${{ hashFiles('poetry.lock') }} + - name: Install Dependencies + run: | + python3 -m venv venv + . venv/bin/activate + pip install pip + pip install poetry + poetry install + python -c "import sys; print(sys.version)" + pip list + - name: Poetry Build + run: | + . venv/bin/activate + poetry build + - name: Test Build + run: | + python3 -m venv fresh_env + . fresh_env/bin/activate + pip install dist/*.whl + + iredis -h + iredis help GET + + - name: Executable Build + run: | + # pyoxidizer doesn't know the wheel path, and it doesn't support passing env vars + export WHEEL_PATH=`ls ./dist/iredis*.whl` + envsubst '$WHEEL_PATH' < pyoxidizer.template.bzl > pyoxidizer.bzl + pip install pyoxidizer + pyoxidizer build --release install + cd ./build/x86*/release/install + tar -zcf ../../../iredis.tar.gz lib/ iredis + cd - + + - name: Test Executable + run: | + ./build/x86*/release/install/iredis -h + ./build/x86*/release/install/iredis help GET + + - name: Upload Release Asset to Github Artifact + uses: actions/upload-artifact@v2 + with: + name: iredis-${{github.sha}}.tar.gz + path: ./build/iredis.tar.gz diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..01a9dfd --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,87 @@ +name: Test + +on: + pull_request: + push: + branches: + - master + +jobs: + test: + name: Pytest + strategy: + matrix: + os: ["ubuntu-20.04"] + python: ["3.7", "3.8", "3.9", "3.10", "3.11.1"] + redis: [5, 6, 7] + runs-on: ${{ matrix.os }} + + services: + redis: + image: redis:${{ matrix.redis }} + ports: + - 6379:6379 + options: --entrypoint redis-server + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: "x64" + - name: Cache venv + uses: actions/cache@v2 + with: + path: venv + # Look to see if there is a cache hit for the corresponding requirements file + key: + poetryenv-${{ matrix.os }}-${{ matrix.python }}-${{ + hashFiles('poetry.lock') }} + - name: Install Dependencies + run: | + python3 -m venv venv + . venv/bin/activate + pip install -U pip setuptools + pip install poetry + poetry install + python -c "import sys; print(sys.version)" + pip list + - name: Pytest + env: + REDIS_VERSION: ${{ matrix.redis }} + run: | + . venv/bin/activate + pytest + lint: + name: flake8 & black + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: codespell-project/actions-codespell@master + with: + ignore_words_list: fo,ists,oll,optin,ot,smove,tre,whe,EXAT,exat + skip: ./docs/assets/demo.svg,./iredis/data/commands.json,./iredis/data/commands/*,./tests/unittests/* + - uses: actions/setup-python@v4 + with: + python-version: 3.7 + architecture: "x64" + - name: Cache venv + uses: actions/cache@v2 + with: + path: venv + # Look to see if there is a cache hit for the corresponding requirements file + key: lintenv-v2 + - name: Install Dependencies + run: | + python3 -m venv venv + . venv/bin/activate + pip install -U pip flake8 black + - name: Flake8 test + run: | + . venv/bin/activate + flake8 . + - name: Black test + run: | + . venv/bin/activate + black --check . diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eb6314a --- /dev/null +++ b/.gitignore @@ -0,0 +1,109 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +*.aof + +# IDE +.vscode +.idea/
\ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..61423c6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "iredis/data/redis-doc"] + path = iredis/data/redis-doc + url = https://github.com/antirez/redis-doc.git +[submodule "redis-doc"] + path = redis-doc + url = https://github.com/antirez/redis-doc.git diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..49329ca --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,310 @@ +## UPCOMING + +## 1.3 + +- Dependency: Drop Python 3.6 support. +- Bugfix: fix some typos. + +### 1.12.2 + +- Feature: IRedis now honors the `ssl_cert_reqs` strategy, either specifying it via + command line (`--verify-ssl=<none|optional|required>`) or as an url parameter (`ssl_cert_reqs`) + when the connection is secured via tls (`rediss://`). (authored by [torrefatto]) + +### 1.12.1 + +- Feature: support new command: `HRANDFIELD`. +- Bugfix: all tests pass on redis:7 now. +- Feature: IRedis now accept `username` for auth, redis server version under 6 + will ignore `username`. +- Feature: IRedis support prompt now, you can customize prompt string. (thanks to [aymericbeaumet]) + +## 1.12 + +- Feature: `CLIENT KILL` now support `LADDR` argument. +- Feature: `CLIENT LIST` now support `ID` argument. +- Feature: `CLIENT PAUSE` support options and added `CLIENT UNPAUSE` command. +- Feature: `CLIENT TRACKING` support multiple prefixes. +- Feature: support new command: `CLIENT TRACKINGINFO`. +- Feature: support new command: `COPY`. +- Feature: support new command: `EVAL_RO` and `EVALSHA_RO`. +- Feature: support new command: `EXPIRETIME`. +- Feature: support new command: `FAILOVER`. +- Feature: support new command: `GEOSEARCH`. +- Feature: support new command: `GEOSEARCHRESTORE`. +- Feature: support new command: `GETDEL`. +- Feature: support new command: `GETEX`. +- Feature: `FLUSHDB` and `FLUSHALL` supports `SYNC` option. +- Feature: `GEOADD` supports `CH XX NX` options. +- Feature: Timestamp Completers are now support completion for timestamp fields + and milliseconds timestamp fields. +- Deprecate: `GEORADIUS` is deprecated, no auto-complete for this command + anymore. +- Deprecate: `GEORADIUSBYMEMBER` is deprecated, no auto-complete for this + command anymore. + +### 1.11.1 + +- Bugfix: Switch `distutils.version` to `packaging.version` to fix the version + parse for windows. (new dependency: pypi's python-packaging. + +## 1.11 + +- Dependency: Upgrade mistune lib to ^2.0. (see + https://github.com/laixintao/iredis/issues/232) + +## 1.10 + +- Feature: more human readable output for `HELP` command like `ACL HELP` and + `MEMORY HELP`. +- Feature: you can use <kbd>Ctrl</kbd> + <kbd>C</kbd> to cancel a blocking + command like `BLPOP`. +- Test: IRedis now tested under ubuntu-latest (before is ubuntu-16.04) +- Dependency: Support Python 3.10 now, thanks to [tssujt]. +- Add new command group: `bitmap`. +- Support new command in Redis: + - `ACL GETUSER` + - `ACL HELP` + - `BLMOVE` + - `CLIENT INFO` + +### 1.9.4 + +- Bugfix: respect newbie_mode set in config, if cli flag is missing. thanks to + [sid-maddy] + +### 1.9.3 + +- Bugfix: When IRedis start with `--decode=utf-8`, command with shell pipe will + fail. ( [#383](https://github.com/laixintao/iredis/issues/383)). Thanks to + [hanaasagi]. + +### 1.9.2 + +- Bugfix: before `cluster` commands' `node-id` only accept numbers, not it's + fixed. `node-id` can be `\w+`. +- Feature: support set client name for iredis connections via `--client-name`. + +### 1.9.1 + +- Feature: support auto-reissue command to another Redis server, when got a + "MOVED" error in redis cluster. + +## 1.9 + +- Feature: Support `LPOS` command. +- Doc: Update docs in `HELP` command update to date. + +## 1.8 + +- Feature: Fully support Redis6! + - Support `STRALGO` command. + - `MIGRATE` command now support `AUTH2`. + - DISABLE `hello` command, IRedis not support RESP3. + +### 1.7.4 + +- Bugfix: Lock wcwidth's version on `1.9.0`. Fix binary build. + +### 1.7.3 + +- Bugfix: IRedis can be suspended by <kbd>Ctrl</kbd> + <kbd>Z</kbd>. (Thanks + [wooden-robot]) +- Bugfix: Press <kbd>Enter</kbd> when completion is open will not execute + commands. (Thanks [wooden-robot]) +- Feature: `AUTH` command is now compatible with both Redis 5 and Redis 6. +- Redis6 support: `CLIENT KILL` support kill by `USER`, `XINFO` command support + `FULL` option. + +### 1.7.2 + +- Feature: Support `ACL` ( [#340](https://github.com/laixintao/iredis/pull/343) + ). +- Bugfix: Include tests in source distribution. + +### 1.7.1 + +- Bugfix: `command in` considered as an invalid input case, due to matched with + `command`'s syntax, and `in` as an extra args. Fixed by falling back to + default grammar if there are ambiguous commands that can match. + +## 1.7 + +- Update: Builtin doc was updated with latest + redis-doc(dd4159397f115d53423c21337eedb04d3258d291). +- Feature: New command support: `CLIENT GETREDIR`, `CLIENT TRACKING` and +- Test: IRedis now was tested in both Redis 5 and Redis 6. +- Bugfix: Fix exception when transaction fails. (Thanks [brianmaissy]) +- Bugfix: Merging multiple spaces bug, e.g. `set foo "hello world"` will result + in sending `set foo "hello world"` to redis-server. `CLIENT CACHING`. +- Bugfix: `--url` options is ignored, but don't worry, it is fixed now by + [otms61]. + +### 1.6.2 + +- Bugfix: `INFO` command accepts `section` now. +- Bugfix: refused to start when can not create connection. + +### 1.6.1 + +- Bugfix: Dangerous command will still run even user canceled. + +## 1.6 + +- Feature: support pager. You can disable it using `--no-pager` or in your + `iredisrc`, or change the pager behavior by setting `pager` in `iredisrc`. + +## 1.5 + +- Bugfix: PEEK command do not use MEMORY USAGE before redis version 4.0. +- Feature: Support disable shell pipeline feature in iredisrc. (Thanks + [wooden-robot]) + +### 1.4.3 + +- Support `LOLWUT` command of Redis 6 version. + +### 1.4.2 + +- Password for `AUTH` command will be hidden as `*`. + +### 1.4.1 + +- This is a test release, nothing new. + +## 1.4.0 + +- Bugfix: Fix PyOxidizer binary build, by locking the importlib_resources + version. + +### 1.3.1 + +- Bugfix: Fix PyOxidizer binary build. +- Feature: Completer for HELP command. +- Bugfix: Lowercase for `--newbie` mode. +- Bugfix: Bottom hint for IRedis builtin commands. + +## 1.3.0 + +- Catch up with redis-doc: d19fb20..6927ef0: + - `SET` command support `KEEPTTL` option. + - `LPUSHX` accepts multiple elements. + - Add commands support for: + - CLUSTER BUMPEPOCH + - CLUSTER FLUSHSLOTS + - CLUSTER MYID + - MODULE LIST + - MODULE LOAD + - MODULE UNLOAD + - PSYNC + - LATENCY DOCTOR + - LATENCY GRAPH + - LATENCY HISTORY + - LATENCY LATEST + - LATENCY RESET + - LATENCY HELP + +## 1.2.0 + +- Feature: Peek command now displays more friendly, before each "info" will take + one line, now type/encoding/ttl/memory usage will display in one line, makes + the result looks more clear. +- Support DSN. (Thanks [lyqscmy]). +- Support URL. +- Support socket connection. + +### 1.1.2 + +- Feature: support history location config. + +### 1.1.1 + +- This release is for testing the binary build, nothing else changed. + +## 1.1 + +- Feature: Package into a single binary with PyOxidizer (thanks [Mac Chaffee]) + +### 1.0.5 + +- Feature: <kbd>Ctrl - X</kbd> then <kbd>Ctrl -E</kbd> to open an editor to edit + command. +- Feature: Support `completion_casing` config. + +### 1.0.4 + +- Bugfix: command completions when a command is substring of another command. + [issue#198](https://github.com/laixintao/iredis/issues/198) + +### 1.0.3 + +- Feature: Support `bitfield` command, and a new completer for int type. + +### 1.0.2 + +- Internal: Migrate CI from travis and circleci to github action. + +### 1.0.1 + +- Bugfix: Fix info command decode error on + decode=utf-8 #[266](https://github.com/laixintao/iredis/pull/266) + +# 1.0 + +- Feature: Support `EXIT` to exit iredis REPL. +- Feature: Support `CLEAR` to clear screen. +- Feature: Support config log location in iredisrc file, default to None. + +### 0.9.1 + +- Feature: Support `PEEK` Command. + +## 0.9 + +- Refactor: split completer update and response render; Move cli tests to travis + ci. (Thanks: [ruohan.chen]) +- Support stream commands. _ Timestamp completer support. _ Stream command + renders and lexers. +- Bugfix: When response is None, + `iredis.completers.udpate_completer_for_responase` will raise Exception. + +### 0.8.12 + +- Bugfix: Multi spaces between commands can be recongnised as correct commands + now. +- Feature: Warning on dangerous command. + +### 0.8.11 + +- Bugfix: Fix HELP command can not render markdown with a `<h3>` header. +- Bugfix: Pipeline using a builtin Python API. + +### 0.8.10 + +- Bugfix: previous version of iredis didn't package redis-doc correctly. +- Feature: prompt for dangerous commands. + +### 0.8.9 + +- Support config files. + +### 0.8.8 + +- Bugfix: pipeline in iredis can run shell command include pipes. thanks to + [Wooden-Robot]. + +### 0.8.7 + +- Support connect shell utilities with pipeline + +[wooden-robot]: https://github.com/Wooden-Robot +[ruohan.chen]: https://github.com/crhan +[mac chaffee]: https://github.com/mac-chaffee +[lyqscmy]: https://github.com/lyqscmy +[brianmaissy]: https://github.com/brianmaissy +[otms61]: https://github.com/otms61 +[hanaasagi]: https://github.com/Hanaasagi +[sid-maddy]: https://github.com/sid-maddy +[tssujt]: https://github.com/tssujt +[aymericbeaumet]: https://github.com/aymericbeaumet +[torrefatto]: https://github.com/torrefatto diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..99c0463 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3 + +WORKDIR /iredis +COPY README.md poetry.lock pyproject.toml ./ +COPY iredis ./iredis + +RUN apt-get update && apt-get install -y --allow-unauthenticated \ + redis-server && \ + rm -rf /var/lib/apt/lists/* + + +RUN python3 -m venv iredis_env && \ + . iredis_env/bin/activate && \ + pip install poetry && \ + poetry install --no-dev && \ + rm -rf ~/.cache + +CMD ["sh","-c","redis-server --daemonize yes && . iredis_env/bin/activate && iredis"] @@ -0,0 +1,10 @@ +Copyright (c) 2019, laixintao +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of IRedis nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..11f3cb2 --- /dev/null +++ b/README.md @@ -0,0 +1,355 @@ +<p align="center"> + <img width="100" height="100" src="https://raw.githubusercontent.com/laixintao/iredis/master/docs/assets/logo.png" /> +</p> + +<h3 align="center">Interactive Redis: A Cli for Redis with AutoCompletion and Syntax Highlighting.</h3> + +<p align="center"> +<a href="https://github.com/laixintao/iredis/actions"><img src="https://github.com/laixintao/iredis/workflows/Test/badge.svg" alt="Github Action"></a> +<a href="https://badge.fury.io/py/iredis"><img src="https://badge.fury.io/py/iredis.svg" alt="PyPI version"></a> +<img src="https://badgen.net/badge/python/3.6%20%7C%203.7%20%7C%203.8%20%7C%203.9%20%7C%203.10/" alt="Python version"> +<a href="https://pepy.tech/project/iredis"><img src="https://pepy.tech/badge/iredis" alt="Download stats"></a> +</p> + +<p align="center"> + <img src="./docs/assets/demo.svg" alt="demo"> +</p> + +IRedis is a terminal client for redis with auto-completion and syntax +highlighting. IRedis lets you type Redis commands smoothly, and displays results +in a user-friendly format. + +IRedis is an alternative for redis-cli. In most cases, IRedis behaves exactly +the same as redis-cli. Besides, it is safer to use IRedis on production servers +than redis-cli: IRedis will prevent accidentally running dangerous commands, +like `KEYS *` (see +[Redis docs / Latency generated by slow commands](https://redis.io/topics/latency#latency-generated-by-slow-commands)). + +## Features + +- Advanced code completion. If you run command `KEYS` then run `DEL`, IRedis + will auto-complete your command based on `KEYS` result. +- Command validation. IRedis will validate command while you are typing, and + highlight errors. E.g. try `CLUSTER MEET IP PORT`, IRedis will validate IP and + PORT for you. +- Command highlighting, fully based on redis grammar. Any valid command in + IRedis shell is a valid redis command. +- Human-friendly result display. +- _pipeline_ feature, you can use your favorite shell tools to parse redis' + response, like `get json | jq .`. +- Support pager for long output. +- Support connection via URL, `iredis --url redis://example.com:6379/1`. +- Support cluster, IRedis will auto reissue command for `MOVED` response in + cluster mode. +- Store server configuration: `iredis -d prod-redis` (see [dsn](#using-dsn) for + more). +- `peek` command to check the key's type then automatically call + `get`/`lrange`/`sscan`, etc, depending on types. You don't need to call the + `type` command then type another command to get the value. `peek` will also + display the key's length and memory usage. +- <kbd>Ctrl</kbd> + <kbd>C</kbd> to cancel the current typed command, this won't + exit IRedis, exactly like bash behaviour. Use <kbd>Ctrl</kbd> + <kbd>D</kbd> + to send a EOF to exit IRedis. +- <kbd>Ctrl</kbd> + <kbd>R</kbd> to open **reverse-i-search** to search through + your command history. +- Auto suggestions. (Like [fish shell](http://fishshell.com/).) +- Support `--encode=utf-8`, to decode Redis' bytes responses. +- Command hint on bottom, include command syntax, supported redis version, and + time complexity. +- Official docs with built-in `HELP` command, try `HELP SET`! +- Written in pure Python, but IRedis was packaged into a single binary with + [PyOxidizer](https://github.com/indygreg/PyOxidizer), you can use cURL to + download and run, it just works, even you don't have a Python interpreter. +- You can change the cli prompt using `--prompt` option or set via `~/.iredisrc` + config file. +- Hide password for `AUTH` command. +- Says "Goodbye!" to you when you exit! +- For full features, please see: [iredis.io](https://www.iredis.io) + +## Install + +### Pip + +Install via pip: + +``` +pip install iredis +``` + +[pipx](https://github.com/pipxproject/pipx) is recommended: + +``` +pipx install iredis +``` + +### Brew + +For Mac users, you can install iredis via brew 🍻 + +``` +brew install iredis +``` + +### Linux + +You can also use your Linux package manager to install IRedis, like `apt` in +Ubuntu (Only available on Ubuntu 21.04+). + +```shell +apt install iredis +``` + +[![Packaging status](https://repology.org/badge/vertical-allrepos/iredis.svg)](https://repology.org/project/iredis/versions) + +### Download Binary + +Or you can download the executable binary with cURL(or wget), untar, then run. +It is especially useful when you don't have a python interpreter(E.g. the +[official Redis docker image](https://hub.docker.com/_/redis/) which doesn't +have Python installed.): + +``` +wget https://github.com/laixintao/iredis/releases/latest/download/iredis.tar.gz \ + && tar -xzf iredis.tar.gz \ + && ./iredis +``` + +(Check the [release page](https://github.com/laixintao/iredis/releases) if you +want to download an old version of IRedis.) + +## Usage + +Once you install IRedis, you will know how to use it. Just remember, IRedis +supports similar options like redis-cli, like `-h` for redis-server's host and +`-p` for port. + +``` +$ iredis --help + +Usage: iredis [OPTIONS] [CMD]... + + IRedis: Interactive Redis + + When no command is given, IRedis starts in interactive mode. + + Examples: + - iredis + - iredis -d dsn + - iredis -h 127.0.0.1 -p 6379 + - iredis -h 127.0.0.1 -p 6379 -a <password> + - iredis --url redis://localhost:7890/3 + + Type "help" in interactive mode for information on available commands and + settings. + +Options: + -h TEXT Server hostname (default: 127.0.0.1). + -p TEXT Server port (default: 6379). + -s, --socket TEXT Server socket (overrides hostname and port). + -n INTEGER Database number.(overwrites dsn/url's db + number) + + -u, --username TEXT User name used to auth, will be ignore for + redis version < 6. + + -a, --password TEXT Password to use when connecting to the + server. + + --url TEXT Use Redis URL to indicate connection(Can set + with env `IREDIS_URL`), Example: redis:/ + /[[username]:[password]]@localhost:6379/0 + rediss://[[username]:[password]]@localhost:6 + 379/0 unix://[[username]:[password]]@/pa + th/to/socket.sock?db=0 + + -d, --dsn TEXT Use DSN configured into the [alias_dsn] + section of iredisrc file. (Can set with env + `IREDIS_DSN`) + + --newbie / --no-newbie Show command hints and useful helps. + --iredisrc TEXT Config file for iredis, default is + ~/.iredisrc. + + --decode TEXT decode response, default is No decode, which + will output all bytes literals. + + --client_name TEXT Assign a name to the current connection. + --raw / --no-raw Use raw formatting for replies (default when + STDOUT is not a tty). However, you can use + --no-raw to force formatted output even when + STDOUT is not a tty. + + --rainbow / --no-rainbow Display colorful prompt. + --shell / --no-shell Allow to run shell commands, default to + True. + + --pager / --no-pager Using pager when output is too tall for your + window, default to True. + + --verify-ssl [none|optional|required] + Set the TLS certificate verification + strategy + + --prompt TEXT Prompt format (supported interpolations: + {client_name}, {db}, {host}, {path}, {port}, + {username}, {client_addr}, {client_id}). + + --version Show the version and exit. + --help Show this message and exit. + +``` + +### Using DSN + +IRedis support storing server configuration in config file. Here is a DSN +config: + +``` +[alias_dsn] +dev=redis://localhost:6379/4 +staging=redis://username:password@staging-redis.example.com:6379/1 +``` + +Put this in your `iredisrc` then connect via `iredis -d staging` or +`iredis -d dev`. + +### Change The Default Prompt + +You can change the prompt str, the default prompt is: + +```shell +127.0.0.1:6379> +``` + +Which is rendered by `{host}:{port}[{db}]> `, you can change this via `--prompt` +option or change +[iredisrc](https://github.com/laixintao/iredis/blob/master/iredis/data/iredisrc) +config file. The prompwt string uses python string format engine, supported +interpolations: + +- `{client_name}` +- `{db}` +- `{host}` +- `{path}` +- `{port}` +- `{username}` +- `{client_addr}` +- `{client_id}` + +The `--prompt` utilize +[Python String format engine](https://docs.python.org/3/library/string.html#formatstrings), +so as long as it is a valid string formatter, it will work( anything that +`"<your prompt>".format(...)` accepts). For example, you can limit your Redis +server host name's length to 5 by setting `--prompt` to +`iredis --prompt '{host:.5s}'`. + +### Configuration + +IRedis supports config files. Command-line options will always take precedence +over config. Configuration resolution from highest to lowest precedence is: + +- _Options from command line_ +- `$PWD/.iredisrc` +- `~/.iredisrc` (this path can be changed with `iredis --iredisrc $YOUR_PATH`) +- `/etc/iredisrc` +- default config in IRedis package. + +You can copy the _self-explained_ default config here: + +https://raw.githubusercontent.com/laixintao/iredis/master/iredis/data/iredisrc + +And then make your own changes. + +(If you are using an old versions of IRedis, please use the config file below, +and change the version in URL): + +https://raw.githubusercontent.com/laixintao/iredis/v1.0.4/iredis/data/iredisrc + +### Keys + +IRedis support unix/readline-style REPL keyboard shortcuts, which means keys +like <kbd>Ctrl</kbd> + <kbd>F</kbd> to forward work. + +Also: + +- <kbd>Ctrl</kbd> + <kbd>D</kbd> (i.e. EOF) to exit; you can also use the `exit` + command. +- <kbd>Ctrl</kbd> + <kbd>L</kbd> to clear screen; you can also use the `clear` + command. +- <kbd>Ctrl</kbd> + <kbd>X</kbd> <kbd>Ctrl</kbd> + <kbd>E</kbd> to open an + editor to edit command, or <kbd>V</kbd> in vi-mode. + +## Development + +### Release Strategy + +IRedis is built and released by `GitHub Actions`. Whenever a tag is pushed to +the `master` branch, a new release is built and uploaded to pypi.org, it's very +convenient. + +Thus, we release as often as possible, so that users can always enjoy the new +features and bugfixes quickly. Any bugfix or new feature will get at least a +patch release, whereas big features will get a minor release. + +### Setup Environment + +IRedis favors [poetry](https://github.com/sdispater/poetry) as package +management tool. To setup a develop environment on your computer: + +First, install poetry (you can do it in a python's virtualenv): + +``` +pip install poetry +``` + +Then run (which is similar to `pip install -e .`): + +``` +poetry install +``` + +**Be careful running testcases locally, it may flush you db!!!** + +### Development Logs + +This is a command-line tool, so we don't write logs to stdout. + +You can `tail -f ~/.iredis.log` to see logs, the log is pretty clear, you can +see what actually happens from log files. + +### Catch Up with Latest Redis-doc + +IRedis use a git submodule to track current-up-to-date redis-doc version. To +catch up with latest: + +1. Git pull in redis-doc +2. Copy doc files to `/data`: `cp -r redis-doc/commands* iredis/data` +3. Prettier + markdown`prettier --prose-wrap always iredis/data/commands/*.md --write` +4. Check the diff, update IRedis' code if needed. + +## Related Projects + +- [redis-tui](https://github.com/mylxsw/redis-tui) + +If you like iredis, you may also like other cli tools by +[dbcli](https://www.dbcli.com/): + +- [pgcli](https://www.pgcli.com) - Postgres Client with Auto-completion and + Syntax Highlighting +- [mycli](https://www.mycli.net) - MySQL/MariaDB/Percona Client with + Auto-completion and Syntax Highlighting +- [litecli](https://litecli.com) - SQLite Client with Auto-completion and Syntax + Highlighting +- [mssql-cli](https://github.com/dbcli/mssql-cli) - Microsoft SQL Server Client + with Auto-completion and Syntax Highlighting +- [athenacli](https://github.com/dbcli/athenacli) - AWS Athena Client with + Auto-completion and Syntax Highlighting +- [vcli](https://github.com/dbcli/vcli) - VerticaDB client +- [iredis](https://github.com/laixintao/iredis/) - Client for Redis with + AutoCompletion and Syntax Highlighting + +IRedis is build on the top of +[prompt_toolkit](https://github.com/jonathanslenders/python-prompt-toolkit), a +Python library (by [Jonathan Slenders](https://twitter.com/jonathan_s)) for +building rich commandline applications. diff --git a/docs/assets/color.css b/docs/assets/color.css new file mode 100644 index 0000000..077cb37 --- /dev/null +++ b/docs/assets/color.css @@ -0,0 +1,294 @@ +" Vim color file +" +" Author: Tomas Restrepo <tomas@winterdom.com> +" https://github.com/tomasr/molokai +" +" Note: Based on the Monokai theme for TextMate +" by Wimer Hazenberg and its darker variant +" by Hamish Stuart Macpherson +" + +hi clear + +if version > 580 + " no guarantees for version 5.8 and below, but this makes it stop + " complaining + hi clear + if exists("syntax_on") + syntax reset + endif +endif +let g:colors_name="molokai" + +if exists("g:molokai_original") + let s:molokai_original = g:molokai_original +else + let s:molokai_original = 0 +endif + + +hi Boolean guifg=#AE81FF +hi Character guifg=#E6DB74 +hi Number guifg=#AE81FF +hi String guifg=#E6DB74 +hi Conditional guifg=#F92672 gui=bold +hi Constant guifg=#AE81FF gui=bold +hi Cursor guifg=#000000 guibg=#F8F8F0 +hi iCursor guifg=#000000 guibg=#F8F8F0 +hi Debug guifg=#BCA3A3 gui=bold +hi Define guifg=#66D9EF +hi Delimiter guifg=#8F8F8F +hi DiffAdd guibg=#13354A +hi DiffChange guifg=#89807D guibg=#4C4745 +hi DiffDelete guifg=#960050 guibg=#1E0010 +hi DiffText guibg=#4C4745 gui=italic,bold + +hi Directory guifg=#A6E22E gui=bold +hi Error guifg=#E6DB74 +guibg=#1E0010 +hi ErrorMsg guifg=#F92672 +guibg=#232526 gui=bold +hi Exception guifg=#A6E22E gui=bold +hi Float guifg=#AE81FF +hi FoldColumn guifg=#465457 guibg=#000000 +hi Folded guifg=#465457 guibg=#000000 +hi Function guifg=#A6E22E +hi Identifier guifg=#FD971F +hi Ignore guifg=#808080 guibg=bg +hi IncSearch guifg=#C4BE89 guibg=#000000 + +hi Keyword guifg=#F92672 gui=bold +hi Label guifg=#E6DB74 gui=none +hi Macro guifg=#C4BE89 gui=italic +hi SpecialKey guifg=#66D9EF gui=italic + +hi MatchParen guifg=#000000 guibg=#FD971F gui=bold +hi ModeMsg guifg=#E6DB74 +hi MoreMsg guifg=#E6DB74 +hi Operator guifg=#F92672 + +" complete menu +hi Pmenu guifg=#66D9EF guibg=#000000 +hi PmenuSel guibg=#808080 +hi PmenuSbar guibg=#080808 +hi PmenuThumb guifg=#66D9EF + +hi PreCondit guifg=#A6E22E gui=bold +hi PreProc guifg=#A6E22E +hi Question guifg=#66D9EF +hi Repeat guifg=#F92672 gui=bold +hi Search guifg=#000000 guibg=#FFE792 +" marks +hi SignColumn guifg=#A6E22E guibg=#232526 +hi SpecialChar guifg=#F92672 gui=bold +hi SpecialComment guifg=#7E8E91 gui=bold +hi Special guifg=#66D9EF guibg=bg gui=italic +if has("spell") + hi SpellBad guisp=#FF0000 gui=undercurl + hi SpellCap guisp=#7070F0 gui=undercurl + hi SpellLocal guisp=#70F0F0 gui=undercurl + hi SpellRare guisp=#FFFFFF gui=undercurl +endif +hi Statement guifg=#F92672 gui=bold +hi StatusLine guifg=#455354 guibg=fg +hi StatusLineNC guifg=#808080 guibg=#080808 +hi StorageClass guifg=#FD971F gui=italic +hi Structure guifg=#66D9EF +hi Tag guifg=#F92672 gui=italic +hi Title guifg=#ef5939 +hi Todo guifg=#FFFFFF guibg=bg gui=bold + +hi Typedef guifg=#66D9EF +hi Type guifg=#66D9EF gui=none +hi Underlined guifg=#808080 gui=underline + +hi VertSplit guifg=#808080 guibg=#080808 gui=bold +hi VisualNOS guibg=#403D3D +hi Visual guibg=#403D3D +hi WarningMsg guifg=#FFFFFF guibg=#333333 gui=bold +hi WildMenu guifg=#66D9EF guibg=#000000 + +hi TabLineFill guifg=#1B1D1E guibg=#1B1D1E +hi TabLine guibg=#1B1D1E guifg=#808080 gui=none + +if s:molokai_original == 1 + hi Normal guifg=#F8F8F2 guibg=#272822 + hi Comment guifg=#75715E + hi CursorLine guibg=#3E3D32 + hi CursorLineNr guifg=#FD971F gui=none + hi CursorColumn guibg=#3E3D32 + hi ColorColumn guibg=#3B3A32 + hi LineNr guifg=#BCBCBC guibg=#3B3A32 + hi NonText guifg=#75715E + hi SpecialKey guifg=#75715E +else + hi Normal guifg=#F8F8F2 guibg=#1B1D1E + hi Comment guifg=#7E8E91 + hi CursorLine guibg=#293739 + hi CursorLineNr guifg=#FD971F gui=none + hi CursorColumn guibg=#293739 + hi ColorColumn guibg=#232526 + hi LineNr guifg=#465457 guibg=#232526 + hi NonText guifg=#465457 + hi SpecialKey guifg=#465457 +end + +" +" Support for 256-color terminal +" +if &t_Co > 255 + if s:molokai_original == 1 + hi Normal ctermbg=234 + hi CursorLine ctermbg=235 cterm=none + hi CursorLineNr ctermfg=208 cterm=none + else + hi Normal ctermfg=252 ctermbg=233 + hi CursorLine ctermbg=234 cterm=none + hi CursorLineNr ctermfg=208 cterm=none + endif + hi Boolean ctermfg=135 + hi Character ctermfg=144 + hi Number ctermfg=135 + hi String ctermfg=144 + hi Conditional ctermfg=161 cterm=bold + hi Constant ctermfg=135 cterm=bold + hi Cursor ctermfg=16 ctermbg=253 + hi Debug ctermfg=225 cterm=bold + hi Define ctermfg=81 + hi Delimiter ctermfg=241 + + hi DiffAdd ctermbg=24 + hi DiffChange ctermfg=181 ctermbg=239 + hi DiffDelete ctermfg=162 ctermbg=53 + hi DiffText ctermbg=102 cterm=bold + + hi Directory ctermfg=118 cterm=bold + hi Error ctermfg=219 ctermbg=89 + hi ErrorMsg ctermfg=199 ctermbg=16 cterm=bold + hi Exception ctermfg=118 cterm=bold + hi Float ctermfg=135 + hi FoldColumn ctermfg=67 ctermbg=16 + hi Folded ctermfg=67 ctermbg=16 + hi Function ctermfg=118 + hi Identifier ctermfg=208 cterm=none + hi Ignore ctermfg=244 ctermbg=232 + hi IncSearch ctermfg=193 ctermbg=16 + + hi keyword ctermfg=161 cterm=bold + hi Label ctermfg=229 cterm=none + hi Macro ctermfg=193 + hi SpecialKey ctermfg=81 + + hi MatchParen ctermfg=233 ctermbg=208 cterm=bold + hi ModeMsg ctermfg=229 + hi MoreMsg ctermfg=229 + hi Operator ctermfg=161 + + " complete menu + hi Pmenu ctermfg=81 ctermbg=16 + hi PmenuSel ctermfg=255 ctermbg=242 + hi PmenuSbar ctermbg=232 + hi PmenuThumb ctermfg=81 + + hi PreCondit ctermfg=118 cterm=bold + hi PreProc ctermfg=118 + hi Question ctermfg=81 + hi Repeat ctermfg=161 cterm=bold + hi Search ctermfg=0 ctermbg=222 cterm=NONE + + " marks column + hi SignColumn ctermfg=118 ctermbg=235 + hi SpecialChar ctermfg=161 cterm=bold + hi SpecialComment ctermfg=245 cterm=bold + hi Special ctermfg=81 + if has("spell") + hi SpellBad ctermbg=52 + hi SpellCap ctermbg=17 + hi SpellLocal ctermbg=17 + hi SpellRare ctermfg=none ctermbg=none cterm=reverse + endif + hi Statement ctermfg=161 cterm=bold + hi StatusLine ctermfg=238 ctermbg=253 + hi StatusLineNC ctermfg=244 ctermbg=232 + hi StorageClass ctermfg=208 + hi Structure ctermfg=81 + hi Tag ctermfg=161 + hi Title ctermfg=166 + hi Todo ctermfg=231 ctermbg=232 cterm=bold + + hi Typedef ctermfg=81 + hi Type ctermfg=81 cterm=none + hi Underlined ctermfg=244 cterm=underline + + hi VertSplit ctermfg=244 ctermbg=232 cterm=bold + hi VisualNOS ctermbg=238 + hi Visual ctermbg=235 + hi WarningMsg ctermfg=231 ctermbg=238 cterm=bold + hi WildMenu ctermfg=81 ctermbg=16 + + hi Comment ctermfg=59 + hi CursorColumn ctermbg=236 + hi ColorColumn ctermbg=236 + hi LineNr ctermfg=250 ctermbg=236 + hi NonText ctermfg=59 + + hi SpecialKey ctermfg=59 + + if exists("g:rehash256") && g:rehash256 == 1 + hi Normal ctermfg=252 ctermbg=234 + hi CursorLine ctermbg=236 cterm=none + hi CursorLineNr ctermfg=208 cterm=none + + hi Boolean ctermfg=141 + hi Character ctermfg=222 + hi Number ctermfg=141 + hi String ctermfg=222 + hi Conditional ctermfg=197 cterm=bold + hi Constant ctermfg=141 cterm=bold + + hi DiffDelete ctermfg=125 ctermbg=233 + + hi Directory ctermfg=154 cterm=bold + hi Error ctermfg=222 ctermbg=233 + hi Exception ctermfg=154 cterm=bold + hi Float ctermfg=141 + hi Function ctermfg=154 + hi Identifier ctermfg=208 + + hi Keyword ctermfg=197 cterm=bold + hi Operator ctermfg=197 + hi PreCondit ctermfg=154 cterm=bold + hi PreProc ctermfg=154 + hi Repeat ctermfg=197 cterm=bold + + hi Statement ctermfg=197 cterm=bold + hi Tag ctermfg=197 + hi Title ctermfg=203 + hi Visual ctermbg=238 + + hi Comment ctermfg=244 + hi LineNr ctermfg=239 ctermbg=235 + hi NonText ctermfg=239 + hi SpecialKey ctermfg=239 + endif +end + +" Must be at the end, because of ctermbg=234 bug. +" https://groups.google.com/forum/#!msg/vim_dev/afPqwAFNdrU/nqh6tOM87QUJ +set background=dark + + + +[colors] + +bottom-toolbar = 'bg:#222222 #aaaaaa' +bottom-toolbar.off = 'bg:#222222 #888888' +bottom-toolbar.on = 'bg:#222222 #ffffff' + +bottom-toolbar.transaction.valid = 'bg:#222222 #00ff5f bold' +bottom-toolbar.transaction.failed = 'bg:#222222 #ff005f bold' + +# style classes for colored table output +output.header = "#00ff5f bold" +output.odd-row = "" +output.even-row = "" diff --git a/docs/assets/demo.cast b/docs/assets/demo.cast new file mode 100644 index 0000000..07b17b2 --- /dev/null +++ b/docs/assets/demo.cast @@ -0,0 +1,386 @@ +{"version": 2, "width": 66, "height": 20} +[0.0, "o", "\u001b]1337;RemoteHost=laixintao@Chico.local\u0007\u001b]1337;CurrentDir=/Users/laixintao\u0007\u001b]1337;ShellIntegrationVersion=6;shell=zsh\u0007"] +[0.034194, "o", "\u001b[1m\u001b[7m%\u001b[27m\u001b[1m\u001b[0m \r \r"] +[0.054034, "o", "\u001b]133;D;0\u0007\u001b]1337;RemoteHost=laixintao@Chico.local\u0007\u001b]1337;CurrentDir=/Users/laixintao\u0007"] +[0.05708, "o", "\r\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b]133;A\u0007$ \u001b]133;B\u0007\u001b[K"] +[0.057424, "o", "\u001b[?1h\u001b="] +[0.057603, "o", "\u001b[?2004h"] +[1.404776, "o", "i"] +[1.709882, "o", "\bir"] +[1.805422, "o", "e"] +[1.957047, "o", "d"] +[2.073349, "o", "i"] +[2.170964, "o", "s"] +[2.308611, "o", "\u001b[?1l\u001b>"] +[2.308783, "o", "\u001b[?2004l\r\r\n"] +[2.311011, "o", "\u001b]133;C;\u0007"] +[2.589501, "o", "\u001b[0m\u001b[?7h\u001b[0miredis 0.8.0\r\r\nredis-server 5.0.6 \r\r\nHome: https://iredis.io\r\r\nIssues: https://iredis.io/issues\u001b[0m\u001b[0m"] +[2.591596, "o", "\u001b[0m\u001b[?7h\u001b[0m\r\r\n\u001b[0m"] +[2.592274, "o", "\u001b[?1l"] +[2.592372, "o", "\u001b[6n"] +[2.599827, "o", "\u001b[?2004h\u001b[?25l\u001b[0m\u001b[?7l\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \r\u001b[7A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[2.617441, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \u001b[0m\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \r\u001b[65C \r\u001b[14A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[3.516857, "o", "\u001b[?25l\u001b[?7l\u001b[0mk \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m KEYS \u001b[0;38;5;16;48;5;238m \u001b[A\u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[3.522751, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241meys *\u001b[0m \u001b[6D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[3.626927, "o", "\u001b[?25l\u001b[?7l\u001b[0me \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m KEYS\u001b[C \u001b[0;38;5;16;48;5;238m \u001b[A\u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[3.632562, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mys *\u001b[0m \u001b[5D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[3.750562, "o", "\u001b[?25l\u001b[?7l\u001b[0my \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m KEYS\u001b[C \u001b[0;38;5;16;48;5;238m \u001b[A\u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[3.755718, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241ms *\u001b[0m \u001b[4D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[3.859462, "o", "\u001b[?25l\u001b[?7l\u001b[3D\u001b[0;38;5;28;1mkeys\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m KEYS\u001b[C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;167;48;5;235;1m(generic) \u001b[0;38;5;28;48;5;235;1mKEYS\u001b[0;38;5;71;48;5;235;1m pattern\u001b[0;38;5;136;48;5;235m since: 1.0.0\u001b[0;38;5;241;48;5;235m complexity:O(N) with N bein\r\u001b[65Cg\u001b[14A\r\u001b[20C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[3.864549, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m *\u001b[0m \u001b[3D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[4.112384, "o", "\u001b[?25l\u001b[?7l\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[A\u001b[20C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[4.121805, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m*\u001b[0m \u001b[2D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[4.49726, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71;1m*\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[4.503062, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[4.796083, "o", "\u001b[?25l\u001b[?7l\u001b[22D\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0;38;5;28;1mkeys\u001b[0m \u001b[0;38;5;71;1m*\u001b[0m \r\u001b[65C \r\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h\u001b[?2004l"] +[4.80137, "o", "\u001b[0m\u001b[?7h\u001b[0m 1)\u001b[0m \u001b[0;38;5;71m\"myzset\"\u001b[0m\r\r\n\u001b[0m 2)\u001b[0m \u001b[0;38;5;71m\"mylist1\"\u001b[0m\r\r\n\u001b[0m 3)\u001b[0m \u001b[0;38;5;71m\"abc\"\u001b[0m\r\r\n\u001b[0m 4)\u001b[0m \u001b[0;38;5;71m\"a\"\u001b[0m\r\r\n\u001b[0m 5)\u001b[0m \u001b[0;38;5;71m\"mstream\"\u001b[0m\r\r\n\u001b[0m 6)\u001b[0m \u001b[0;38;5;71m\"testKeyDB2\"\u001b[0m\r\r\n\u001b[0m 7)\u001b[0m \u001b[0;38;5;71m\"list:restaurant\"\u001b[0m\r\r\n\u001b[0m 8)\u001b[0m \u001b[0;38;5;71m\"Sicily\"\u001b[0m\r\r\n\u001b[0m 9)\u001b[0m \u001b[0;38;5;71m\"cars\"\u001b[0m\r\r\n\u001b[0m10)\u001b[0m \u001b[0;38;5;71m\"hash1\"\u001b[0m\r\r\n\u001b[0m11)\u001b[0m \u001b[0;38;5;71m\"list:buildings\"\u001b[0m\r\r\n\u001b[0m12)\u001b[0m \u001b[0;38;5;71m\"hash3\"\u001b[0m\r\r\n\u001b[0m13)\u001b[0m \u001b[0;38;5;71m\"fooset\"\u001b[0m\r\r\n\u001b[0m14)\u001b[0m \u001b[0;38;5;71m\"foo\"\u001b[0m\r\r\n\u001b[0m15)\u001b[0m \u001b[0;38;5;71m\"myset\"\u001b[0m\r\r\n\u001b[0m16)\u001b[0m \u001b[0;38;5;71m\"hash2\"\u001b[0m\r\r\n\u001b[0m17)\u001b[0m \u001b[0;38;5;71m\"list:animals\"\u001b[0m\r\r\n\u001b[0m18)\u001b[0m \u001b[0;38;5;71m\"af\"\u001b[0m\r\r\n\u001b[0m19)\u001b[0m \u001b[0;38;5;71m\"somestream\"\u001b[0m\r\r\n\u001b[0m20)\u001b[0m \u001b[0;38;5;71m\"kkk\"\u001b[0m\u001b[0m"] +[4.803285, "o", "\u001b[0m\u001b[?7h\u001b[0m\r\r\n\u001b[0m"] +[4.804015, "o", "\u001b[?1l"] +[4.804128, "o", "\u001b[6n"] +[4.807349, "o", "\u001b[?2004h\u001b[?25l\u001b[0m\u001b[?7l\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \r\u001b[7A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[4.812015, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \r\u001b[65C \r\u001b[8A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[5.558691, "o", "\u001b[?25l\u001b[?7l\u001b[0mt \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TTL \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TIME \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TYPE \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TOUCH \u001b[0;38;5;16;48;5;238m \u001b[4A\u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[5.562825, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mype myset\u001b[0m \u001b[10D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[5.802861, "o", "\u001b[?25l\u001b[?7l\u001b[0my \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m TYPE \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[4A\u001b[17C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[5.807952, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mpe myset\u001b[0m \u001b[9D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[6.011176, "o", "\u001b[?25l\u001b[?7l\u001b[0mp \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m TYPE\u001b[C \u001b[0;38;5;16;48;5;238m \u001b[A\u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[6.01494, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241me myset\u001b[0m \u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[6.1425, "o", "\u001b[?25l\u001b[?7l\u001b[3D\u001b[0;38;5;28;1mtype\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m TYPE\u001b[C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;167;48;5;235;1m(generic) \u001b[0;38;5;28;48;5;235;1mTYPE\u001b[0;38;5;71;48;5;235m key\u001b[0;38;5;136;48;5;235m since: 1.0.0\u001b[0;38;5;241;48;5;235m complexity:O(1)\u001b[8A\u001b[29D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[6.14741, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m myset\u001b[0m \u001b[7D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[6.244466, "o", "\u001b[?25l\u001b[?7l\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m kkk \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m somestream \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m af \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m list:animals \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m hash2 \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m myset \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m foo \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[6.253095, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mmyset\u001b[0m \u001b[6D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[6.712731, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mm\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mm\u001b[0;38;5;238;48;5;30myset\u001b[8C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mm\u001b[0;38;5;238;48;5;30mstream\u001b[0;38;5;231;48;5;30m \u001b[4C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mm\u001b[0;38;5;238;48;5;30mylist1\u001b[6C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mm\u001b[0;38;5;238;48;5;30myzset\u001b[0;38;5;231;48;5;30m \u001b[2C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mso\u001b[0;38;5;231;48;5;30;1;4mm\u001b[0;38;5;238;48;5;30mestream\u001b[3C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mlist:ani\u001b[0;38;5;231;48;5;30;1;4mm\u001b[0;38;5;238;48;5;30mals\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[7A\u001b[17D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[6.718052, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241myset\u001b[0m \u001b[5D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[9.031011, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71my\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[22C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mmy\u001b[0;38;5;238;48;5;30mset\u001b[3C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[22C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mmy\u001b[0;38;5;238;48;5;30mlist1\u001b[C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[22C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mmy\u001b[0;38;5;238;48;5;30mzset\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[6A\u001b[22C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[9.048076, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mset\u001b[0m \u001b[4D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[9.337635, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mset\u001b[0m\r\r\n\u001b[23C\u001b[0;38;5;16;48;5;231m \u001b[0;38;5;16;48;5;231;4mmy\u001b[0;48;5;231mset\u001b[0;38;5;16;48;5;231m \u001b[A\u001b[6D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[9.341531, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[9.587591, "o", "\u001b[?25l\u001b[?7l\u001b[26D\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0;38;5;28;1mtype\u001b[0m \u001b[0;38;5;71mmyset\u001b[0m \r\u001b[65C \r\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h\u001b[?2004l"] +[9.592731, "o", "\u001b[0m\u001b[?7h\u001b[0m\"set\"\u001b[0m\u001b[0m"] +[9.595501, "o", "\u001b[0m\u001b[?7h\u001b[0m\r\r\n\u001b[0m"] +[9.596128, "o", "\u001b[?1l"] +[9.59625, "o", "\u001b[6n"] +[9.598996, "o", "\u001b[?2004h\u001b[?25l\u001b[0m\u001b[?7l\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \r\u001b[7A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[9.602329, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \r\u001b[65C \r\u001b[8A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[10.630148, "o", "\u001b[?25l\u001b[?7l\u001b[0ms \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m SET \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m SREM \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m SPOP \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m SADD \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m SYNC \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m SAVE \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m SORT \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[16D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[10.635184, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241met foo bar\u001b[0m \u001b[11D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[11.02782, "o", "\u001b[?25l\u001b[?7l\u001b[0mm \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m SMOVE\u001b[4C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m SMEMBERS \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[7A\u001b[15D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[11.031124, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241members fooset\u001b[0m \u001b[14D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[11.103554, "o", "\u001b[?25l\u001b[?7l\u001b[0me \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m SMEMBERS \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[2A\u001b[18C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[11.107347, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mmbers fooset\u001b[0m \u001b[13D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[11.198052, "o", "\u001b[?25l\u001b[?7l\u001b[0mm \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m SMEMBERS \u001b[0;38;5;16;48;5;238m \u001b[A\u001b[11D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[11.201012, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mbers fooset\u001b[0m \u001b[12D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[11.568186, "o", "\u001b[?25l\u001b[?7l\u001b[4D\u001b[0;38;5;28;1mSMEMBERS\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[20C\u001b[0;38;5;16;48;5;231m SMEMBERS \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;167;48;5;235;1m(set) \u001b[0;38;5;28;48;5;235;1mSMEMBERS\u001b[0;38;5;71;48;5;235m key\u001b[0;38;5;136;48;5;235m since: 1.0.0\u001b[0;38;5;241;48;5;235m complexity:O(N) where N is the \r\u001b[65Cs\u001b[8A\r\u001b[24C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[11.572482, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[11.824354, "o", "\u001b[?25l\u001b[?7l\u001b[C\u001b[0m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m myset \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[25C\u001b[0;38;5;231;48;5;30m kkk \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[25C\u001b[0;38;5;231;48;5;30m somestream \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[25C\u001b[0;38;5;231;48;5;30m af \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[25C\u001b[0;38;5;231;48;5;30m list:animals \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[25C\u001b[0;38;5;231;48;5;30m hash2 \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[25C\u001b[0;38;5;231;48;5;30m foo \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[11.828823, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mmyset\u001b[0m \u001b[6D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[12.363643, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mm\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[25C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mm\u001b[0;38;5;238;48;5;30myset\u001b[8C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[25C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mm\u001b[0;38;5;238;48;5;30mstream\u001b[6C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[25C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mm\u001b[0;38;5;238;48;5;30mylist1\u001b[0;38;5;231;48;5;30m \u001b[4C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[25C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mm\u001b[0;38;5;238;48;5;30myzset\u001b[7C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[25C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mso\u001b[0;38;5;231;48;5;30;1;4mm\u001b[0;38;5;238;48;5;30mestream\u001b[0;38;5;231;48;5;30m \u001b[2C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[25C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mlist:ani\u001b[0;38;5;231;48;5;30;1;4mm\u001b[0;38;5;238;48;5;30mals\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[25C\u001b[0m \u001b[7A\u001b[17D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[12.368073, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241myset\u001b[0m \u001b[5D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[12.639026, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71my\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[26C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mmy\u001b[0;38;5;238;48;5;30mset\u001b[3C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[26C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mmy\u001b[0;38;5;238;48;5;30mlist1\u001b[C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[26C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mmy\u001b[0;38;5;238;48;5;30mzset\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[6A\u001b[26C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[12.642963, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mset\u001b[0m \u001b[4D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[12.84344, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mset\u001b[0m\r\r\n\u001b[27C\u001b[0;38;5;16;48;5;231m \u001b[0;38;5;16;48;5;231;4mmy\u001b[0;48;5;231mset\u001b[0;38;5;16;48;5;231m \u001b[A\u001b[6D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[12.847415, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[13.250149, "o", "\u001b[?25l\u001b[?7l\u001b[30D\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0;38;5;28;1mSMEMBERS\u001b[0m \u001b[0;38;5;71mmyset\u001b[0m \r\u001b[65C \r\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h\u001b[?2004l"] +[13.255777, "o", "\u001b[0m\u001b[?7h\u001b[0m1)\u001b[0m \u001b[0;38;5;208m\"foo\"\u001b[0m\r\r\n\u001b[0m2)\u001b[0m \u001b[0;38;5;208m\"world\"\u001b[0m\r\r\n\u001b[0m3)\u001b[0m \u001b[0;38;5;208m\"bar\"\u001b[0m\r\r\n\u001b[0m4)\u001b[0m \u001b[0;38;5;208m\"hello\"\u001b[0m\u001b[0m"] +[13.257576, "o", "\u001b[0m\u001b[?7h\u001b[0m\r\r\n\u001b[0m"] +[13.25837, "o", "\u001b[?1l\u001b[6n"] +[13.260811, "o", "\u001b[?2004h\u001b[?25l\u001b[0m\u001b[?7l\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \r\u001b[7A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[13.264088, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \r\u001b[65C \r\u001b[8A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.018012, "o", "\u001b[?25l\u001b[?7l\u001b[0mt \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TTL \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TIME \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TYPE \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TOUCH \u001b[0;38;5;16;48;5;238m \u001b[4A\u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.021342, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mype myset\u001b[0m \u001b[10D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.136615, "o", "\u001b[?25l\u001b[?7l\u001b[0my \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m TYPE \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[4A\u001b[17C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.139872, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mpe myset\u001b[0m \u001b[9D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.301704, "o", "\u001b[?25l\u001b[?7l\u001b[0mp \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m TYPE\u001b[C \u001b[0;38;5;16;48;5;238m \u001b[A\u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.305109, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241me myset\u001b[0m \u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.381888, "o", "\u001b[?25l\u001b[?7l\u001b[3D\u001b[0;38;5;28;1mtype\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m TYPE\u001b[C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;167;48;5;235;1m(generic) \u001b[0;38;5;28;48;5;235;1mTYPE\u001b[0;38;5;71;48;5;235m key\u001b[0;38;5;136;48;5;235m since: 1.0.0\u001b[0;38;5;241;48;5;235m complexity:O(1)\u001b[8A\u001b[29D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.387144, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m myset\u001b[0m \u001b[7D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.493325, "o", "\u001b[?25l\u001b[?7l\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m myset \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m kkk \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m somestream \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m af \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m list:animals \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m hash2 \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m foo \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.498349, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mmyset\u001b[0m \u001b[6D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.792526, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mc\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mc\u001b[0;38;5;238;48;5;30mars\u001b[3C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mSi\u001b[0;38;5;231;48;5;30;1;4mc\u001b[0;38;5;238;48;5;30mily\u001b[C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mab\u001b[0;38;5;231;48;5;30;1;4mc\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[7A\u001b[17D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.797662, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mars\u001b[0m \u001b[4D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.880584, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71ma\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[22C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mca\u001b[0;38;5;238;48;5;30mrs\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[3A\u001b[22C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[15.885051, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mrs\u001b[0m \u001b[3D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[16.48149, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mrs\u001b[0m\r\r\n\u001b[23C\u001b[0;38;5;16;48;5;231m \u001b[0;38;5;16;48;5;231;4mca\u001b[0;48;5;231mrs\u001b[0;38;5;16;48;5;231m \u001b[A\u001b[5D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[16.486215, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[16.848883, "o", "\u001b[?25l\u001b[?7l\u001b[25D\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0;38;5;28;1mtype\u001b[0m \u001b[0;38;5;71mcars\u001b[0m \r\u001b[65C \r\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h\u001b[?2004l"] +[16.852972, "o", "\u001b[0m\u001b[?7h\u001b[0m\"zset\"\u001b[0m\u001b[0m"] +[16.854529, "o", "\u001b[0m\u001b[?7h\u001b[0m\r\r\n\u001b[0m"] +[16.855119, "o", "\u001b[?1l\u001b[6n"] +[16.858567, "o", "\u001b[?2004h\u001b[?25l\u001b[0m\u001b[?7l\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \r\u001b[7A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[16.862469, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \r\u001b[65C \r\u001b[8A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[17.715952, "o", "\u001b[?25l\u001b[?7l\u001b[0mz \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m ZREM \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m ZADD \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m ZSCAN \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m ZRANK \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m ZCARD \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m ZSCORE \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m ZRANGE \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[19D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[17.72013, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mscan kkk 0\u001b[0m \u001b[11D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[17.977719, "o", "\u001b[?25l\u001b[?7l\u001b[0ms \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m ZSCAN\u001b[2C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m ZSCORE \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[17.981853, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mcan kkk 0\u001b[0m \u001b[10D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[18.172029, "o", "\u001b[?25l\u001b[?7l\u001b[0mc \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m ZSCAN\u001b[C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m ZSCORE \u001b[0;38;5;16;48;5;238m \u001b[2A\u001b[9D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[18.176161, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241man kkk 0\u001b[0m \u001b[9D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[18.555927, "o", "\u001b[?25l\u001b[?7l\u001b[3D\u001b[0;38;5;28;1mZSCAN\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[19C\u001b[0;38;5;16;48;5;231m ZSCAN \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;167;48;5;235;1m(sorted_set) \u001b[0;38;5;28;48;5;235;1mZSCAN\u001b[0;38;5;71;48;5;235m key\u001b[0;38;5;141;48;5;235m cursor\u001b[0;38;5;28;48;5;235;1m [MATCH\u001b[0;38;5;71;48;5;235;1m pattern\u001b[0;38;5;28;48;5;235;1m] [COUNT\u001b[0;38;5;141;48;5;235m count\u001b[0;38;5;28;48;5;235;1m]\u001b[0;38;5;136;48;5;235m sin\r\u001b[65Cc\u001b[8A\r\u001b[21C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[18.5603, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[18.890406, "o", "\u001b[?25l\u001b[?7l\u001b[C\u001b[0m \u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m cars \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m myset \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[22C\u001b[0;38;5;231;48;5;30m kkk \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[22C\u001b[0;38;5;231;48;5;30m somestream \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[22C\u001b[0;38;5;231;48;5;30m af \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[22C\u001b[0;38;5;231;48;5;30m list:animals \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[22C\u001b[0;38;5;231;48;5;30m hash2 \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[18.895303, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mcars 0\u001b[0m \u001b[7D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[19.875157, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mcars\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[22C\u001b[0;38;5;16;48;5;231m cars \u001b[A\u001b[13D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[19.880817, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[20.080926, "o", "\u001b[?25l\u001b[?7l\u001b[26D\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0;38;5;28;1mZSCAN\u001b[0m \u001b[0;38;5;71mcars\u001b[0m \r\u001b[65C \r\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h\u001b[?2004l"] +[20.089992, "o", "\u001b[0m\u001b[?7h\u001b[0;38;5;102m(error) \u001b[0;38;5;197;1mwrong number of arguments for 'zscan' command\u001b[0m\u001b[0m"] +[20.091761, "o", "\u001b[0m\u001b[?7h\u001b[0m\r\r\n\u001b[0m"] +[20.092544, "o", "\u001b[?1l\u001b[6n"] +[20.101137, "o", "\u001b[?2004h\u001b[?25l\u001b[0m\u001b[?7l\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \r\u001b[7A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[20.109017, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \r\u001b[65C \r\u001b[8A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[21.330573, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;28;1mZSCAN\u001b[0m \u001b[0;38;5;71mcars\u001b[0m \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;167;48;5;235;1m(sorted_set) \u001b[0;38;5;28;48;5;235;1mZSCAN\u001b[0;38;5;71;48;5;235m key\u001b[0;38;5;141;48;5;235m cursor\u001b[0;38;5;28;48;5;235;1m [MATCH\u001b[0;38;5;71;48;5;235;1m pattern\u001b[0;38;5;28;48;5;235;1m] [COUNT\u001b[0;38;5;141;48;5;235m count\u001b[0;38;5;28;48;5;235;1m]\u001b[0;38;5;136;48;5;235m sin\r\u001b[65Cc\u001b[8A\r\u001b[26C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[21.340066, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[21.796556, "o", "\u001b[?25l\u001b[?7l\u001b[C\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[21.800207, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m0\u001b[0m \u001b[2D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[22.451791, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;141m0\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[22.460219, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[23.089162, "o", "\u001b[?25l\u001b[?7l\u001b[28D\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0;38;5;28;1mZSCAN\u001b[0m \u001b[0;38;5;71mcars\u001b[0m \u001b[0;38;5;141m0\u001b[0m \r\u001b[65C \r\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h\u001b[?2004l"] +[23.100459, "o", "\u001b[0m\u001b[?7h\u001b[0;38;5;102m(cursor) \u001b[0;38;5;141m0\u001b[0m\r\r\n\u001b[0m1)\u001b[0m \u001b[0;38;5;141m1367522908124000 \u001b[0;38;5;208m\"robins-car\"\u001b[0m\u001b[0m"] +[23.102113, "o", "\u001b[0m\u001b[?7h\u001b[0m\r\r\n\u001b[0m"] +[23.102697, "o", "\u001b[?1l"] +[23.102802, "o", "\u001b[6n"] +[23.105131, "o", "\u001b[?2004h\u001b[?25l\u001b[0m\u001b[?7l\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \r\u001b[7A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[23.108162, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \r\u001b[65C \r\u001b[8A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[25.209658, "o", "\u001b[?25l\u001b[?7l\u001b[0mt \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TTL \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TIME \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TYPE \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TOUCH \u001b[0;38;5;16;48;5;238m \u001b[4A\u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[25.218301, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mype cars\u001b[0m \u001b[9D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[25.35018, "o", "\u001b[?25l\u001b[?7l\u001b[0my \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m TYPE \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[4A\u001b[17C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[25.354149, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mpe cars\u001b[0m \u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[25.529032, "o", "\u001b[?25l\u001b[?7l\u001b[0mp \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m TYPE\u001b[C \u001b[0;38;5;16;48;5;238m \u001b[A\u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[25.533149, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241me cars\u001b[0m \u001b[7D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[25.630584, "o", "\u001b[?25l\u001b[?7l\u001b[3D\u001b[0;38;5;28;1mtype\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m TYPE\u001b[C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;167;48;5;235;1m(generic) \u001b[0;38;5;28;48;5;235;1mTYPE\u001b[0;38;5;71;48;5;235m key\u001b[0;38;5;136;48;5;235m since: 1.0.0\u001b[0;38;5;241;48;5;235m complexity:O(1)\u001b[8A\u001b[29D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[25.634871, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m cars\u001b[0m \u001b[6D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[25.742093, "o", "\u001b[?25l\u001b[?7l\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m cars \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m myset \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m kkk \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m somestream \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m af \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m list:animals \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m hash2 \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[25.750379, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mcars\u001b[0m \u001b[5D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[25.984703, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71ml\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30mist:animals\u001b[3C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30mist:buildings\u001b[C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30mist:restaurant\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mmy\u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30mist1\u001b[0;38;5;231;48;5;30m \u001b[6C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mSici\u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30my\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[7A\u001b[17D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[25.988778, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mist:animals\u001b[0m \u001b[12D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[26.206791, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mi\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[22C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mli\u001b[0;38;5;238;48;5;30mst:animals\u001b[3C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[22C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mli\u001b[0;38;5;238;48;5;30mst:buildings\u001b[C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[22C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mli\u001b[0;38;5;238;48;5;30mst:restaurant\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[22C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mmy\u001b[0;38;5;231;48;5;30;1;4mli\u001b[0;38;5;238;48;5;30mst1\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[5A\u001b[22C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[26.213146, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mst:animals\u001b[0m \u001b[11D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[26.905529, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mst:animals\u001b[0m\r\r\n\u001b[23C\u001b[0;38;5;16;48;5;231m \u001b[0;38;5;16;48;5;231;4mli\u001b[0;48;5;231mst:animals\u001b[0;38;5;16;48;5;231m \u001b[A\u001b[7D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[26.915375, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[27.735947, "o", "\u001b[?25l\u001b[?7l\u001b[33D\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0;38;5;28;1mtype\u001b[0m \u001b[0;38;5;71mlist:animals\u001b[0m \r\u001b[65C \r\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h\u001b[?2004l"] +[27.740639, "o", "\u001b[0m\u001b[?7h\u001b[0m\"list\"\u001b[0m\u001b[0m"] +[27.743095, "o", "\u001b[0m\u001b[?7h\u001b[0m\r\r\n\u001b[0m"] +[27.743675, "o", "\u001b[?1l"] +[27.74377, "o", "\u001b[6n"] +[27.746106, "o", "\u001b[?2004h\u001b[?25l\u001b[0m\u001b[?7l\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \r\u001b[7A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[27.750128, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \r\u001b[65C \r\u001b[8A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[28.104759, "o", "\u001b[?25l\u001b[?7l\u001b[0ml \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LSET \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LREM \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LPOP \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LLEN \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LTRIM \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LPUSH \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LRANGE \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[11D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[28.108111, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mrange list:animals 0 6\u001b[0m \u001b[23D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[28.254897, "o", "\u001b[?25l\u001b[?7l\u001b[0ml \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m LLEN \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[7A\u001b[10D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[28.259097, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241men testKeyDB2\u001b[0m \u001b[14D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[28.758049, "o", "\u001b[?25l\u001b[?7l\u001b[2D\u001b[0;38;5;28;1mLLEN\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0;38;5;16;48;5;231m LLEN \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;167;48;5;235;1m(list) \u001b[0;38;5;28;48;5;235;1mLLEN\u001b[0;38;5;71;48;5;235m key\u001b[0;38;5;136;48;5;235m since: 1.0.0\u001b[0;38;5;241;48;5;235m complexity:O(1)\u001b[8A\u001b[26D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[28.762078, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[28.981063, "o", "\u001b[?25l\u001b[?7l\u001b[C\u001b[0m \u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m list:animals \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m cars \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m myset \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m kkk \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m somestream \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m af \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m hash2 \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[28.987768, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mlist:animals\u001b[0m \u001b[13D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[29.889228, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mi\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30ml\u001b[0;38;5;231;48;5;30;1;4mi\u001b[0;38;5;238;48;5;30mst:animals\u001b[3C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30ml\u001b[0;38;5;231;48;5;30;1;4mi\u001b[0;38;5;238;48;5;30mst:buildings\u001b[C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mS\u001b[0;38;5;231;48;5;30;1;4mi\u001b[0;38;5;238;48;5;30mcily\u001b[9C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30ml\u001b[0;38;5;231;48;5;30;1;4mi\u001b[0;38;5;238;48;5;30mst:restaurant\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mmyl\u001b[0;38;5;231;48;5;30;1;4mi\u001b[0;38;5;238;48;5;30mst1\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[7A\u001b[17D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[29.895168, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[30.516043, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[5A\u001b[20C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[30.520459, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[30.845385, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71ml\u001b[0m \u001b[0m\r\r\n\u001b[22C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30mist:animals\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[22C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30mist:buildings\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[22C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30mist:restaurant\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[22C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mmy\u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30mist1\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[22C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mSici\u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30my\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[5A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[30.84925, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mist:animals\u001b[0m \u001b[12D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[31.051905, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mi\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[22C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mli\u001b[0;38;5;238;48;5;30mst:animals\u001b[3C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[22C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mli\u001b[0;38;5;238;48;5;30mst:buildings\u001b[C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[22C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4mli\u001b[0;38;5;238;48;5;30mst:restaurant\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[22C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mmy\u001b[0;38;5;231;48;5;30;1;4mli\u001b[0;38;5;238;48;5;30mst1\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[5A\u001b[22C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[31.055859, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mst:animals\u001b[0m \u001b[11D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[31.292784, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mst:animals\u001b[0m\r\r\n\u001b[23C\u001b[0;38;5;16;48;5;231m \u001b[0;38;5;16;48;5;231;4mli\u001b[0;48;5;231mst:animals\u001b[0;38;5;16;48;5;231m \u001b[A\u001b[7D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[31.296722, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[32.658483, "o", "\u001b[?25l\u001b[?7l\u001b[33D\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0;38;5;28;1mLLEN\u001b[0m \u001b[0;38;5;71mlist:animals\u001b[0m \r\u001b[65C \r\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h\u001b[?2004l"] +[32.662927, "o", "\u001b[0m\u001b[?7h\u001b[0;38;5;102m(integer) \u001b[0m51\u001b[0m\u001b[0m"] +[32.664937, "o", "\u001b[0m\u001b[?7h\u001b[0m\r\r\n\u001b[0m"] +[32.665552, "o", "\u001b[?1l"] +[32.665646, "o", "\u001b[6n"] +[32.66873, "o", "\u001b[?2004h\u001b[?25l\u001b[0m\u001b[?7l\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \r\u001b[7A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[32.671953, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \r\u001b[65C \r\u001b[8A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[35.303978, "o", "\u001b[?25l\u001b[?7l\u001b[0ml \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LSET \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LREM \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LPOP \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LLEN \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LTRIM \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LPUSH \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m LRANGE \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[11D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[35.320666, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mrange list:animals 0 6\u001b[0m \u001b[23D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[35.652587, "o", "\u001b[?25l\u001b[?7l\u001b[0mr \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m LREM\u001b[3C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m LRANGE \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[7A\u001b[10D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[35.656638, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mange list:animals 0 6\u001b[0m \u001b[22D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[35.741188, "o", "\u001b[?25l\u001b[?7l\u001b[0ma \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m LRANGE \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[2A\u001b[18C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[35.744004, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mnge list:animals 0 6\u001b[0m \u001b[21D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[35.819735, "o", "\u001b[?25l\u001b[?7l\u001b[0mn \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m LRANGE \u001b[0;38;5;16;48;5;238m \u001b[A\u001b[9D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[35.823559, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mge list:animals 0 6\u001b[0m \u001b[20D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[35.956968, "o", "\u001b[?25l\u001b[?7l\u001b[0mg \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m LRANGE \u001b[0;38;5;16;48;5;238m \u001b[A\u001b[9D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[35.960667, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241me list:animals 0 6\u001b[0m \u001b[19D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[36.069943, "o", "\u001b[?25l\u001b[?7l\u001b[5D\u001b[0;38;5;28;1mlrange\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m LRANGE \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;167;48;5;235;1m(list) \u001b[0;38;5;28;48;5;235;1mLRANGE\u001b[0;38;5;71;48;5;235m key\u001b[0;38;5;141;48;5;235m start stop\u001b[0;38;5;136;48;5;235m since: 1.0.0\u001b[0;38;5;241;48;5;235m complexity:O(S+N) whe\r\u001b[65Cr\u001b[8A\r\u001b[22C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[36.076669, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m list:animals 0 6\u001b[0m \u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[36.209277, "o", "\u001b[?25l\u001b[?7l\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[22C\u001b[0m \u001b[0;38;5;231;48;5;30m list:animals \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[23C\u001b[0;38;5;231;48;5;30m cars \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[23C\u001b[0;38;5;231;48;5;30m myset \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[23C\u001b[0;38;5;231;48;5;30m kkk \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[23C\u001b[0;38;5;231;48;5;30m somestream \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[23C\u001b[0;38;5;231;48;5;30m af \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[23C\u001b[0;38;5;231;48;5;30m hash2 \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[36.216403, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mlist:animals 0 6\u001b[0m \u001b[17D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[37.3095, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71ml\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[23C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30mist:animals\u001b[3C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[23C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30mist:buildings\u001b[C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[23C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30mist:restaurant\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[23C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mmy\u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30mist1\u001b[8C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[23C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mSici\u001b[0;38;5;231;48;5;30;1;4ml\u001b[0;38;5;238;48;5;30my\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[23C\u001b[0m \u001b[7A\u001b[17D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[37.319061, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mist:animals 0 6\u001b[0m \u001b[16D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[37.965239, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mist:animals\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[24C\u001b[0;38;5;16;48;5;231m \u001b[0;38;5;16;48;5;231;4ml\u001b[0;48;5;231mist:animals\u001b[0;38;5;16;48;5;231m \u001b[A\u001b[6D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[37.96939, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[38.184492, "o", "\u001b[?25l\u001b[?7l\u001b[C\u001b[0m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[5A\u001b[35C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[38.189811, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m0 6\u001b[0m \u001b[4D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[38.809319, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;141m0\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[38.813992, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m 6\u001b[0m \u001b[3D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[38.969048, "o", "\u001b[?25l\u001b[?7l\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[38.973767, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m6\u001b[0m \u001b[2D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[41.005131, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;141m6\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[41.015952, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[41.427252, "o", "\u001b[?25l\u001b[?7l\u001b[39D\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0;38;5;28;1mlrange\u001b[0m \u001b[0;38;5;71mlist:animals\u001b[0m \u001b[0;38;5;141m0\u001b[0m \u001b[0;38;5;141m6\u001b[0m \r\u001b[65C \r\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h\u001b[?2004l"] +[41.437426, "o", "\u001b[0m\u001b[?7h\u001b[0m1)\u001b[0m \u001b[0;38;5;208m\"wolf\"\u001b[0m\r\r\n\u001b[0m2)\u001b[0m \u001b[0;38;5;208m\"turtle\"\u001b[0m\r\r\n\u001b[0m3)\u001b[0m \u001b[0;38;5;208m\"tiger\"\u001b[0m\r\r\n\u001b[0m4)\u001b[0m \u001b[0;38;5;208m\"squirrel\"\u001b[0m\r\r\n\u001b[0m5)\u001b[0m \u001b[0;38;5;208m\"spider\"\u001b[0m\r\r\n\u001b[0m6)\u001b[0m \u001b[0;38;5;208m\"snake\"\u001b[0m\r\r\n\u001b[0m7)\u001b[0m \u001b[0;38;5;208m\"snail\"\u001b[0m\u001b[0m"] +[41.439085, "o", "\u001b[0m\u001b[?7h\u001b[0m\r\r\n\u001b[0m"] +[41.439711, "o", "\u001b[?1l"] +[41.439807, "o", "\u001b[6n"] +[41.444224, "o", "\u001b[?2004h\u001b[?25l\u001b[0m\u001b[?7l\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \r\u001b[7A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[41.447447, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \r\u001b[65C \r\u001b[8A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[45.439479, "o", "\u001b[?25l\u001b[?7l\u001b[0mt \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TTL \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TIME \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TYPE \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m TOUCH \u001b[0;38;5;16;48;5;238m \u001b[4A\u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[45.444328, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mype list:animals\u001b[0m \u001b[17D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[45.592128, "o", "\u001b[?25l\u001b[?7l\u001b[0my \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m TYPE \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[4A\u001b[17C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[45.59538, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mpe list:animals\u001b[0m \u001b[16D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[45.812073, "o", "\u001b[?25l\u001b[?7l\u001b[0mp \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m TYPE\u001b[C \u001b[0;38;5;16;48;5;238m \u001b[A\u001b[8D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[45.816301, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241me list:animals\u001b[0m \u001b[15D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[45.953551, "o", "\u001b[?25l\u001b[?7l\u001b[3D\u001b[0;38;5;28;1mtype\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m TYPE\u001b[C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;167;48;5;235;1m(generic) \u001b[0;38;5;28;48;5;235;1mTYPE\u001b[0;38;5;71;48;5;235m key\u001b[0;38;5;136;48;5;235m since: 1.0.0\u001b[0;38;5;241;48;5;235m complexity:O(1)\u001b[8A\u001b[29D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[45.958932, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m list:animals\u001b[0m \u001b[14D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[46.676064, "o", "\u001b[?25l\u001b[?7l\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m list:animals \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m cars \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m myset \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m kkk \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m somestream \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m af \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m hash2 \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[46.68263, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mlist:animals\u001b[0m \u001b[13D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[46.908434, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mlist:animals\u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;16;48;5;231m list:animals \u001b[A\u001b[5D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[46.912994, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[47.594674, "o", "\u001b[?25l\u001b[?7l\u001b[12D\u001b[0;38;5;71mcars\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m list:animals \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;16;48;5;231m cars \u001b[2A\u001b[13D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[47.599769, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[48.036896, "o", "\u001b[?25l\u001b[?7l\u001b[4D\u001b[0;38;5;71mmyset\u001b[0m \u001b[0m\r\r\n\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m cars \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;16;48;5;231m myset \u001b[3A\u001b[12D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[48.041407, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[48.555102, "o", "\u001b[?25l\u001b[?7l\u001b[5D\u001b[0;38;5;71mkkk\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\r\r\n\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m myset \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;16;48;5;231m kkk \u001b[4A\u001b[14D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[48.559223, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[48.744603, "o", "\u001b[?25l\u001b[?7l\u001b[3D\u001b[0;38;5;71msomestream\u001b[0m \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m kkk \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;16;48;5;231m somestream \u001b[5A\u001b[7D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[48.751509, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[48.895622, "o", "\u001b[?25l\u001b[?7l\u001b[10D\u001b[0;38;5;71maf\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[21C\u001b[0;38;5;231;48;5;30m somestream \u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;16;48;5;231m af \u001b[6A\u001b[15D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[48.900841, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[50.400124, "o", "\u001b[?25l\u001b[?7l\u001b[23D\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0;38;5;28;1mtype\u001b[0m \u001b[0;38;5;71maf\u001b[0m \r\u001b[65C \r\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h\u001b[?2004l"] +[50.41034, "o", "\u001b[0m\u001b[?7h\u001b[0m\"string\"\u001b[0m\u001b[0m"] +[50.412186, "o", "\u001b[0m\u001b[?7h\u001b[0m\r\r\n\u001b[0m"] +[50.41283, "o", "\u001b[?1l"] +[50.41295, "o", "\u001b[6n"] +[50.415152, "o", "\u001b[?2004h\u001b[?25l\u001b[0m\u001b[?7l\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \r\u001b[7A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[50.419664, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \r\u001b[65C \r\u001b[8A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[51.542536, "o", "\u001b[?25l\u001b[?7l\u001b[0mg \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GET \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GETSET \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GETBIT \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GEOPOS \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GEOADD \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GEOHASH \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GEODIST \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[20D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[51.555077, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241met foo\u001b[0m \u001b[7D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[51.630144, "o", "\u001b[?25l\u001b[?7l\u001b[0me \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GET\u001b[14C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GETSET\u001b[11C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GETBIT\u001b[11C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GEOPOS\u001b[11C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GEOA\u001b[CD\u001b[11C \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GEOHASH\u001b[10C \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GEODIST\u001b[10C \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[20D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[51.635334, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mt foo\u001b[0m \u001b[6D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[51.773743, "o", "\u001b[?25l\u001b[?7l\u001b[2D\u001b[0;38;5;28;1mget\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m GET\u001b[6C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m GETSET\u001b[3C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m GETBIT\u001b[3C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m GETRANGE \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0m\r\r\n\u001b[0;38;5;167;48;5;235;1m(string) \u001b[0;38;5;28;48;5;235;1mGET\u001b[0;38;5;71;48;5;235m key\u001b[0;38;5;136;48;5;235m since: 1.0.0\u001b[0;38;5;241;48;5;235m complexity:O(1)\u001b[8A\u001b[28D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[51.77765, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m foo\u001b[0m \u001b[5D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[51.91592, "o", "\u001b[?25l\u001b[?7l\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m af\u001b[6C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m list:animals \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m cars \u001b[3C \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m myset \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[20C\u001b[0;38;5;231;48;5;30m kkk \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[20C\u001b[0;38;5;231;48;5;30m somestream \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[20C\u001b[0;38;5;231;48;5;30m hash2 \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[51.921861, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mfoo\u001b[0m \u001b[4D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[52.325226, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71ma\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30mf\u001b[13C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;231;48;5;30m \u001b[4C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30mbc\u001b[12C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mc\u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30mrs\u001b[11C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mh\u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30msh2\u001b[10C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mh\u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30msh3\u001b[0;38;5;231;48;5;30m \u001b[6C \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mh\u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30msh1"] +[52.32535, "o", "\u001b[10C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[52.329701, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[52.448681, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mf\u001b[0m \u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4maf\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[7A\u001b[17D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[52.453078, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[A\u001b[21C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[52.892111, "o", "\u001b[?25l\u001b[?7l\u001b[22D\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0;38;5;28;1mget\u001b[0m \u001b[0;38;5;71maf\u001b[0m \r\u001b[65C \r\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h\u001b[?2004l"] +[52.896263, "o", "\u001b[0m\u001b[?7h\u001b[0m\"asdf\"\u001b[0m\u001b[0m"] +[52.898075, "o", "\u001b[0m\u001b[?7h\u001b[0m\r\r\n\u001b[0m"] +[52.898599, "o", "\u001b[?1l\u001b[6n"] +[52.90232, "o", "\u001b[?2004h\u001b[?25l\u001b[0m\u001b[?7l\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \r\u001b[7A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[52.905874, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \r\u001b[65C \r\u001b[8A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[53.943112, "o", "\u001b[?25l\u001b[?7l\u001b[0mg \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GET \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GETSET \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GETBIT \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GEOPOS \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GEOADD \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GEOHASH \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m GEODIST \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[20D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[53.9504, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241met af\u001b[0m \u001b[6D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[54.043955, "o", "\u001b[?25l\u001b[?7l\u001b[0me \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GET\u001b[14C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GETSET\u001b[11C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GETBIT\u001b[11C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GEOPOS\u001b[11C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GEOA\u001b[CD\u001b[11C \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GEOHASH\u001b[10C \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m GEODIST\u001b[10C \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[20D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[54.047839, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mt af\u001b[0m \u001b[5D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[54.192601, "o", "\u001b[?25l\u001b[?7l\u001b[2D\u001b[0;38;5;28;1mget\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m GET\u001b[6C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m GETSET\u001b[3C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m GETBIT\u001b[3C\u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m GETRANGE \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0m\r\r\n\u001b[0;38;5;167;48;5;235;1m(string) \u001b[0;38;5;28;48;5;235;1mGET\u001b[0;38;5;71;48;5;235m key\u001b[0;38;5;136;48;5;235m since: 1.0.0\u001b[0;38;5;241;48;5;235m complexity:O(1)\u001b[8A\u001b[28D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[54.197235, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m af\u001b[0m \u001b[4D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[54.335864, "o", "\u001b[?25l\u001b[?7l\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m af\u001b[6C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m list:animals \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m cars \u001b[3C \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m myset \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[20C\u001b[0;38;5;231;48;5;30m kkk \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[20C\u001b[0;38;5;231;48;5;30m somestream \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[20C\u001b[0;38;5;231;48;5;30m hash2 \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[54.342312, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241maf\u001b[0m \u001b[3D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[54.76708, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71ma\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30mf\u001b[13C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;231;48;5;30m \u001b[4C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30mbc\u001b[12C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mc\u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30mrs\u001b[11C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mh\u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30msh2\u001b[10C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mh\u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30msh3\u001b[0;38;5;231;48;5;30m \u001b[6C \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mh\u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30msh1"] +[54.767202, "o", "\u001b[10C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[54.771478, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mf\u001b[0m \u001b[2D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[55.027261, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mf\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4maf\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0m \u001b[7A\u001b[17D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[55.03053, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[A\u001b[21C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[55.228293, "o", "\u001b[?25l\u001b[?7l\u001b[C\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[55.231931, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[55.573146, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196mi\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[55.577988, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[55.66374, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196mn\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[55.667964, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[55.984948, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196mv\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[55.98961, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[56.157229, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196ma\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[56.162529, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[56.423, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196ml\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[56.427638, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[56.586877, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196mi\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[56.593834, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[56.913957, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196md\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[56.918423, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[57.091248, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196me\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[57.095887, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[57.190026, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196m \u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[57.1952, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[57.430926, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196mi\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[57.435255, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[57.500268, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196mn\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[57.506086, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[57.711636, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196mp\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[57.715911, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[57.984832, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196mu\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[57.992887, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[58.141271, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;16;48;5;196mt\u001b[0m \b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[58.145592, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.061523, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.073482, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.309508, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.315274, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.34596, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.350846, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.379097, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.38583, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.416019, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.431899, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.446868, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.45367, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.479192, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.483837, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.512893, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.519325, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.546693, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.550989, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.581696, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.586075, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.613113, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.617986, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.648799, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.652827, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.800181, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.805545, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.955905, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[59.959298, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.208194, "o", "\u001b[?25l\u001b[?7l\u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.212447, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.247807, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.254547, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.278, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.2824, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.309265, "o", "\u001b[?25l\u001b[?7l\u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.313357, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.342096, "o", "\u001b[?25l\u001b[?7l\u001b[3D\u001b[0mge \u001b[0m\u001b[K\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \u001b[8A\u001b[29D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.352259, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.377642, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.38131, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.408313, "o", "\u001b[?25l\u001b[?7l\b\u001b[0m \u001b[0m\u001b[K\b\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.412424, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.449815, "o", "\u0007"] +[60.453021, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[60.473651, "o", "\u0007"] +[60.476542, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[62.514509, "o", "\u001b[?25l\u001b[?7l\u001b[0md \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m DEL \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m DECR \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m DUMP \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m DECRBY \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m DBSIZE \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m DISCARD \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0;38;5;231;48;5;30m DEBUG OBJECT \u001b[0;38;5;16;48;5;37m \u001b[7A\u001b[17D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[62.520623, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241mel _kombu.binding.celeryev\u001b[0m \u001b[27D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[62.683241, "o", "\u001b[?25l\u001b[?7l\u001b[0me \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m DEL\u001b[11C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m DECR\u001b[10C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m DECRBY\u001b[8C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m DEBUG\u001b[COBJECT\u001b[2C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[0;38;5;231;48;5;30m DEBUG SEGFAULT \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[17C\u001b[0m \u001b[7A\u001b[16D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[62.686861, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241ml _kombu.binding.celeryev\u001b[0m \u001b[26D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[62.885578, "o", "\u001b[?25l\u001b[?7l\u001b[2D\u001b[0;38;5;28;1mdel\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[18C\u001b[0m \u001b[0;38;5;231;48;5;30m DEL \u001b[0;38;5;16;48;5;238m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[C\u001b[0m\u001b[K\u001b[0m\r\r\n\r\r\n\r\r\n\u001b[0;38;5;167;48;5;235;1m(generic) \u001b[0;38;5;28;48;5;235;1mDEL\u001b[0;38;5;71;48;5;235m key\u001b[0;38;5;136;48;5;235m since: 1.0.0\u001b[0;38;5;241;48;5;235m complexity:O(N) where N is the n\r\u001b[65Cu\u001b[8A\r\u001b[19C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[62.890125, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m _kombu.binding.celeryev\u001b[0m \u001b[25D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[63.433741, "o", "\u001b[?25l\u001b[?7l\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[19C\u001b[0m \u001b[0;38;5;231;48;5;30m af \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0;38;5;231;48;5;30m list:animals \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0;38;5;231;48;5;30m cars \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[20C\u001b[0;38;5;231;48;5;30m myset \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[20C\u001b[0;38;5;231;48;5;30m kkk \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[20C\u001b[0;38;5;231;48;5;30m somestream \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[20C\u001b[0;38;5;231;48;5;30m hash2 \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[63.438223, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m_kombu.binding.celeryev\u001b[0m \u001b[24D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[64.652788, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71ma\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30mf\u001b[13C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;231;48;5;30m \u001b[4C \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30mbc\u001b[12C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mc\u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30mrs\u001b[11C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;238m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mh\u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30msh2\u001b[10C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;37m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mh\u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30msh3\u001b[0;38;5;231;48;5;30m \u001b[6C \u001b[0;38;5;16;48;5;248m \u001b[0m\r\r\n\u001b[20C\u001b[0m \u001b[0;38;5;231;48;5;30m \u001b[0;38;5;238;48;5;30mh\u001b[0;38;5;231;48;5;30;1;4ma\u001b[0;38;5;238;48;5;30msh1"] +[64.652904, "o", "\u001b[10C\u001b[0;38;5;231;48;5;30m \u001b[0;38;5;16;48;5;248m \u001b[7A\u001b[18D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[64.66165, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;241m\\\"bc\u001b[0m \u001b[5D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[65.254736, "o", "\u001b[?25l\u001b[?7l\u001b[0;38;5;71mf\u001b[0m \u001b[0m\u001b[K\u001b[0m\r\r\n\u001b[21C\u001b[0;38;5;16;48;5;231m \u001b[0;38;5;16;48;5;231;4ma\u001b[0;48;5;231mf\u001b[0;38;5;16;48;5;231m \u001b[A\u001b[16D\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[65.26029, "o", "\u001b[?25l\u001b[?7l\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[65.761821, "o", "\u001b[?25l\u001b[?7l\u001b[22D\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0;38;5;28;1mdel\u001b[0m \u001b[0;38;5;71maf\u001b[0m \r\u001b[65C \r\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h\u001b[?2004l"] +[65.766399, "o", "\u001b[0m\u001b[?7h\u001b[0;38;5;102m(integer) \u001b[0m1\u001b[0m\u001b[0m"] +[65.768122, "o", "\u001b[0m\u001b[?7h\u001b[0m\r\r\n\u001b[0m"] +[65.768819, "o", "\u001b[?1l\u001b[6n"] +[65.771167, "o", "\u001b[?2004h\u001b[?25l\u001b[0m\u001b[?7l\u001b[0m\u001b[J\u001b[0m127.0.0.1:6379> \u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0m \r\u001b[65C \r\u001b[7A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[65.774133, "o", "\u001b[?25l\u001b[?7l\u001b[0m\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\r\r\n\u001b[0;38;5;248;48;5;235mCtrl-D to exit; \r\u001b[65C \r\u001b[8A\u001b[16C\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h"] +[66.838972, "o", "\u001b[?25l\u001b[?7l\u001b[16D\u001b[0m\u001b[J\u001b[0;38;5;102m127.0.0.1:6379> \r\u001b[65C \r\u001b[0m\r\r\n\u001b[J\u001b[?7h\u001b[0m\u001b[?12l\u001b[?25h\u001b[?2004l"] +[66.839665, "o", "Goodbye!\r\n"] +[66.871374, "o", "\u001b[1m\u001b[7m%\u001b[27m\u001b[1m\u001b[0m \r \r"] +[66.893132, "o", "\u001b]133;D;0\u0007\u001b]1337;RemoteHost=laixintao@Chico.local\u0007\u001b]1337;CurrentDir=/Users/laixintao\u0007"] +[66.896847, "o", "\r\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b]133;A\u0007$ \u001b]133;B\u0007\u001b[K"] +[66.897062, "o", "\u001b[?1h\u001b="] +[66.897178, "o", "\u001b[?2004h"] +[67.725923, "o", "\u001b[?2004l\r\r\n"] diff --git a/docs/assets/demo.svg b/docs/assets/demo.svg new file mode 100644 index 0000000..6213d56 --- /dev/null +++ b/docs/assets/demo.svg @@ -0,0 +1,214 @@ +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="terminal" baseProfile="full" viewBox="0 0 528 342" width="528" version="1.1"> + <defs> + <termtosvg:template_settings xmlns:termtosvg="https://github.com/nbedos/termtosvg"> + <termtosvg:screen_geometry columns="66" rows="20"/> + <termtosvg:animation type="css"/> + </termtosvg:template_settings> + <style type="text/css" id="generated-style"><![CDATA[#screen { + font-family: 'DejaVu Sans Mono', monospace; + font-style: normal; + font-size: 14px; + } + + text { + dominant-baseline: text-before-edge; + white-space: pre; + } + + :root { + --animation-duration: 32720ms; + } + + @keyframes roll { + 0.000%{transform:translateY(0px)} +0.165%{transform:translateY(-374px)} +1.082%{transform:translateY(-748px)} +1.999%{transform:translateY(-1122px)} +2.289%{transform:translateY(-1496px)} +2.754%{transform:translateY(-1870px)} +3.108%{transform:translateY(-2244px)} +3.408%{transform:translateY(-2618px)} +3.826%{transform:translateY(-2992px)} +4.685%{transform:translateY(-3366px)} +5.602%{transform:translateY(-3740px)} +5.938%{transform:translateY(-4114px)} +6.317%{transform:translateY(-4488px)} +6.650%{transform:translateY(-4862px)} +7.424%{transform:translateY(-5236px)} +8.340%{transform:translateY(-5610px)} +9.254%{transform:translateY(-5984px)} +10.171%{transform:translateY(-6358px)} +10.917%{transform:translateY(-6732px)} +11.553%{transform:translateY(-7106px)} +11.953%{transform:translateY(-7480px)} +12.265%{transform:translateY(-7854px)} +13.182%{transform:translateY(-8228px)} +14.098%{transform:translateY(-8602px)} +15.015%{transform:translateY(-8976px)} +15.779%{transform:translateY(-9350px)} +16.696%{transform:translateY(-9724px)} +17.613%{transform:translateY(-10098px)} +17.845%{transform:translateY(-10472px)} +18.133%{transform:translateY(-10846px)} +19.050%{transform:translateY(-11220px)} +19.835%{transform:translateY(-11594px)} +20.752%{transform:translateY(-11968px)} +21.592%{transform:translateY(-12342px)} +22.216%{transform:translateY(-12716px)} +23.133%{transform:translateY(-13090px)} +24.050%{transform:translateY(-13464px)} +24.413%{transform:translateY(-13838px)} +24.917%{transform:translateY(-14212px)} +25.162%{transform:translateY(-14586px)} +25.504%{transform:translateY(-14960px)} +26.418%{transform:translateY(-15334px)} +26.687%{transform:translateY(-15708px)} +27.604%{transform:translateY(-16082px)} +28.521%{transform:translateY(-16456px)} +29.438%{transform:translateY(-16830px)} +30.238%{transform:translateY(-17204px)} +30.831%{transform:translateY(-17578px)} +31.748%{transform:translateY(-17952px)} +32.665%{transform:translateY(-18326px)} +33.582%{transform:translateY(-18700px)} +34.211%{transform:translateY(-19074px)} +35.128%{transform:translateY(-19448px)} +36.045%{transform:translateY(-19822px)} +36.962%{transform:translateY(-20196px)} +37.879%{transform:translateY(-20570px)} +38.796%{transform:translateY(-20944px)} +39.224%{transform:translateY(-21318px)} +39.771%{transform:translateY(-21692px)} +40.083%{transform:translateY(-22066px)} +40.422%{transform:translateY(-22440px)} +41.164%{transform:translateY(-22814px)} +41.843%{transform:translateY(-23188px)} +42.760%{transform:translateY(-23562px)} +43.677%{transform:translateY(-23936px)} +44.594%{transform:translateY(-24310px)} +45.052%{transform:translateY(-24684px)} +45.969%{transform:translateY(-25058px)} +46.650%{transform:translateY(-25432px)} +47.567%{transform:translateY(-25806px)} +48.484%{transform:translateY(-26180px)} +49.401%{transform:translateY(-26554px)} +50.034%{transform:translateY(-26928px)} +50.770%{transform:translateY(-27302px)} +51.687%{transform:translateY(-27676px)} +52.604%{transform:translateY(-28050px)} +53.521%{transform:translateY(-28424px)} +53.790%{transform:translateY(-28798px)} +54.031%{transform:translateY(-29172px)} +54.450%{transform:translateY(-29546px)} +54.795%{transform:translateY(-29920px)} +55.220%{transform:translateY(-30294px)} +56.137%{transform:translateY(-30668px)} +57.054%{transform:translateY(-31042px)} +57.723%{transform:translateY(-31416px)} +58.640%{transform:translateY(-31790px)} +59.129%{transform:translateY(-32164px)} +60.046%{transform:translateY(-32538px)} +60.963%{transform:translateY(-32912px)} +61.880%{transform:translateY(-33286px)} +62.347%{transform:translateY(-33660px)} +63.020%{transform:translateY(-34034px)} +63.450%{transform:translateY(-34408px)} +64.367%{transform:translateY(-34782px)} +65.079%{transform:translateY(-35156px)} +65.996%{transform:translateY(-35530px)} +66.913%{transform:translateY(-35904px)} +67.830%{transform:translateY(-36278px)} +68.408%{transform:translateY(-36652px)} +68.869%{transform:translateY(-37026px)} +69.786%{transform:translateY(-37400px)} +70.703%{transform:translateY(-37774px)} +70.972%{transform:translateY(-38148px)} +71.409%{transform:translateY(-38522px)} +71.846%{transform:translateY(-38896px)} +72.763%{transform:translateY(-39270px)} +73.139%{transform:translateY(-39644px)} +74.056%{transform:translateY(-40018px)} +74.972%{transform:translateY(-40392px)} +75.281%{transform:translateY(-40766px)} +75.733%{transform:translateY(-41140px)} +76.174%{transform:translateY(-41514px)} +77.090%{transform:translateY(-41888px)} +77.885%{transform:translateY(-42262px)} +78.499%{transform:translateY(-42636px)} +79.416%{transform:translateY(-43010px)} +79.694%{transform:translateY(-43384px)} +80.611%{transform:translateY(-43758px)} +81.137%{transform:translateY(-44132px)} +81.950%{transform:translateY(-44506px)} +82.448%{transform:translateY(-44880px)} +83.365%{transform:translateY(-45254px)} +83.909%{transform:translateY(-45628px)} +84.211%{transform:translateY(-46002px)} +84.945%{transform:translateY(-46376px)} +85.159%{transform:translateY(-46750px)} +85.804%{transform:translateY(-47124px)} +86.638%{transform:translateY(-47498px)} +87.118%{transform:translateY(-47872px)} +88.035%{transform:translateY(-48246px)} +88.793%{transform:translateY(-48620px)} +88.918%{transform:translateY(-48994px)} +89.117%{transform:translateY(-49368px)} +89.309%{transform:translateY(-49742px)} +89.435%{transform:translateY(-50116px)} +89.624%{transform:translateY(-50490px)} +89.829%{transform:translateY(-50864px)} +90.290%{transform:translateY(-51238px)} +90.767%{transform:translateY(-51612px)} +91.537%{transform:translateY(-51986px)} +91.681%{transform:translateY(-52360px)} +91.849%{transform:translateY(-52734px)} +91.980%{transform:translateY(-53108px)} +92.152%{transform:translateY(-53482px)} +92.277%{transform:translateY(-53856px)} +93.194%{transform:translateY(-54230px)} +93.710%{transform:translateY(-54604px)} +94.328%{transform:translateY(-54978px)} +95.244%{transform:translateY(-55352px)} +96.161%{transform:translateY(-55726px)} +97.078%{transform:translateY(-56100px)} +97.995%{transform:translateY(-56474px)} +98.912%{transform:translateY(-56848px)} +99.077%{transform:translateY(-57222px)} +99.994%{transform:translateY(-57596px)} +100.000%{transform:translateY(-57596px)} + } + + #screen_view { + animation-duration: 32720ms; + animation-iteration-count:infinite; + animation-name:roll; + animation-timing-function: steps(1,end); + animation-fill-mode: forwards; + } + ]]></style> + <style type="text/css" id="user-style"> + /* The colors defined below are the default 16 colors used for rendering text of the terminal. Adjust + them as needed. + gjm8 color theme (source: https://terminal.sexy/) */ + .foreground {fill: #c5c5c5;} + .background {fill: #1c1c1c;} + .color0 {fill: #1c1c1c;} + .color1 {fill: #ff005b;} + .color2 {fill: #cee318;} + .color3 {fill: #ffe755;} + .color4 {fill: #048ac7;} + .color5 {fill: #833c9f;} + .color6 {fill: #0ac1cd;} + .color7 {fill: #e5e5e5;} + .color8 {fill: #1c1c1c;} + .color9 {fill: #ff005b;} + .color10 {fill: #cee318;} + .color11 {fill: #ffe755;} + .color12 {fill: #048ac7;} + .color13 {fill: #833c9f;} + .color14 {fill: #0ac1cd;} + .color15 {fill: #e5e5e5;} + </style> + </defs> + <svg id="screen" width="528" height="340" viewBox="0 0 528 340" preserveAspectRatio="xMidYMin slice"><rect class="background" height="100%" width="100%" x="0" y="0"/><defs><g id="g1"><text x="0" textLength="8" class="background"> </text><text x="8" textLength="520" class="foreground"> </text></g><g id="g2"><text x="0" textLength="16" class="foreground">$ </text><text x="16" textLength="8" class="background"> </text><text x="24" textLength="504" class="foreground"> </text></g><g id="g3"><text x="0" textLength="24" class="foreground">$ i</text><text x="24" textLength="8" class="background"> </text><text x="32" textLength="496" class="foreground"> </text></g><g id="g4"><text x="0" textLength="32" class="foreground">$ ir</text><text x="32" textLength="8" class="background"> </text><text x="40" textLength="488" class="foreground"> </text></g><g id="g5"><text x="0" textLength="40" class="foreground">$ ire</text><text x="40" textLength="8" class="background"> </text><text x="48" textLength="480" class="foreground"> </text></g><g id="g6"><text x="0" textLength="48" class="foreground">$ ired</text><text x="48" textLength="8" class="background"> </text><text x="56" textLength="472" class="foreground"> </text></g><g id="g7"><text x="0" textLength="56" class="foreground">$ iredi</text><text x="56" textLength="8" class="background"> </text><text x="64" textLength="464" class="foreground"> </text></g><g id="g8"><text x="0" textLength="64" class="foreground">$ iredis</text><text x="64" textLength="8" class="background"> </text><text x="72" textLength="456" class="foreground"> </text></g><g id="g9"><text x="0" textLength="528" class="foreground">$ iredis </text></g><g id="g10"><text x="0" textLength="8" class="background"> </text></g><g id="g11"><text x="0" textLength="104" class="foreground">iredis 0.8.0</text></g><g id="g12"><text x="0" textLength="160" class="foreground">redis-server 5.0.6 </text></g><g id="g13"><text x="0" textLength="200" class="foreground">Home: https://iredis.io</text></g><g id="g14"><text x="0" textLength="256" class="foreground">Issues: https://iredis.io/issues</text></g><g id="g15"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="8" class="background"> </text><text x="136" textLength="392" class="foreground"> </text></g><g id="g16"><text x="0" textLength="528" class="foreground"> </text></g><g id="g17"><text x="0" textLength="528" fill="#a8a8a8">Ctrl-D to exit; </text></g><g id="g18"><text x="0" textLength="136" class="foreground">127.0.0.1:6379> k</text><text x="136" textLength="8" class="background">e</text><text x="144" textLength="32" fill="#626262">ys *</text><text x="176" textLength="352" class="foreground"> </text></g><g id="g19"><text x="136" textLength="56" fill="#ffffff"> KEYS </text><text x="192" textLength="8" fill="#000000"> </text></g><g id="g20"><text x="0" textLength="144" class="foreground">127.0.0.1:6379> ke</text><text x="144" textLength="8" class="background">y</text><text x="152" textLength="24" fill="#626262">s *</text><text x="176" textLength="352" class="foreground"> </text></g><g id="g21"><text x="136" textLength="8" class="foreground"> </text><text x="144" textLength="56" fill="#ffffff"> KEYS </text><text x="200" textLength="8" fill="#000000"> </text></g><g id="g22"><text x="0" textLength="152" class="foreground">127.0.0.1:6379> key</text><text x="152" textLength="8" class="background">s</text><text x="160" textLength="16" fill="#626262"> *</text><text x="176" textLength="352" class="foreground"> </text></g><g id="g23"><text x="136" textLength="16" class="foreground"> </text><text x="152" textLength="56" fill="#ffffff"> KEYS </text><text x="208" textLength="8" fill="#000000"> </text></g><g id="g24"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">keys</text><text x="160" textLength="8" class="background"> </text><text x="168" textLength="8" fill="#626262">*</text><text x="176" textLength="352" class="foreground"> </text></g><g id="g25"><text x="136" textLength="24" class="foreground"> </text><text x="160" textLength="56" fill="#ffffff"> KEYS </text><text x="216" textLength="8" fill="#000000"> </text></g><g id="g26"><text x="0" textLength="80" font-weight="bold" fill="#d75f5f">(generic) </text><text x="80" textLength="32" font-weight="bold" fill="#008700">KEYS</text><text x="112" textLength="64" font-weight="bold" fill="#5faf5f"> pattern</text><text x="176" textLength="120" fill="#af8700"> since: 1.0.0</text><text x="296" textLength="232" fill="#626262"> complexity:O(N) with N being</text></g><g id="g27"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">keys</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="8" class="background">*</text><text x="176" textLength="352" class="foreground"> </text></g><g id="g28"><text x="8" textLength="520" class="foreground"> </text></g><g id="g29"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">keys</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="8" font-weight="bold" fill="#5faf5f">*</text><text x="176" textLength="8" class="background"> </text><text x="184" textLength="344" class="foreground"> </text></g><g id="g30"><text x="0" textLength="32" class="foreground">10) </text><text x="32" textLength="56" fill="#5faf5f">"hash1"</text></g><g id="g31"><text x="0" textLength="32" class="foreground">11) </text><text x="32" textLength="128" fill="#5faf5f">"list:buildings"</text></g><g id="g32"><text x="0" textLength="32" class="foreground">12) </text><text x="32" textLength="56" fill="#5faf5f">"hash3"</text></g><g id="g33"><text x="0" textLength="32" class="foreground">13) </text><text x="32" textLength="64" fill="#5faf5f">"fooset"</text><text x="96" textLength="432" class="foreground"> </text></g><g id="g34"><text x="0" textLength="32" class="foreground">14) </text><text x="32" textLength="40" fill="#5faf5f">"foo"</text><text x="72" textLength="456" class="foreground"> </text></g><g id="g35"><text x="0" textLength="32" class="foreground">15) </text><text x="32" textLength="56" fill="#5faf5f">"myset"</text></g><g id="g36"><text x="0" textLength="32" class="foreground">16) </text><text x="32" textLength="56" fill="#5faf5f">"hash2"</text></g><g id="g37"><text x="0" textLength="32" class="foreground">17) </text><text x="32" textLength="112" fill="#5faf5f">"list:animals"</text></g><g id="g38"><text x="0" textLength="32" class="foreground">18) </text><text x="32" textLength="32" fill="#5faf5f">"af"</text></g><g id="g39"><text x="0" textLength="32" class="foreground">19) </text><text x="32" textLength="96" fill="#5faf5f">"somestream"</text></g><g id="g40"><text x="0" textLength="32" class="foreground">20) </text><text x="32" textLength="40" fill="#5faf5f">"kkk"</text></g><g id="g41"><text x="0" textLength="136" class="foreground">127.0.0.1:6379> t</text><text x="136" textLength="8" class="background">y</text><text x="144" textLength="64" fill="#626262">pe myset</text><text x="208" textLength="320" class="foreground"> </text></g><g id="g42"><text x="136" textLength="56" fill="#ffffff"> TTL </text><text x="192" textLength="8" fill="#000000"> </text></g><g id="g43"><text x="136" textLength="56" fill="#ffffff"> TIME </text><text x="192" textLength="8" fill="#000000"> </text></g><g id="g44"><text x="136" textLength="56" fill="#ffffff"> TYPE </text><text x="192" textLength="8" fill="#000000"> </text></g><g id="g45"><text x="136" textLength="56" fill="#ffffff"> TOUCH </text><text x="192" textLength="8" fill="#000000"> </text></g><g id="g46"><text x="0" textLength="144" class="foreground">127.0.0.1:6379> ty</text><text x="144" textLength="8" class="background">p</text><text x="152" textLength="56" fill="#626262">e myset</text><text x="208" textLength="320" class="foreground"> </text></g><g id="g47"><text x="136" textLength="8" class="foreground"> </text><text x="144" textLength="56" fill="#ffffff"> TYPE </text><text x="200" textLength="8" fill="#000000"> </text></g><g id="g48"><text x="0" textLength="152" class="foreground">127.0.0.1:6379> typ</text><text x="152" textLength="8" class="background">e</text><text x="160" textLength="48" fill="#626262"> myset</text><text x="208" textLength="320" class="foreground"> </text></g><g id="g49"><text x="136" textLength="16" class="foreground"> </text><text x="152" textLength="56" fill="#ffffff"> TYPE </text><text x="208" textLength="8" fill="#000000"> </text></g><g id="g50"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="background"> </text><text x="168" textLength="40" fill="#626262">myset</text><text x="208" textLength="320" class="foreground"> </text></g><g id="g51"><text x="136" textLength="24" class="foreground"> </text><text x="160" textLength="56" fill="#ffffff"> TYPE </text><text x="216" textLength="8" fill="#000000"> </text></g><g id="g52"><text x="0" textLength="80" font-weight="bold" fill="#d75f5f">(generic) </text><text x="80" textLength="32" font-weight="bold" fill="#008700">TYPE</text><text x="112" textLength="32" fill="#5faf5f"> key</text><text x="144" textLength="120" fill="#af8700"> since: 1.0.0</text><text x="264" textLength="128" fill="#626262"> complexity:O(1)</text><text x="392" textLength="136" fill="#a8a8a8"> </text></g><g id="g53"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="8" class="background">m</text><text x="176" textLength="32" fill="#626262">yset</text><text x="208" textLength="320" class="foreground"> </text></g><g id="g54"><text x="136" textLength="32" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> kkk </text><text x="304" textLength="8" fill="#000000"> </text></g><g id="g55"><text x="8" textLength="160" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> somestream </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g56"><text x="8" textLength="160" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> af </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g57"><text x="8" textLength="160" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> list:animals </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g58"><text x="168" textLength="136" fill="#ffffff"> hash2 </text><text x="304" textLength="8" fill="#000000"> </text></g><g id="g59"><text x="168" textLength="136" fill="#ffffff"> myset </text><text x="304" textLength="8" fill="#000000"> </text></g><g id="g60"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> foo </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g61"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="8" fill="#5faf5f">m</text><text x="176" textLength="8" class="background">y</text><text x="184" textLength="24" fill="#626262">set</text><text x="208" textLength="320" class="foreground"> </text></g><g id="g62"><text x="136" textLength="40" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">m</text><text x="192" textLength="32" fill="#444444">yset</text><text x="224" textLength="64" fill="#ffffff"> </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g63"><text x="8" textLength="168" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">m</text><text x="192" textLength="48" fill="#444444">stream</text><text x="240" textLength="48" fill="#ffffff"> </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g64"><text x="8" textLength="168" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">m</text><text x="192" textLength="48" fill="#444444">ylist1</text><text x="240" textLength="48" fill="#ffffff"> </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g65"><text x="8" textLength="168" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">m</text><text x="192" textLength="40" fill="#444444">yzset</text><text x="232" textLength="56" fill="#ffffff"> </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g66"><text x="168" textLength="8" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="16" fill="#444444">so</text><text x="200" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">m</text><text x="208" textLength="56" fill="#444444">estream</text><text x="264" textLength="24" fill="#ffffff"> </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g67"><text x="168" textLength="8" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="64" fill="#444444">list:ani</text><text x="248" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">m</text><text x="256" textLength="24" fill="#444444">als</text><text x="280" textLength="8" fill="#ffffff"> </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g68"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="16" fill="#5faf5f">my</text><text x="184" textLength="8" class="background">s</text><text x="192" textLength="16" fill="#626262">et</text><text x="208" textLength="320" class="foreground"> </text></g><g id="g69"><text x="136" textLength="48" class="foreground"> </text><text x="184" textLength="8" fill="#ffffff"> </text><text x="192" textLength="16" font-weight="bold" text-decoration="underline" fill="#ffffff">my</text><text x="208" textLength="24" fill="#444444">set</text><text x="232" textLength="24" fill="#ffffff"> </text><text x="256" textLength="8" fill="#000000"> </text><text x="264" textLength="264" class="foreground"> </text></g><g id="g70"><text x="8" textLength="176" class="foreground"> </text><text x="184" textLength="8" fill="#ffffff"> </text><text x="192" textLength="16" font-weight="bold" text-decoration="underline" fill="#ffffff">my</text><text x="208" textLength="40" fill="#444444">list1</text><text x="248" textLength="8" fill="#ffffff"> </text><text x="256" textLength="8" fill="#000000"> </text><text x="264" textLength="264" class="foreground"> </text></g><g id="g71"><text x="8" textLength="176" class="foreground"> </text><text x="184" textLength="8" fill="#ffffff"> </text><text x="192" textLength="16" font-weight="bold" text-decoration="underline" fill="#ffffff">my</text><text x="208" textLength="32" fill="#444444">zset</text><text x="240" textLength="16" fill="#ffffff"> </text><text x="256" textLength="8" fill="#000000"> </text><text x="264" textLength="264" class="foreground"> </text></g><g id="g72"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="40" fill="#5faf5f">myset</text><text x="208" textLength="8" class="background"> </text><text x="216" textLength="312" class="foreground"> </text></g><g id="g73"><text x="136" textLength="48" class="foreground"> </text><text x="184" textLength="8" fill="#000000"> </text><text x="192" textLength="16" text-decoration="underline" fill="#000000">my</text><text x="208" textLength="24" class="foreground">set</text><text x="232" textLength="32" fill="#000000"> </text><text x="264" textLength="264" class="foreground"> </text></g><g id="g74"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="40" fill="#5faf5f">myset</text><text x="208" textLength="320" class="foreground"> </text></g><g id="g75"><text x="0" textLength="528" class="foreground">"set" </text></g><g id="g76"><text x="0" textLength="136" class="foreground">127.0.0.1:6379> s</text><text x="136" textLength="8" class="background">e</text><text x="144" textLength="72" fill="#626262">t foo bar</text><text x="216" textLength="312" class="foreground"> </text></g><g id="g77"><text x="8" textLength="128" class="foreground"> </text><text x="136" textLength="120" fill="#ffffff"> SET </text><text x="256" textLength="8" fill="#000000"> </text><text x="264" textLength="264" class="foreground"> </text></g><g id="g78"><text x="8" textLength="128" class="foreground"> </text><text x="136" textLength="120" fill="#ffffff"> SREM </text><text x="256" textLength="8" fill="#000000"> </text><text x="264" textLength="264" class="foreground"> </text></g><g id="g79"><text x="8" textLength="128" class="foreground"> </text><text x="136" textLength="120" fill="#ffffff"> SPOP </text><text x="256" textLength="8" fill="#000000"> </text><text x="264" textLength="264" class="foreground"> </text></g><g id="g80"><text x="8" textLength="128" class="foreground"> </text><text x="136" textLength="120" fill="#ffffff"> SADD </text><text x="256" textLength="8" fill="#000000"> </text><text x="264" textLength="264" class="foreground"> </text></g><g id="g81"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="120" fill="#ffffff"> SYNC </text><text x="256" textLength="8" fill="#000000"> </text><text x="264" textLength="264" class="foreground"> </text></g><g id="g82"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="120" fill="#ffffff"> SAVE </text><text x="256" textLength="8" fill="#000000"> </text><text x="264" textLength="264" class="foreground"> </text></g><g id="g83"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="120" fill="#ffffff"> SORT </text><text x="256" textLength="8" fill="#000000"> </text><text x="264" textLength="264" class="foreground"> </text></g><g id="g84"><text x="0" textLength="144" class="foreground">127.0.0.1:6379> sm</text><text x="144" textLength="8" class="background">e</text><text x="152" textLength="96" fill="#626262">mbers fooset</text><text x="248" textLength="280" class="foreground"> </text></g><g id="g85"><text x="8" textLength="136" class="foreground"> </text><text x="144" textLength="80" fill="#ffffff"> SMOVE </text><text x="224" textLength="8" fill="#000000"> </text><text x="232" textLength="296" class="foreground"> </text></g><g id="g86"><text x="8" textLength="136" class="foreground"> </text><text x="144" textLength="80" fill="#ffffff"> SMEMBERS </text><text x="224" textLength="8" fill="#000000"> </text><text x="232" textLength="296" class="foreground"> </text></g><g id="g87"><text x="0" textLength="152" class="foreground">127.0.0.1:6379> sme</text><text x="152" textLength="8" class="background">m</text><text x="160" textLength="88" fill="#626262">bers fooset</text><text x="248" textLength="280" class="foreground"> </text></g><g id="g88"><text x="8" textLength="144" class="foreground"> </text><text x="152" textLength="80" fill="#ffffff"> SMEMBERS </text><text x="232" textLength="8" fill="#000000"> </text><text x="240" textLength="288" class="foreground"> </text></g><g id="g89"><text x="0" textLength="160" class="foreground">127.0.0.1:6379> smem</text><text x="160" textLength="8" class="background">b</text><text x="168" textLength="80" fill="#626262">ers fooset</text><text x="248" textLength="280" class="foreground"> </text></g><g id="g90"><text x="8" textLength="152" class="foreground"> </text><text x="160" textLength="80" fill="#ffffff"> SMEMBERS </text><text x="240" textLength="8" fill="#000000"> </text><text x="248" textLength="280" class="foreground"> </text></g><g id="g91"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="64" font-weight="bold" fill="#008700">SMEMBERS</text><text x="192" textLength="8" class="background"> </text><text x="200" textLength="328" class="foreground"> </text></g><g id="g92"><text x="8" textLength="152" class="foreground"> </text><text x="160" textLength="88" fill="#000000"> SMEMBERS </text><text x="248" textLength="280" class="foreground"> </text></g><g id="g93"><text x="0" textLength="48" font-weight="bold" fill="#d75f5f">(set) </text><text x="48" textLength="64" font-weight="bold" fill="#008700">SMEMBERS</text><text x="112" textLength="32" fill="#5faf5f"> key</text><text x="144" textLength="120" fill="#af8700"> since: 1.0.0</text><text x="264" textLength="264" fill="#626262"> complexity:O(N) where N is the s</text></g><g id="g94"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="64" font-weight="bold" fill="#008700">SMEMBERS</text><text x="192" textLength="8" class="foreground"> </text><text x="200" textLength="8" class="background">m</text><text x="208" textLength="32" fill="#626262">yset</text><text x="240" textLength="288" class="foreground"> </text></g><g id="g95"><text x="8" textLength="192" class="foreground"> </text><text x="200" textLength="136" fill="#ffffff"> myset </text><text x="336" textLength="8" fill="#000000"> </text><text x="344" textLength="184" class="foreground"> </text></g><g id="g96"><text x="8" textLength="192" class="foreground"> </text><text x="200" textLength="136" fill="#ffffff"> kkk </text><text x="336" textLength="8" fill="#000000"> </text><text x="344" textLength="184" class="foreground"> </text></g><g id="g97"><text x="8" textLength="192" class="foreground"> </text><text x="200" textLength="136" fill="#ffffff"> somestream </text><text x="336" textLength="8" fill="#000000"> </text><text x="344" textLength="184" class="foreground"> </text></g><g id="g98"><text x="8" textLength="192" class="foreground"> </text><text x="200" textLength="136" fill="#ffffff"> af </text><text x="336" textLength="8" fill="#000000"> </text><text x="344" textLength="184" class="foreground"> </text></g><g id="g99"><text x="0" textLength="200" class="foreground"> </text><text x="200" textLength="136" fill="#ffffff"> list:animals </text><text x="336" textLength="8" fill="#000000"> </text><text x="344" textLength="184" class="foreground"> </text></g><g id="g100"><text x="0" textLength="200" class="foreground"> </text><text x="200" textLength="136" fill="#ffffff"> hash2 </text><text x="336" textLength="8" fill="#000000"> </text><text x="344" textLength="184" class="foreground"> </text></g><g id="g101"><text x="0" textLength="200" class="foreground"> </text><text x="200" textLength="136" fill="#ffffff"> foo </text><text x="336" textLength="8" fill="#000000"> </text><text x="344" textLength="184" class="foreground"> </text></g><g id="g102"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="64" font-weight="bold" fill="#008700">SMEMBERS</text><text x="192" textLength="8" class="foreground"> </text><text x="200" textLength="8" fill="#5faf5f">m</text><text x="208" textLength="8" class="background">y</text><text x="216" textLength="24" fill="#626262">set</text><text x="240" textLength="288" class="foreground"> </text></g><g id="g103"><text x="8" textLength="200" class="foreground"> </text><text x="208" textLength="8" fill="#ffffff"> </text><text x="216" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">m</text><text x="224" textLength="32" fill="#444444">yset</text><text x="256" textLength="64" fill="#ffffff"> </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g104"><text x="8" textLength="200" class="foreground"> </text><text x="208" textLength="8" fill="#ffffff"> </text><text x="216" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">m</text><text x="224" textLength="48" fill="#444444">stream</text><text x="272" textLength="48" fill="#ffffff"> </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g105"><text x="8" textLength="200" class="foreground"> </text><text x="208" textLength="8" fill="#ffffff"> </text><text x="216" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">m</text><text x="224" textLength="48" fill="#444444">ylist1</text><text x="272" textLength="48" fill="#ffffff"> </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g106"><text x="8" textLength="200" class="foreground"> </text><text x="208" textLength="8" fill="#ffffff"> </text><text x="216" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">m</text><text x="224" textLength="40" fill="#444444">yzset</text><text x="264" textLength="56" fill="#ffffff"> </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g107"><text x="0" textLength="208" class="foreground"> </text><text x="208" textLength="8" fill="#ffffff"> </text><text x="216" textLength="16" fill="#444444">so</text><text x="232" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">m</text><text x="240" textLength="56" fill="#444444">estream</text><text x="296" textLength="24" fill="#ffffff"> </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g108"><text x="0" textLength="208" class="foreground"> </text><text x="208" textLength="8" fill="#ffffff"> </text><text x="216" textLength="64" fill="#444444">list:ani</text><text x="280" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">m</text><text x="288" textLength="24" fill="#444444">als</text><text x="312" textLength="8" fill="#ffffff"> </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g109"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="64" font-weight="bold" fill="#008700">SMEMBERS</text><text x="192" textLength="8" class="foreground"> </text><text x="200" textLength="16" fill="#5faf5f">my</text><text x="216" textLength="8" class="background">s</text><text x="224" textLength="16" fill="#626262">et</text><text x="240" textLength="288" class="foreground"> </text></g><g id="g110"><text x="8" textLength="208" class="foreground"> </text><text x="216" textLength="8" fill="#ffffff"> </text><text x="224" textLength="16" font-weight="bold" text-decoration="underline" fill="#ffffff">my</text><text x="240" textLength="24" fill="#444444">set</text><text x="264" textLength="24" fill="#ffffff"> </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g111"><text x="8" textLength="208" class="foreground"> </text><text x="216" textLength="8" fill="#ffffff"> </text><text x="224" textLength="16" font-weight="bold" text-decoration="underline" fill="#ffffff">my</text><text x="240" textLength="40" fill="#444444">list1</text><text x="280" textLength="8" fill="#ffffff"> </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g112"><text x="8" textLength="208" class="foreground"> </text><text x="216" textLength="8" fill="#ffffff"> </text><text x="224" textLength="16" font-weight="bold" text-decoration="underline" fill="#ffffff">my</text><text x="240" textLength="32" fill="#444444">zset</text><text x="272" textLength="16" fill="#ffffff"> </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g113"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="64" font-weight="bold" fill="#008700">SMEMBERS</text><text x="192" textLength="8" class="foreground"> </text><text x="200" textLength="40" fill="#5faf5f">myset</text><text x="240" textLength="8" class="background"> </text><text x="248" textLength="280" class="foreground"> </text></g><g id="g114"><text x="8" textLength="208" class="foreground"> </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="16" text-decoration="underline" fill="#000000">my</text><text x="240" textLength="24" class="foreground">set</text><text x="264" textLength="32" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g115"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="64" font-weight="bold" fill="#008700">SMEMBERS</text><text x="192" textLength="8" class="foreground"> </text><text x="200" textLength="40" fill="#5faf5f">myset</text><text x="240" textLength="288" class="foreground"> </text></g><g id="g116"><text x="0" textLength="24" class="foreground">1) </text><text x="24" textLength="40" fill="#ff8700">"foo"</text><text x="64" textLength="464" class="foreground"> </text></g><g id="g117"><text x="0" textLength="24" class="foreground">2) </text><text x="24" textLength="56" fill="#ff8700">"world"</text><text x="80" textLength="448" class="foreground"> </text></g><g id="g118"><text x="0" textLength="24" class="foreground">3) </text><text x="24" textLength="40" fill="#ff8700">"bar"</text><text x="64" textLength="464" class="foreground"> </text></g><g id="g119"><text x="0" textLength="24" class="foreground">4) </text><text x="24" textLength="56" fill="#ff8700">"hello"</text><text x="80" textLength="448" class="foreground"> </text></g><g id="g120"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="56" fill="#ffffff"> TTL </text><text x="192" textLength="8" fill="#000000"> </text><text x="200" textLength="328" class="foreground"> </text></g><g id="g121"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="56" fill="#ffffff"> TIME </text><text x="192" textLength="8" fill="#000000"> </text><text x="200" textLength="328" class="foreground"> </text></g><g id="g122"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="56" fill="#ffffff"> TYPE </text><text x="192" textLength="8" fill="#000000"> </text><text x="200" textLength="328" class="foreground"> </text></g><g id="g123"><text x="0" textLength="144" class="foreground"> </text><text x="144" textLength="56" fill="#ffffff"> TYPE </text><text x="200" textLength="8" fill="#000000"> </text><text x="208" textLength="320" class="foreground"> </text></g><g id="g124"><text x="0" textLength="152" class="foreground"> </text><text x="152" textLength="56" fill="#ffffff"> TYPE </text><text x="208" textLength="8" fill="#000000"> </text><text x="216" textLength="312" class="foreground"> </text></g><g id="g125"><text x="0" textLength="160" class="foreground"> </text><text x="160" textLength="56" fill="#ffffff"> TYPE </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g126"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> myset </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g127"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> kkk </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g128"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> somestream </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g129"><text x="168" textLength="136" fill="#ffffff"> list:animals </text><text x="304" textLength="8" fill="#000000"> </text></g><g id="g130"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="8" fill="#5faf5f">c</text><text x="176" textLength="8" class="background">a</text><text x="184" textLength="16" fill="#626262">rs</text><text x="200" textLength="328" class="foreground"> </text></g><g id="g131"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">c</text><text x="192" textLength="24" fill="#444444">ars</text><text x="216" textLength="24" fill="#ffffff"> </text><text x="240" textLength="8" fill="#000000"> </text><text x="248" textLength="280" class="foreground"> </text></g><g id="g132"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="16" fill="#444444">Si</text><text x="200" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">c</text><text x="208" textLength="24" fill="#444444">ily</text><text x="232" textLength="8" fill="#ffffff"> </text><text x="240" textLength="8" fill="#000000"> </text><text x="248" textLength="280" class="foreground"> </text></g><g id="g133"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="16" fill="#444444">ab</text><text x="200" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">c</text><text x="208" textLength="32" fill="#ffffff"> </text><text x="240" textLength="8" fill="#000000"> </text><text x="248" textLength="280" class="foreground"> </text></g><g id="g134"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="16" fill="#5faf5f">ca</text><text x="184" textLength="8" class="background">r</text><text x="192" textLength="8" fill="#626262">s</text><text x="200" textLength="328" class="foreground"> </text></g><g id="g135"><text x="0" textLength="184" class="foreground"> </text><text x="184" textLength="8" fill="#ffffff"> </text><text x="192" textLength="16" font-weight="bold" text-decoration="underline" fill="#ffffff">ca</text><text x="208" textLength="16" fill="#444444">rs</text><text x="224" textLength="16" fill="#ffffff"> </text><text x="240" textLength="8" fill="#000000"> </text><text x="248" textLength="280" class="foreground"> </text></g><g id="g136"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="32" fill="#5faf5f">cars</text><text x="200" textLength="8" class="background"> </text><text x="208" textLength="320" class="foreground"> </text></g><g id="g137"><text x="0" textLength="184" class="foreground"> </text><text x="184" textLength="8" fill="#000000"> </text><text x="192" textLength="16" text-decoration="underline" fill="#000000">ca</text><text x="208" textLength="16" class="foreground">rs</text><text x="224" textLength="24" fill="#000000"> </text><text x="248" textLength="280" class="foreground"> </text></g><g id="g138"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="32" fill="#5faf5f">cars</text><text x="200" textLength="328" class="foreground"> </text></g><g id="g139"><text x="0" textLength="528" class="foreground">"zset" </text></g><g id="g140"><text x="0" textLength="136" class="foreground">127.0.0.1:6379> z</text><text x="136" textLength="8" class="background">s</text><text x="144" textLength="72" fill="#626262">can kkk 0</text><text x="216" textLength="312" class="foreground"> </text></g><g id="g141"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="144" fill="#ffffff"> ZREM </text><text x="280" textLength="8" fill="#000000"> </text><text x="288" textLength="240" class="foreground"> </text></g><g id="g142"><text x="8" textLength="128" class="foreground"> </text><text x="136" textLength="144" fill="#ffffff"> ZADD </text><text x="280" textLength="8" fill="#000000"> </text><text x="288" textLength="240" class="foreground"> </text></g><g id="g143"><text x="8" textLength="128" class="foreground"> </text><text x="136" textLength="144" fill="#ffffff"> ZSCAN </text><text x="280" textLength="8" fill="#000000"> </text><text x="288" textLength="240" class="foreground"> </text></g><g id="g144"><text x="8" textLength="128" class="foreground"> </text><text x="136" textLength="144" fill="#ffffff"> ZRANK </text><text x="280" textLength="8" fill="#000000"> </text><text x="288" textLength="240" class="foreground"> </text></g><g id="g145"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="144" fill="#ffffff"> ZCARD </text><text x="280" textLength="8" fill="#000000"> </text><text x="288" textLength="240" class="foreground"> </text></g><g id="g146"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="144" fill="#ffffff"> ZSCORE </text><text x="280" textLength="8" fill="#000000"> </text><text x="288" textLength="240" class="foreground"> </text></g><g id="g147"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="144" fill="#ffffff"> ZRANGE </text><text x="280" textLength="8" fill="#000000"> </text><text x="288" textLength="240" class="foreground"> </text></g><g id="g148"><text x="0" textLength="144" class="foreground">127.0.0.1:6379> zs</text><text x="144" textLength="8" class="background">c</text><text x="152" textLength="64" fill="#626262">an kkk 0</text><text x="216" textLength="312" class="foreground"> </text></g><g id="g149"><text x="0" textLength="144" class="foreground"> </text><text x="144" textLength="64" fill="#ffffff"> ZSCAN </text><text x="208" textLength="8" fill="#000000"> </text><text x="216" textLength="312" class="foreground"> </text></g><g id="g150"><text x="8" textLength="136" class="foreground"> </text><text x="144" textLength="64" fill="#ffffff"> ZSCORE </text><text x="208" textLength="8" fill="#000000"> </text><text x="216" textLength="312" class="foreground"> </text></g><g id="g151"><text x="0" textLength="152" class="foreground">127.0.0.1:6379> zsc</text><text x="152" textLength="8" class="background">a</text><text x="160" textLength="56" fill="#626262">n kkk 0</text><text x="216" textLength="312" class="foreground"> </text></g><g id="g152"><text x="0" textLength="152" class="foreground"> </text><text x="152" textLength="64" fill="#ffffff"> ZSCAN </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g153"><text x="8" textLength="144" class="foreground"> </text><text x="152" textLength="64" fill="#ffffff"> ZSCORE </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g154"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="40" font-weight="bold" fill="#008700">ZSCAN</text><text x="168" textLength="8" class="background"> </text><text x="176" textLength="352" class="foreground"> </text></g><g id="g155"><text x="0" textLength="152" class="foreground"> </text><text x="152" textLength="72" fill="#000000"> ZSCAN </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g156"><text x="0" textLength="104" font-weight="bold" fill="#d75f5f">(sorted_set) </text><text x="104" textLength="40" font-weight="bold" fill="#008700">ZSCAN</text><text x="144" textLength="32" fill="#5faf5f"> key</text><text x="176" textLength="56" fill="#af87ff"> cursor</text><text x="232" textLength="56" font-weight="bold" fill="#008700"> [MATCH</text><text x="288" textLength="64" font-weight="bold" fill="#5faf5f"> pattern</text><text x="352" textLength="64" font-weight="bold" fill="#008700">] [COUNT</text><text x="416" textLength="48" fill="#af87ff"> count</text><text x="464" textLength="8" font-weight="bold" fill="#008700">]</text><text x="472" textLength="56" fill="#af8700"> sinc</text></g><g id="g157"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="40" font-weight="bold" fill="#008700">ZSCAN</text><text x="168" textLength="8" class="foreground"> </text><text x="176" textLength="8" class="background">c</text><text x="184" textLength="40" fill="#626262">ars 0</text><text x="224" textLength="304" class="foreground"> </text></g><g id="g158"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="136" fill="#ffffff"> cars </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g159"><text x="8" textLength="168" class="foreground"> </text><text x="176" textLength="136" fill="#ffffff"> myset </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g160"><text x="8" textLength="168" class="foreground"> </text><text x="176" textLength="136" fill="#ffffff"> kkk </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g161"><text x="8" textLength="168" class="foreground"> </text><text x="176" textLength="136" fill="#ffffff"> somestream </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g162"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="136" fill="#ffffff"> af </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g163"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="136" fill="#ffffff"> list:animals </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g164"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="136" fill="#ffffff"> hash2 </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g165"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="40" font-weight="bold" fill="#008700">ZSCAN</text><text x="168" textLength="8" class="foreground"> </text><text x="176" textLength="32" fill="#5faf5f">cars</text><text x="208" textLength="8" class="background"> </text><text x="216" textLength="312" class="foreground"> </text></g><g id="g166"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="144" fill="#000000"> cars </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g167"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="40" font-weight="bold" fill="#008700">ZSCAN</text><text x="168" textLength="8" class="foreground"> </text><text x="176" textLength="32" fill="#5faf5f">cars</text><text x="208" textLength="320" class="foreground"> </text></g><g id="g168"><text x="0" textLength="64" fill="#878787">(error) </text><text x="64" textLength="360" font-weight="bold" fill="#ff005f">wrong number of arguments for 'zscan' command</text><text x="424" textLength="104" class="foreground"> </text></g><g id="g169"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="40" font-weight="bold" fill="#008700">ZSCAN</text><text x="168" textLength="8" class="foreground"> </text><text x="176" textLength="32" fill="#5faf5f">cars</text><text x="208" textLength="8" class="foreground"> </text><text x="216" textLength="8" class="background">0</text><text x="224" textLength="304" class="foreground"> </text></g><g id="g170"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="40" font-weight="bold" fill="#008700">ZSCAN</text><text x="168" textLength="8" class="foreground"> </text><text x="176" textLength="32" fill="#5faf5f">cars</text><text x="208" textLength="8" class="foreground"> </text><text x="216" textLength="8" fill="#af87ff">0</text><text x="224" textLength="8" class="background"> </text><text x="232" textLength="296" class="foreground"> </text></g><g id="g171"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="40" font-weight="bold" fill="#008700">ZSCAN</text><text x="168" textLength="8" class="foreground"> </text><text x="176" textLength="32" fill="#5faf5f">cars</text><text x="208" textLength="8" class="foreground"> </text><text x="216" textLength="8" fill="#af87ff">0</text><text x="224" textLength="304" class="foreground"> </text></g><g id="g172"><text x="0" textLength="72" fill="#878787">(cursor) </text><text x="72" textLength="8" fill="#af87ff">0</text><text x="80" textLength="448" class="foreground"> </text></g><g id="g173"><text x="0" textLength="24" class="foreground">1) </text><text x="24" textLength="136" fill="#af87ff">1367522908124000 </text><text x="160" textLength="96" fill="#ff8700">"robins-car"</text><text x="256" textLength="272" class="foreground"> </text></g><g id="g174"><text x="0" textLength="136" class="foreground">127.0.0.1:6379> t</text><text x="136" textLength="8" class="background">y</text><text x="144" textLength="56" fill="#626262">pe cars</text><text x="200" textLength="328" class="foreground"> </text></g><g id="g175"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="56" fill="#ffffff"> TOUCH </text><text x="192" textLength="8" fill="#000000"> </text><text x="200" textLength="328" class="foreground"> </text></g><g id="g176"><text x="0" textLength="144" class="foreground">127.0.0.1:6379> ty</text><text x="144" textLength="8" class="background">p</text><text x="152" textLength="48" fill="#626262">e cars</text><text x="200" textLength="328" class="foreground"> </text></g><g id="g177"><text x="0" textLength="152" class="foreground">127.0.0.1:6379> typ</text><text x="152" textLength="8" class="background">e</text><text x="160" textLength="40" fill="#626262"> cars</text><text x="200" textLength="328" class="foreground"> </text></g><g id="g178"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="background"> </text><text x="168" textLength="32" fill="#626262">cars</text><text x="200" textLength="328" class="foreground"> </text></g><g id="g179"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="8" class="background">c</text><text x="176" textLength="24" fill="#626262">ars</text><text x="200" textLength="328" class="foreground"> </text></g><g id="g180"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> cars </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g181"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> af </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g182"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> hash2 </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g183"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="8" fill="#5faf5f">l</text><text x="176" textLength="8" class="background">i</text><text x="184" textLength="80" fill="#626262">st:animals</text><text x="264" textLength="264" class="foreground"> </text></g><g id="g184"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">l</text><text x="192" textLength="88" fill="#444444">ist:animals</text><text x="280" textLength="32" fill="#ffffff"> </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g185"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">l</text><text x="192" textLength="104" fill="#444444">ist:buildings</text><text x="296" textLength="16" fill="#ffffff"> </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g186"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">l</text><text x="192" textLength="112" fill="#444444">ist:restaurant</text><text x="304" textLength="8" fill="#ffffff"> </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g187"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="16" fill="#444444">my</text><text x="200" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">l</text><text x="208" textLength="32" fill="#444444">ist1</text><text x="240" textLength="72" fill="#ffffff"> </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g188"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="32" fill="#444444">Sici</text><text x="216" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">l</text><text x="224" textLength="8" fill="#444444">y</text><text x="232" textLength="80" fill="#ffffff"> </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g189"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="16" fill="#5faf5f">li</text><text x="184" textLength="8" class="background">s</text><text x="192" textLength="72" fill="#626262">t:animals</text><text x="264" textLength="264" class="foreground"> </text></g><g id="g190"><text x="0" textLength="184" class="foreground"> </text><text x="184" textLength="8" fill="#ffffff"> </text><text x="192" textLength="16" font-weight="bold" text-decoration="underline" fill="#ffffff">li</text><text x="208" textLength="80" fill="#444444">st:animals</text><text x="288" textLength="32" fill="#ffffff"> </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g191"><text x="0" textLength="184" class="foreground"> </text><text x="184" textLength="8" fill="#ffffff"> </text><text x="192" textLength="16" font-weight="bold" text-decoration="underline" fill="#ffffff">li</text><text x="208" textLength="96" fill="#444444">st:buildings</text><text x="304" textLength="16" fill="#ffffff"> </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g192"><text x="0" textLength="184" class="foreground"> </text><text x="184" textLength="8" fill="#ffffff"> </text><text x="192" textLength="16" font-weight="bold" text-decoration="underline" fill="#ffffff">li</text><text x="208" textLength="104" fill="#444444">st:restaurant</text><text x="312" textLength="8" fill="#ffffff"> </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g193"><text x="0" textLength="184" class="foreground"> </text><text x="184" textLength="8" fill="#ffffff"> </text><text x="192" textLength="16" fill="#444444">my</text><text x="208" textLength="16" font-weight="bold" text-decoration="underline" fill="#ffffff">li</text><text x="224" textLength="24" fill="#444444">st1</text><text x="248" textLength="72" fill="#ffffff"> </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g194"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="96" fill="#5faf5f">list:animals</text><text x="264" textLength="8" class="background"> </text><text x="272" textLength="256" class="foreground"> </text></g><g id="g195"><text x="0" textLength="184" class="foreground"> </text><text x="184" textLength="8" fill="#000000"> </text><text x="192" textLength="16" text-decoration="underline" fill="#000000">li</text><text x="208" textLength="80" class="foreground">st:animals</text><text x="288" textLength="40" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g196"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="96" fill="#5faf5f">list:animals</text><text x="264" textLength="264" class="foreground"> </text></g><g id="g197"><text x="0" textLength="528" class="foreground">"list" </text></g><g id="g198"><text x="0" textLength="136" class="foreground">127.0.0.1:6379> l</text><text x="136" textLength="8" class="background">r</text><text x="144" textLength="168" fill="#626262">ange list:animals 0 6</text><text x="312" textLength="216" class="foreground"> </text></g><g id="g199"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="80" fill="#ffffff"> LSET </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g200"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="80" fill="#ffffff"> LREM </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g201"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="80" fill="#ffffff"> LPOP </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g202"><text x="8" textLength="128" class="foreground"> </text><text x="136" textLength="80" fill="#ffffff"> LLEN </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g203"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="80" fill="#ffffff"> LTRIM </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g204"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="80" fill="#ffffff"> LPUSH </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g205"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="80" fill="#ffffff"> LRANGE </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g206"><text x="0" textLength="144" class="foreground">127.0.0.1:6379> ll</text><text x="144" textLength="8" class="background">e</text><text x="152" textLength="96" fill="#626262">n testKeyDB2</text><text x="248" textLength="280" class="foreground"> </text></g><g id="g207"><text x="0" textLength="144" class="foreground"> </text><text x="144" textLength="56" fill="#ffffff"> LLEN </text><text x="200" textLength="8" fill="#000000"> </text><text x="208" textLength="320" class="foreground"> </text></g><g id="g208"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">LLEN</text><text x="160" textLength="8" class="background"> </text><text x="168" textLength="360" class="foreground"> </text></g><g id="g209"><text x="0" textLength="144" class="foreground"> </text><text x="144" textLength="64" fill="#000000"> LLEN </text><text x="208" textLength="320" class="foreground"> </text></g><g id="g210"><text x="0" textLength="56" font-weight="bold" fill="#d75f5f">(list) </text><text x="56" textLength="32" font-weight="bold" fill="#008700">LLEN</text><text x="88" textLength="32" fill="#5faf5f"> key</text><text x="120" textLength="120" fill="#af8700"> since: 1.0.0</text><text x="240" textLength="128" fill="#626262"> complexity:O(1)</text><text x="368" textLength="160" fill="#a8a8a8"> </text></g><g id="g211"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">LLEN</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="8" class="background">l</text><text x="176" textLength="88" fill="#626262">ist:animals</text><text x="264" textLength="264" class="foreground"> </text></g><g id="g212"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> list:animals </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g213"><text x="8" textLength="160" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> kkk </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g214"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">LLEN</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="8" fill="#5faf5f">i</text><text x="176" textLength="8" class="background"> </text><text x="184" textLength="344" class="foreground"> </text></g><g id="g215"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="8" fill="#444444">l</text><text x="192" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">i</text><text x="200" textLength="80" fill="#444444">st:animals</text><text x="280" textLength="32" fill="#ffffff"> </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g216"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="8" fill="#444444">l</text><text x="192" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">i</text><text x="200" textLength="96" fill="#444444">st:buildings</text><text x="296" textLength="16" fill="#ffffff"> </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g217"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="8" fill="#444444">S</text><text x="192" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">i</text><text x="200" textLength="32" fill="#444444">cily</text><text x="232" textLength="80" fill="#ffffff"> </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g218"><text x="8" textLength="168" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="8" fill="#444444">l</text><text x="192" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">i</text><text x="200" textLength="104" fill="#444444">st:restaurant</text><text x="304" textLength="8" fill="#ffffff"> </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g219"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="24" fill="#444444">myl</text><text x="208" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">i</text><text x="216" textLength="24" fill="#444444">st1</text><text x="240" textLength="72" fill="#ffffff"> </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g220"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">LLEN</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="8" class="background"> </text><text x="176" textLength="352" class="foreground"> </text></g><g id="g221"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">LLEN</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="8" fill="#5faf5f">l</text><text x="176" textLength="8" class="background">i</text><text x="184" textLength="80" fill="#626262">st:animals</text><text x="264" textLength="264" class="foreground"> </text></g><g id="g222"><text x="8" textLength="168" class="foreground"> </text><text x="176" textLength="8" fill="#ffffff"> </text><text x="184" textLength="16" fill="#444444">my</text><text x="200" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">l</text><text x="208" textLength="32" fill="#444444">ist1</text><text x="240" textLength="72" fill="#ffffff"> </text><text x="312" textLength="8" fill="#000000"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g223"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">LLEN</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="16" fill="#5faf5f">li</text><text x="184" textLength="8" class="background">s</text><text x="192" textLength="72" fill="#626262">t:animals</text><text x="264" textLength="264" class="foreground"> </text></g><g id="g224"><text x="8" textLength="176" class="foreground"> </text><text x="184" textLength="8" fill="#ffffff"> </text><text x="192" textLength="16" fill="#444444">my</text><text x="208" textLength="16" font-weight="bold" text-decoration="underline" fill="#ffffff">li</text><text x="224" textLength="24" fill="#444444">st1</text><text x="248" textLength="72" fill="#ffffff"> </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g225"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">LLEN</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="96" fill="#5faf5f">list:animals</text><text x="264" textLength="8" class="background"> </text><text x="272" textLength="256" class="foreground"> </text></g><g id="g226"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">LLEN</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="96" fill="#5faf5f">list:animals</text><text x="264" textLength="264" class="foreground"> </text></g><g id="g227"><text x="0" textLength="80" fill="#878787">(integer) </text><text x="80" textLength="448" class="foreground">51 </text></g><g id="g228"><text x="8" textLength="128" class="foreground"> </text><text x="136" textLength="80" fill="#ffffff"> LREM </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g229"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="80" fill="#ffffff"> LLEN </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g230"><text x="0" textLength="144" class="foreground">127.0.0.1:6379> lr</text><text x="144" textLength="8" class="background">a</text><text x="152" textLength="160" fill="#626262">nge list:animals 0 6</text><text x="312" textLength="216" class="foreground"> </text></g><g id="g231"><text x="0" textLength="144" class="foreground"> </text><text x="144" textLength="64" fill="#ffffff"> LREM </text><text x="208" textLength="8" fill="#000000"> </text><text x="216" textLength="312" class="foreground"> </text></g><g id="g232"><text x="8" textLength="136" class="foreground"> </text><text x="144" textLength="64" fill="#ffffff"> LRANGE </text><text x="208" textLength="8" fill="#000000"> </text><text x="216" textLength="312" class="foreground"> </text></g><g id="g233"><text x="0" textLength="152" class="foreground">127.0.0.1:6379> lra</text><text x="152" textLength="8" class="background">n</text><text x="160" textLength="152" fill="#626262">ge list:animals 0 6</text><text x="312" textLength="216" class="foreground"> </text></g><g id="g234"><text x="0" textLength="152" class="foreground"> </text><text x="152" textLength="64" fill="#ffffff"> LRANGE </text><text x="216" textLength="8" fill="#000000"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g235"><text x="0" textLength="160" class="foreground">127.0.0.1:6379> lran</text><text x="160" textLength="8" class="background">g</text><text x="168" textLength="144" fill="#626262">e list:animals 0 6</text><text x="312" textLength="216" class="foreground"> </text></g><g id="g236"><text x="0" textLength="160" class="foreground"> </text><text x="160" textLength="64" fill="#ffffff"> LRANGE </text><text x="224" textLength="8" fill="#000000"> </text><text x="232" textLength="296" class="foreground"> </text></g><g id="g237"><text x="0" textLength="168" class="foreground">127.0.0.1:6379> lrang</text><text x="168" textLength="8" class="background">e</text><text x="176" textLength="136" fill="#626262"> list:animals 0 6</text><text x="312" textLength="216" class="foreground"> </text></g><g id="g238"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="64" fill="#ffffff"> LRANGE </text><text x="232" textLength="8" fill="#000000"> </text><text x="240" textLength="288" class="foreground"> </text></g><g id="g239"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="48" font-weight="bold" fill="#008700">lrange</text><text x="176" textLength="8" class="background"> </text><text x="184" textLength="128" fill="#626262">list:animals 0 6</text><text x="312" textLength="216" class="foreground"> </text></g><g id="g240"><text x="0" textLength="176" class="foreground"> </text><text x="176" textLength="64" fill="#ffffff"> LRANGE </text><text x="240" textLength="8" fill="#000000"> </text><text x="248" textLength="280" class="foreground"> </text></g><g id="g241"><text x="0" textLength="56" font-weight="bold" fill="#d75f5f">(list) </text><text x="56" textLength="48" font-weight="bold" fill="#008700">LRANGE</text><text x="104" textLength="32" fill="#5faf5f"> key</text><text x="136" textLength="88" fill="#af87ff"> start stop</text><text x="224" textLength="120" fill="#af8700"> since: 1.0.0</text><text x="344" textLength="184" fill="#626262"> complexity:O(S+N) wher</text></g><g id="g242"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="48" font-weight="bold" fill="#008700">lrange</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="8" class="background">l</text><text x="192" textLength="120" fill="#626262">ist:animals 0 6</text><text x="312" textLength="216" class="foreground"> </text></g><g id="g243"><text x="0" textLength="184" class="foreground"> </text><text x="184" textLength="136" fill="#ffffff"> list:animals </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g244"><text x="8" textLength="176" class="foreground"> </text><text x="184" textLength="136" fill="#ffffff"> cars </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g245"><text x="0" textLength="184" class="foreground"> </text><text x="184" textLength="136" fill="#ffffff"> myset </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g246"><text x="0" textLength="184" class="foreground"> </text><text x="184" textLength="136" fill="#ffffff"> kkk </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g247"><text x="0" textLength="184" class="foreground"> </text><text x="184" textLength="136" fill="#ffffff"> somestream </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g248"><text x="0" textLength="184" class="foreground"> </text><text x="184" textLength="136" fill="#ffffff"> af </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g249"><text x="0" textLength="184" class="foreground"> </text><text x="184" textLength="136" fill="#ffffff"> hash2 </text><text x="320" textLength="8" fill="#000000"> </text><text x="328" textLength="200" class="foreground"> </text></g><g id="g250"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="48" font-weight="bold" fill="#008700">lrange</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="8" fill="#5faf5f">l</text><text x="192" textLength="8" class="background">i</text><text x="200" textLength="112" fill="#626262">st:animals 0 6</text><text x="312" textLength="216" class="foreground"> </text></g><g id="g251"><text x="0" textLength="192" class="foreground"> </text><text x="192" textLength="8" fill="#ffffff"> </text><text x="200" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">l</text><text x="208" textLength="88" fill="#444444">ist:animals</text><text x="296" textLength="32" fill="#ffffff"> </text><text x="328" textLength="8" fill="#000000"> </text><text x="336" textLength="192" class="foreground"> </text></g><g id="g252"><text x="8" textLength="184" class="foreground"> </text><text x="192" textLength="8" fill="#ffffff"> </text><text x="200" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">l</text><text x="208" textLength="104" fill="#444444">ist:buildings</text><text x="312" textLength="16" fill="#ffffff"> </text><text x="328" textLength="8" fill="#000000"> </text><text x="336" textLength="192" class="foreground"> </text></g><g id="g253"><text x="0" textLength="192" class="foreground"> </text><text x="192" textLength="8" fill="#ffffff"> </text><text x="200" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">l</text><text x="208" textLength="112" fill="#444444">ist:restaurant</text><text x="320" textLength="8" fill="#ffffff"> </text><text x="328" textLength="8" fill="#000000"> </text><text x="336" textLength="192" class="foreground"> </text></g><g id="g254"><text x="0" textLength="192" class="foreground"> </text><text x="192" textLength="8" fill="#ffffff"> </text><text x="200" textLength="16" fill="#444444">my</text><text x="216" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">l</text><text x="224" textLength="32" fill="#444444">ist1</text><text x="256" textLength="72" fill="#ffffff"> </text><text x="328" textLength="8" fill="#000000"> </text><text x="336" textLength="192" class="foreground"> </text></g><g id="g255"><text x="0" textLength="192" class="foreground"> </text><text x="192" textLength="8" fill="#ffffff"> </text><text x="200" textLength="32" fill="#444444">Sici</text><text x="232" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">l</text><text x="240" textLength="8" fill="#444444">y</text><text x="248" textLength="80" fill="#ffffff"> </text><text x="328" textLength="8" fill="#000000"> </text><text x="336" textLength="192" class="foreground"> </text></g><g id="g256"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="48" font-weight="bold" fill="#008700">lrange</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="96" fill="#5faf5f">list:animals</text><text x="280" textLength="8" class="background"> </text><text x="288" textLength="240" class="foreground"> </text></g><g id="g257"><text x="0" textLength="192" class="foreground"> </text><text x="192" textLength="8" fill="#000000"> </text><text x="200" textLength="8" text-decoration="underline" fill="#000000">l</text><text x="208" textLength="88" class="foreground">ist:animals</text><text x="296" textLength="40" fill="#000000"> </text><text x="336" textLength="192" class="foreground"> </text></g><g id="g258"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="48" font-weight="bold" fill="#008700">lrange</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="96" fill="#5faf5f">list:animals</text><text x="280" textLength="8" class="foreground"> </text><text x="288" textLength="8" class="background">0</text><text x="296" textLength="16" fill="#626262"> 6</text><text x="312" textLength="216" class="foreground"> </text></g><g id="g259"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="48" font-weight="bold" fill="#008700">lrange</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="96" fill="#5faf5f">list:animals</text><text x="280" textLength="8" class="foreground"> </text><text x="288" textLength="8" fill="#af87ff">0</text><text x="296" textLength="8" class="background"> </text><text x="304" textLength="8" fill="#626262">6</text><text x="312" textLength="216" class="foreground"> </text></g><g id="g260"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="48" font-weight="bold" fill="#008700">lrange</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="96" fill="#5faf5f">list:animals</text><text x="280" textLength="8" class="foreground"> </text><text x="288" textLength="8" fill="#af87ff">0</text><text x="296" textLength="8" class="foreground"> </text><text x="304" textLength="8" class="background">6</text><text x="312" textLength="216" class="foreground"> </text></g><g id="g261"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="48" font-weight="bold" fill="#008700">lrange</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="96" fill="#5faf5f">list:animals</text><text x="280" textLength="8" class="foreground"> </text><text x="288" textLength="8" fill="#af87ff">0</text><text x="296" textLength="8" class="foreground"> </text><text x="304" textLength="8" fill="#af87ff">6</text><text x="312" textLength="8" class="background"> </text><text x="320" textLength="208" class="foreground"> </text></g><g id="g262"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="48" font-weight="bold" fill="#008700">lrange</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="96" fill="#5faf5f">list:animals</text><text x="280" textLength="8" class="foreground"> </text><text x="288" textLength="8" fill="#af87ff">0</text><text x="296" textLength="8" class="foreground"> </text><text x="304" textLength="8" fill="#af87ff">6</text><text x="312" textLength="216" class="foreground"> </text></g><g id="g263"><text x="0" textLength="24" class="foreground">1) </text><text x="24" textLength="48" fill="#ff8700">"wolf"</text><text x="72" textLength="456" class="foreground"> </text></g><g id="g264"><text x="0" textLength="24" class="foreground">2) </text><text x="24" textLength="64" fill="#ff8700">"turtle"</text><text x="88" textLength="440" class="foreground"> </text></g><g id="g265"><text x="0" textLength="24" class="foreground">3) </text><text x="24" textLength="56" fill="#ff8700">"tiger"</text><text x="80" textLength="448" class="foreground"> </text></g><g id="g266"><text x="0" textLength="24" class="foreground">4) </text><text x="24" textLength="80" fill="#ff8700">"squirrel"</text><text x="104" textLength="424" class="foreground"> </text></g><g id="g267"><text x="0" textLength="24" class="foreground">5) </text><text x="24" textLength="64" fill="#ff8700">"spider"</text><text x="88" textLength="440" class="foreground"> </text></g><g id="g268"><text x="0" textLength="24" class="foreground">6) </text><text x="24" textLength="56" fill="#ff8700">"snake"</text><text x="80" textLength="448" class="foreground"> </text></g><g id="g269"><text x="0" textLength="24" class="foreground">7) </text><text x="24" textLength="56" fill="#ff8700">"snail"</text><text x="80" textLength="448" class="foreground"> </text></g><g id="g270"><text x="0" textLength="136" class="foreground">127.0.0.1:6379> t</text><text x="136" textLength="8" class="background">y</text><text x="144" textLength="120" fill="#626262">pe list:animals</text><text x="264" textLength="264" class="foreground"> </text></g><g id="g271"><text x="0" textLength="144" class="foreground">127.0.0.1:6379> ty</text><text x="144" textLength="8" class="background">p</text><text x="152" textLength="112" fill="#626262">e list:animals</text><text x="264" textLength="264" class="foreground"> </text></g><g id="g272"><text x="0" textLength="152" class="foreground">127.0.0.1:6379> typ</text><text x="152" textLength="8" class="background">e</text><text x="160" textLength="104" fill="#626262"> list:animals</text><text x="264" textLength="264" class="foreground"> </text></g><g id="g273"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="background"> </text><text x="168" textLength="96" fill="#626262">list:animals</text><text x="264" textLength="264" class="foreground"> </text></g><g id="g274"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="8" class="background">l</text><text x="176" textLength="88" fill="#626262">ist:animals</text><text x="264" textLength="264" class="foreground"> </text></g><g id="g275"><text x="136" textLength="32" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> list:animals </text><text x="304" textLength="8" fill="#000000"> </text></g><g id="g276"><text x="8" textLength="160" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> cars </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g277"><text x="8" textLength="160" class="foreground"> </text><text x="168" textLength="136" fill="#ffffff"> myset </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g278"><text x="168" textLength="136" fill="#ffffff"> somestream </text><text x="304" textLength="8" fill="#000000"> </text></g><g id="g279"><text x="168" textLength="136" fill="#ffffff"> af </text><text x="304" textLength="8" fill="#000000"> </text></g><g id="g280"><text x="136" textLength="32" class="foreground"> </text><text x="168" textLength="144" fill="#000000"> list:animals </text></g><g id="g281"><text x="8" textLength="160" class="foreground"> </text><text x="168" textLength="144" fill="#000000"> cars </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g282"><text x="8" textLength="160" class="foreground"> </text><text x="168" textLength="144" fill="#000000"> myset </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g283"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="24" fill="#5faf5f">kkk</text><text x="192" textLength="8" class="background"> </text><text x="200" textLength="328" class="foreground"> </text></g><g id="g284"><text x="8" textLength="160" class="foreground"> </text><text x="168" textLength="144" fill="#000000"> kkk </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g285"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="80" fill="#5faf5f">somestream</text><text x="248" textLength="8" class="background"> </text><text x="256" textLength="272" class="foreground"> </text></g><g id="g286"><text x="168" textLength="144" fill="#000000"> somestream </text></g><g id="g287"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="16" fill="#5faf5f">af</text><text x="184" textLength="8" class="background"> </text><text x="192" textLength="336" class="foreground"> </text></g><g id="g288"><text x="168" textLength="144" fill="#000000"> af </text></g><g id="g289"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="32" font-weight="bold" fill="#008700">type</text><text x="160" textLength="8" class="foreground"> </text><text x="168" textLength="16" fill="#5faf5f">af</text><text x="184" textLength="344" class="foreground"> </text></g><g id="g290"><text x="0" textLength="528" class="foreground">"string" </text></g><g id="g291"><text x="168" textLength="144" class="foreground"> </text></g><g id="g292"><text x="0" textLength="136" class="foreground">127.0.0.1:6379> g</text><text x="136" textLength="8" class="background">e</text><text x="144" textLength="40" fill="#626262">t foo</text><text x="184" textLength="344" class="foreground"> </text></g><g id="g293"><text x="8" textLength="128" class="foreground"> </text><text x="136" textLength="152" fill="#ffffff"> GET </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g294"><text x="8" textLength="128" class="foreground"> </text><text x="136" textLength="152" fill="#ffffff"> GETSET </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g295"><text x="136" textLength="152" fill="#ffffff"> GETBIT </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="16" class="foreground"> </text></g><g id="g296"><text x="136" textLength="152" fill="#ffffff"> GEOPOS </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="16" class="foreground"> </text></g><g id="g297"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="152" fill="#ffffff"> GEOADD </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g298"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="152" fill="#ffffff"> GEOHASH </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g299"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="152" fill="#ffffff"> GEODIST </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g300"><text x="0" textLength="144" class="foreground">127.0.0.1:6379> ge</text><text x="144" textLength="8" class="background">t</text><text x="152" textLength="32" fill="#626262"> foo</text><text x="184" textLength="344" class="foreground"> </text></g><g id="g301"><text x="8" textLength="136" class="foreground"> </text><text x="144" textLength="152" fill="#ffffff"> GET </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g302"><text x="8" textLength="136" class="foreground"> </text><text x="144" textLength="152" fill="#ffffff"> GETSET </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g303"><text x="136" textLength="8" class="foreground"> </text><text x="144" textLength="152" fill="#ffffff"> GETBIT </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="8" class="foreground"> </text></g><g id="g304"><text x="136" textLength="8" class="foreground"> </text><text x="144" textLength="152" fill="#ffffff"> GEOPOS </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="8" class="foreground"> </text></g><g id="g305"><text x="0" textLength="144" class="foreground"> </text><text x="144" textLength="152" fill="#ffffff"> GEOADD </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g306"><text x="0" textLength="144" class="foreground"> </text><text x="144" textLength="152" fill="#ffffff"> GEOHASH </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g307"><text x="0" textLength="144" class="foreground"> </text><text x="144" textLength="152" fill="#ffffff"> GEODIST </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g308"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="background"> </text><text x="160" textLength="24" fill="#626262">foo</text><text x="184" textLength="344" class="foreground"> </text></g><g id="g309"><text x="8" textLength="144" class="foreground"> </text><text x="152" textLength="80" fill="#ffffff"> GET </text><text x="232" textLength="8" fill="#000000"> </text><text x="240" textLength="288" class="foreground"> </text></g><g id="g310"><text x="8" textLength="144" class="foreground"> </text><text x="152" textLength="80" fill="#ffffff"> GETSET </text><text x="232" textLength="8" fill="#000000"> </text><text x="240" textLength="288" class="foreground"> </text></g><g id="g311"><text x="136" textLength="16" class="foreground"> </text><text x="152" textLength="80" fill="#ffffff"> GETBIT </text><text x="232" textLength="8" fill="#000000"> </text><text x="240" textLength="288" class="foreground"> </text></g><g id="g312"><text x="136" textLength="16" class="foreground"> </text><text x="152" textLength="80" fill="#ffffff"> GETRANGE </text><text x="232" textLength="8" fill="#000000"> </text><text x="240" textLength="288" class="foreground"> </text></g><g id="g313"><text x="0" textLength="72" font-weight="bold" fill="#d75f5f">(string) </text><text x="72" textLength="24" font-weight="bold" fill="#008700">GET</text><text x="96" textLength="32" fill="#5faf5f"> key</text><text x="128" textLength="120" fill="#af8700"> since: 1.0.0</text><text x="248" textLength="128" fill="#626262"> complexity:O(1)</text><text x="376" textLength="152" fill="#a8a8a8"> </text></g><g id="g314"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="8" class="background">f</text><text x="168" textLength="16" fill="#626262">oo</text><text x="184" textLength="344" class="foreground"> </text></g><g id="g315"><text x="8" textLength="152" class="foreground"> </text><text x="160" textLength="136" fill="#ffffff"> af </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g316"><text x="8" textLength="152" class="foreground"> </text><text x="160" textLength="136" fill="#ffffff"> list:animals </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g317"><text x="136" textLength="24" class="foreground"> </text><text x="160" textLength="136" fill="#ffffff"> cars </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g318"><text x="136" textLength="24" class="foreground"> </text><text x="160" textLength="136" fill="#ffffff"> myset </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g319"><text x="0" textLength="160" class="foreground"> </text><text x="160" textLength="136" fill="#ffffff"> kkk </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g320"><text x="0" textLength="160" class="foreground"> </text><text x="160" textLength="136" fill="#ffffff"> somestream </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g321"><text x="0" textLength="160" class="foreground"> </text><text x="160" textLength="136" fill="#ffffff"> hash2 </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g322"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="8" fill="#5faf5f">a</text><text x="168" textLength="8" class="background"> </text><text x="176" textLength="352" class="foreground"> </text></g><g id="g323"><text x="8" textLength="160" class="foreground"> </text><text x="168" textLength="8" fill="#ffffff"> </text><text x="176" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">a</text><text x="184" textLength="8" fill="#444444">f</text><text x="192" textLength="112" fill="#ffffff"> </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g324"><text x="8" textLength="160" class="foreground"> </text><text x="168" textLength="8" fill="#ffffff"> </text><text x="176" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">a</text><text x="184" textLength="120" fill="#ffffff"> </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g325"><text x="136" textLength="32" class="foreground"> </text><text x="168" textLength="8" fill="#ffffff"> </text><text x="176" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">a</text><text x="184" textLength="16" fill="#444444">bc</text><text x="200" textLength="104" fill="#ffffff"> </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g326"><text x="136" textLength="32" class="foreground"> </text><text x="168" textLength="8" fill="#ffffff"> </text><text x="176" textLength="8" fill="#444444">c</text><text x="184" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">a</text><text x="192" textLength="16" fill="#444444">rs</text><text x="208" textLength="96" fill="#ffffff"> </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g327"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="8" fill="#ffffff"> </text><text x="176" textLength="8" fill="#444444">h</text><text x="184" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">a</text><text x="192" textLength="24" fill="#444444">sh2</text><text x="216" textLength="88" fill="#ffffff"> </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g328"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="8" fill="#ffffff"> </text><text x="176" textLength="8" fill="#444444">h</text><text x="184" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">a</text><text x="192" textLength="24" fill="#444444">sh3</text><text x="216" textLength="88" fill="#ffffff"> </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g329"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="8" fill="#ffffff"> </text><text x="176" textLength="8" fill="#444444">h</text><text x="184" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">a</text><text x="192" textLength="24" fill="#444444">sh1</text><text x="216" textLength="88" fill="#ffffff"> </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g330"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="background"> </text><text x="184" textLength="344" class="foreground"> </text></g><g id="g331"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="352" class="foreground"> </text></g><g id="g332"><text x="0" textLength="528" class="foreground">"asdf" </text></g><g id="g333"><text x="0" textLength="136" class="foreground">127.0.0.1:6379> g</text><text x="136" textLength="8" class="background">e</text><text x="144" textLength="32" fill="#626262">t af</text><text x="176" textLength="352" class="foreground"> </text></g><g id="g334"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="152" fill="#ffffff"> GETBIT </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g335"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="152" fill="#ffffff"> GEOPOS </text><text x="288" textLength="8" fill="#000000"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g336"><text x="0" textLength="144" class="foreground">127.0.0.1:6379> ge</text><text x="144" textLength="8" class="background">t</text><text x="152" textLength="24" fill="#626262"> af</text><text x="176" textLength="352" class="foreground"> </text></g><g id="g337"><text x="0" textLength="144" class="foreground"> </text><text x="144" textLength="152" fill="#ffffff"> GETBIT </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g338"><text x="0" textLength="144" class="foreground"> </text><text x="144" textLength="152" fill="#ffffff"> GEOPOS </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g339"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="background"> </text><text x="160" textLength="16" fill="#626262">af</text><text x="176" textLength="352" class="foreground"> </text></g><g id="g340"><text x="0" textLength="152" class="foreground"> </text><text x="152" textLength="80" fill="#ffffff"> GETBIT </text><text x="232" textLength="8" fill="#000000"> </text><text x="240" textLength="288" class="foreground"> </text></g><g id="g341"><text x="0" textLength="152" class="foreground"> </text><text x="152" textLength="80" fill="#ffffff"> GETRANGE </text><text x="232" textLength="8" fill="#000000"> </text><text x="240" textLength="288" class="foreground"> </text></g><g id="g342"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="8" class="background">a</text><text x="168" textLength="8" fill="#626262">f</text><text x="176" textLength="352" class="foreground"> </text></g><g id="g343"><text x="0" textLength="160" class="foreground"> </text><text x="160" textLength="136" fill="#ffffff"> cars </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g344"><text x="0" textLength="160" class="foreground"> </text><text x="160" textLength="136" fill="#ffffff"> myset </text><text x="296" textLength="8" fill="#000000"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g345"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="8" fill="#5faf5f">a</text><text x="168" textLength="8" class="background">f</text><text x="176" textLength="352" class="foreground"> </text></g><g id="g346"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="8" fill="#ffffff"> </text><text x="176" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">a</text><text x="184" textLength="16" fill="#444444">bc</text><text x="200" textLength="104" fill="#ffffff"> </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g347"><text x="0" textLength="168" class="foreground"> </text><text x="168" textLength="8" fill="#ffffff"> </text><text x="176" textLength="8" fill="#444444">c</text><text x="184" textLength="8" font-weight="bold" text-decoration="underline" fill="#ffffff">a</text><text x="192" textLength="16" fill="#444444">rs</text><text x="208" textLength="96" fill="#ffffff"> </text><text x="304" textLength="8" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g348"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="8" class="background"> </text><text x="192" textLength="336" class="foreground"> </text></g><g id="g349"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="8" fill="#000000">i</text><text x="192" textLength="8" class="background"> </text><text x="200" textLength="328" class="foreground"> </text></g><g id="g350"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="16" fill="#000000">in</text><text x="200" textLength="8" class="background"> </text><text x="208" textLength="320" class="foreground"> </text></g><g id="g351"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="24" fill="#000000">inv</text><text x="208" textLength="8" class="background"> </text><text x="216" textLength="312" class="foreground"> </text></g><g id="g352"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="32" fill="#000000">inva</text><text x="216" textLength="8" class="background"> </text><text x="224" textLength="304" class="foreground"> </text></g><g id="g353"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="40" fill="#000000">inval</text><text x="224" textLength="8" class="background"> </text><text x="232" textLength="296" class="foreground"> </text></g><g id="g354"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="48" fill="#000000">invali</text><text x="232" textLength="8" class="background"> </text><text x="240" textLength="288" class="foreground"> </text></g><g id="g355"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="56" fill="#000000">invalid</text><text x="240" textLength="8" class="background"> </text><text x="248" textLength="280" class="foreground"> </text></g><g id="g356"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="64" fill="#000000">invalide</text><text x="248" textLength="8" class="background"> </text><text x="256" textLength="272" class="foreground"> </text></g><g id="g357"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="72" fill="#000000">invalide </text><text x="256" textLength="8" class="background"> </text><text x="264" textLength="264" class="foreground"> </text></g><g id="g358"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="80" fill="#000000">invalide i</text><text x="264" textLength="8" class="background"> </text><text x="272" textLength="256" class="foreground"> </text></g><g id="g359"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="88" fill="#000000">invalide in</text><text x="272" textLength="8" class="background"> </text><text x="280" textLength="248" class="foreground"> </text></g><g id="g360"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="96" fill="#000000">invalide inp</text><text x="280" textLength="8" class="background"> </text><text x="288" textLength="240" class="foreground"> </text></g><g id="g361"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="104" fill="#000000">invalide inpu</text><text x="288" textLength="8" class="background"> </text><text x="296" textLength="232" class="foreground"> </text></g><g id="g362"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="foreground"> </text><text x="184" textLength="112" fill="#000000">invalide input</text><text x="296" textLength="8" class="background"> </text><text x="304" textLength="224" class="foreground"> </text></g><g id="g363"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">get</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="8" class="background"> </text><text x="168" textLength="360" class="foreground"> </text></g><g id="g364"><text x="0" textLength="144" class="foreground">127.0.0.1:6379> ge</text><text x="144" textLength="8" class="background"> </text><text x="152" textLength="376" class="foreground"> </text></g><g id="g365"><text x="0" textLength="136" class="foreground">127.0.0.1:6379> g</text><text x="136" textLength="8" class="background"> </text><text x="144" textLength="384" class="foreground"> </text></g><g id="g366"><text x="0" textLength="136" class="foreground">127.0.0.1:6379> d</text><text x="136" textLength="8" class="background">e</text><text x="144" textLength="200" fill="#626262">l _kombu.binding.celeryev</text><text x="344" textLength="184" class="foreground"> </text></g><g id="g367"><text x="8" textLength="128" class="foreground"> </text><text x="136" textLength="128" fill="#ffffff"> DEL </text><text x="264" textLength="8" fill="#000000"> </text><text x="272" textLength="256" class="foreground"> </text></g><g id="g368"><text x="8" textLength="128" class="foreground"> </text><text x="136" textLength="128" fill="#ffffff"> DECR </text><text x="264" textLength="8" fill="#000000"> </text><text x="272" textLength="256" class="foreground"> </text></g><g id="g369"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="128" fill="#ffffff"> DUMP </text><text x="264" textLength="8" fill="#000000"> </text><text x="272" textLength="256" class="foreground"> </text></g><g id="g370"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="128" fill="#ffffff"> DECRBY </text><text x="264" textLength="8" fill="#000000"> </text><text x="272" textLength="256" class="foreground"> </text></g><g id="g371"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="128" fill="#ffffff"> DBSIZE </text><text x="264" textLength="8" fill="#000000"> </text><text x="272" textLength="256" class="foreground"> </text></g><g id="g372"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="128" fill="#ffffff"> DISCARD </text><text x="264" textLength="8" fill="#000000"> </text><text x="272" textLength="256" class="foreground"> </text></g><g id="g373"><text x="0" textLength="136" class="foreground"> </text><text x="136" textLength="128" fill="#ffffff"> DEBUG OBJECT </text><text x="264" textLength="8" fill="#000000"> </text><text x="272" textLength="256" class="foreground"> </text></g><g id="g374"><text x="0" textLength="144" class="foreground">127.0.0.1:6379> de</text><text x="144" textLength="8" class="background">l</text><text x="152" textLength="192" fill="#626262"> _kombu.binding.celeryev</text><text x="344" textLength="184" class="foreground"> </text></g><g id="g375"><text x="8" textLength="136" class="foreground"> </text><text x="144" textLength="128" fill="#ffffff"> DEL </text><text x="272" textLength="8" fill="#000000"> </text><text x="280" textLength="248" class="foreground"> </text></g><g id="g376"><text x="8" textLength="136" class="foreground"> </text><text x="144" textLength="128" fill="#ffffff"> DECR </text><text x="272" textLength="8" fill="#000000"> </text><text x="280" textLength="248" class="foreground"> </text></g><g id="g377"><text x="0" textLength="144" class="foreground"> </text><text x="144" textLength="128" fill="#ffffff"> DECRBY </text><text x="272" textLength="8" fill="#000000"> </text><text x="280" textLength="248" class="foreground"> </text></g><g id="g378"><text x="0" textLength="144" class="foreground"> </text><text x="144" textLength="128" fill="#ffffff"> DEBUG OBJECT </text><text x="272" textLength="8" fill="#000000"> </text><text x="280" textLength="248" class="foreground"> </text></g><g id="g379"><text x="0" textLength="144" class="foreground"> </text><text x="144" textLength="128" fill="#ffffff"> DEBUG SEGFAULT </text><text x="272" textLength="8" fill="#000000"> </text><text x="280" textLength="248" class="foreground"> </text></g><g id="g380"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">del</text><text x="152" textLength="8" class="background"> </text><text x="160" textLength="184" fill="#626262">_kombu.binding.celeryev</text><text x="344" textLength="184" class="foreground"> </text></g><g id="g381"><text x="8" textLength="144" class="foreground"> </text><text x="152" textLength="56" fill="#ffffff"> DEL </text><text x="208" textLength="8" fill="#000000"> </text><text x="216" textLength="312" class="foreground"> </text></g><g id="g382"><text x="0" textLength="80" font-weight="bold" fill="#d75f5f">(generic) </text><text x="80" textLength="24" font-weight="bold" fill="#008700">DEL</text><text x="104" textLength="32" fill="#5faf5f"> key</text><text x="136" textLength="120" fill="#af8700"> since: 1.0.0</text><text x="256" textLength="272" fill="#626262"> complexity:O(N) where N is the nu</text></g><g id="g383"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">del</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="8" class="background">_</text><text x="168" textLength="176" fill="#626262">kombu.binding.celeryev</text><text x="344" textLength="184" class="foreground"> </text></g><g id="g384"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">del</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="8" fill="#5faf5f">a</text><text x="168" textLength="8" class="background">\</text><text x="176" textLength="24" fill="#626262">"bc</text><text x="200" textLength="328" class="foreground"> </text></g><g id="g385"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">del</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="8" class="background"> </text><text x="184" textLength="344" class="foreground"> </text></g><g id="g386"><text x="8" textLength="160" class="foreground"> </text><text x="168" textLength="8" fill="#000000"> </text><text x="176" textLength="8" text-decoration="underline" fill="#000000">a</text><text x="184" textLength="8" class="foreground">f</text><text x="192" textLength="120" fill="#000000"> </text><text x="312" textLength="216" class="foreground"> </text></g><g id="g387"><text x="0" textLength="128" class="foreground">127.0.0.1:6379> </text><text x="128" textLength="24" font-weight="bold" fill="#008700">del</text><text x="152" textLength="8" class="foreground"> </text><text x="160" textLength="16" fill="#5faf5f">af</text><text x="176" textLength="352" class="foreground"> </text></g><g id="g388"><text x="0" textLength="80" fill="#878787">(integer) </text><text x="80" textLength="448" class="foreground">1 </text></g><g id="g389"><text x="0" textLength="528" fill="#878787">127.0.0.1:6379> </text></g><g id="g390"><text x="0" textLength="528" class="foreground">Goodbye! </text></g><g id="g391"><text x="0" textLength="528" class="foreground">$ </text></g></defs><g id="screen_view"><g><rect x="0" y="0" width="8" height="17" class="foreground"/><use xlink:href="#g1" y="0"/></g><g><rect x="16" y="374" width="8" height="17" class="foreground"/><use xlink:href="#g2" y="374"/></g><g><rect x="24" y="748" width="8" height="17" class="foreground"/><use xlink:href="#g3" y="748"/></g><g><rect x="32" y="1122" width="8" height="17" class="foreground"/><use xlink:href="#g4" y="1122"/></g><g><rect x="40" y="1496" width="8" height="17" class="foreground"/><use xlink:href="#g5" y="1496"/></g><g><rect x="48" y="1870" width="8" height="17" class="foreground"/><use xlink:href="#g6" y="1870"/></g><g><rect x="56" y="2244" width="8" height="17" class="foreground"/><use xlink:href="#g7" y="2244"/></g><g><rect x="64" y="2618" width="8" height="17" class="foreground"/><use xlink:href="#g8" y="2618"/></g><g><use xlink:href="#g9" y="2992"/><rect x="0" y="3009" width="8" height="17" class="foreground"/><use xlink:href="#g10" y="3009"/></g><g><use xlink:href="#g9" y="3366"/><use xlink:href="#g11" y="3383"/><use xlink:href="#g12" y="3400"/><use xlink:href="#g13" y="3417"/><use xlink:href="#g14" y="3434"/><rect x="128" y="3451" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="3451"/><use xlink:href="#g16" y="3570"/><use xlink:href="#g16" y="3672"/><rect x="0" y="3689" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="3689"/></g><g><use xlink:href="#g9" y="3740"/><use xlink:href="#g11" y="3757"/><use xlink:href="#g12" y="3774"/><use xlink:href="#g13" y="3791"/><use xlink:href="#g14" y="3808"/><rect x="136" y="3825" width="8" height="17" class="foreground"/><use xlink:href="#g18" y="3825"/><rect x="136" y="3842" width="56" height="17" fill="#008787"/><rect x="192" y="3842" width="8" height="17" fill="#444444"/><use xlink:href="#g19" y="3842"/><use xlink:href="#g16" y="3944"/><use xlink:href="#g16" y="4046"/><rect x="0" y="4063" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="4063"/></g><g><use xlink:href="#g9" y="4114"/><use xlink:href="#g11" y="4131"/><use xlink:href="#g12" y="4148"/><use xlink:href="#g13" y="4165"/><use xlink:href="#g14" y="4182"/><rect x="144" y="4199" width="8" height="17" class="foreground"/><use xlink:href="#g20" y="4199"/><rect x="144" y="4216" width="56" height="17" fill="#008787"/><rect x="200" y="4216" width="8" height="17" fill="#444444"/><use xlink:href="#g21" y="4216"/><use xlink:href="#g16" y="4318"/><use xlink:href="#g16" y="4420"/><rect x="0" y="4437" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="4437"/></g><g><use xlink:href="#g9" y="4488"/><use xlink:href="#g11" y="4505"/><use xlink:href="#g12" y="4522"/><use xlink:href="#g13" y="4539"/><use xlink:href="#g14" y="4556"/><rect x="152" y="4573" width="8" height="17" class="foreground"/><use xlink:href="#g22" y="4573"/><rect x="152" y="4590" width="56" height="17" fill="#008787"/><rect x="208" y="4590" width="8" height="17" fill="#444444"/><use xlink:href="#g23" y="4590"/><use xlink:href="#g16" y="4692"/><use xlink:href="#g16" y="4794"/><rect x="0" y="4811" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="4811"/></g><g><use xlink:href="#g9" y="4862"/><use xlink:href="#g11" y="4879"/><use xlink:href="#g12" y="4896"/><use xlink:href="#g13" y="4913"/><use xlink:href="#g14" y="4930"/><rect x="160" y="4947" width="8" height="17" class="foreground"/><use xlink:href="#g24" y="4947"/><rect x="160" y="4964" width="56" height="17" fill="#008787"/><rect x="216" y="4964" width="8" height="17" fill="#444444"/><use xlink:href="#g25" y="4964"/><use xlink:href="#g16" y="5066"/><use xlink:href="#g16" y="5168"/><rect x="0" y="5185" width="528" height="17" fill="#262626"/><use xlink:href="#g26" y="5185"/></g><g><use xlink:href="#g9" y="5236"/><use xlink:href="#g11" y="5253"/><use xlink:href="#g12" y="5270"/><use xlink:href="#g13" y="5287"/><use xlink:href="#g14" y="5304"/><rect x="168" y="5321" width="8" height="17" class="foreground"/><use xlink:href="#g27" y="5321"/><use xlink:href="#g28" y="5338"/><use xlink:href="#g16" y="5440"/><use xlink:href="#g16" y="5542"/><rect x="0" y="5559" width="528" height="17" fill="#262626"/><use xlink:href="#g26" y="5559"/></g><g><use xlink:href="#g9" y="5610"/><use xlink:href="#g11" y="5627"/><use xlink:href="#g12" y="5644"/><use xlink:href="#g13" y="5661"/><use xlink:href="#g14" y="5678"/><rect x="176" y="5695" width="8" height="17" class="foreground"/><use xlink:href="#g29" y="5695"/><use xlink:href="#g28" y="5712"/><use xlink:href="#g16" y="5814"/><use xlink:href="#g16" y="5916"/><rect x="0" y="5933" width="528" height="17" fill="#262626"/><use xlink:href="#g26" y="5933"/></g><g><use xlink:href="#g30" y="5984"/><use xlink:href="#g31" y="6001"/><use xlink:href="#g32" y="6018"/><use xlink:href="#g33" y="6035"/><use xlink:href="#g34" y="6052"/><use xlink:href="#g35" y="6069"/><use xlink:href="#g36" y="6086"/><use xlink:href="#g37" y="6103"/><use xlink:href="#g38" y="6120"/><use xlink:href="#g39" y="6137"/><use xlink:href="#g40" y="6154"/><rect x="128" y="6171" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="6171"/><use xlink:href="#g16" y="6290"/><rect x="0" y="6307" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="6307"/></g><g><use xlink:href="#g30" y="6358"/><use xlink:href="#g31" y="6375"/><use xlink:href="#g32" y="6392"/><use xlink:href="#g33" y="6409"/><use xlink:href="#g34" y="6426"/><use xlink:href="#g35" y="6443"/><use xlink:href="#g36" y="6460"/><use xlink:href="#g37" y="6477"/><use xlink:href="#g38" y="6494"/><use xlink:href="#g39" y="6511"/><use xlink:href="#g40" y="6528"/><rect x="136" y="6545" width="8" height="17" class="foreground"/><use xlink:href="#g41" y="6545"/><rect x="136" y="6562" width="56" height="17" fill="#008787"/><rect x="192" y="6562" width="8" height="17" fill="#444444"/><use xlink:href="#g42" y="6562"/><rect x="136" y="6579" width="56" height="17" fill="#008787"/><rect x="192" y="6579" width="8" height="17" fill="#444444"/><use xlink:href="#g43" y="6579"/><rect x="136" y="6596" width="56" height="17" fill="#008787"/><rect x="192" y="6596" width="8" height="17" fill="#444444"/><use xlink:href="#g44" y="6596"/><rect x="136" y="6613" width="56" height="17" fill="#008787"/><rect x="192" y="6613" width="8" height="17" fill="#444444"/><use xlink:href="#g45" y="6613"/><use xlink:href="#g16" y="6664"/><rect x="0" y="6681" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="6681"/></g><g><use xlink:href="#g30" y="6732"/><use xlink:href="#g31" y="6749"/><use xlink:href="#g32" y="6766"/><use xlink:href="#g33" y="6783"/><use xlink:href="#g34" y="6800"/><use xlink:href="#g35" y="6817"/><use xlink:href="#g36" y="6834"/><use xlink:href="#g37" y="6851"/><use xlink:href="#g38" y="6868"/><use xlink:href="#g39" y="6885"/><use xlink:href="#g40" y="6902"/><rect x="144" y="6919" width="8" height="17" class="foreground"/><use xlink:href="#g46" y="6919"/><rect x="144" y="6936" width="56" height="17" fill="#008787"/><rect x="200" y="6936" width="8" height="17" fill="#444444"/><use xlink:href="#g47" y="6936"/><use xlink:href="#g28" y="6953"/><use xlink:href="#g28" y="6970"/><use xlink:href="#g28" y="6987"/><use xlink:href="#g16" y="7038"/><rect x="0" y="7055" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="7055"/></g><g><use xlink:href="#g30" y="7106"/><use xlink:href="#g31" y="7123"/><use xlink:href="#g32" y="7140"/><use xlink:href="#g33" y="7157"/><use xlink:href="#g34" y="7174"/><use xlink:href="#g35" y="7191"/><use xlink:href="#g36" y="7208"/><use xlink:href="#g37" y="7225"/><use xlink:href="#g38" y="7242"/><use xlink:href="#g39" y="7259"/><use xlink:href="#g40" y="7276"/><rect x="152" y="7293" width="8" height="17" class="foreground"/><use xlink:href="#g48" y="7293"/><rect x="152" y="7310" width="56" height="17" fill="#008787"/><rect x="208" y="7310" width="8" height="17" fill="#444444"/><use xlink:href="#g49" y="7310"/><use xlink:href="#g28" y="7327"/><use xlink:href="#g28" y="7344"/><use xlink:href="#g28" y="7361"/><use xlink:href="#g16" y="7412"/><rect x="0" y="7429" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="7429"/></g><g><use xlink:href="#g30" y="7480"/><use xlink:href="#g31" y="7497"/><use xlink:href="#g32" y="7514"/><use xlink:href="#g33" y="7531"/><use xlink:href="#g34" y="7548"/><use xlink:href="#g35" y="7565"/><use xlink:href="#g36" y="7582"/><use xlink:href="#g37" y="7599"/><use xlink:href="#g38" y="7616"/><use xlink:href="#g39" y="7633"/><use xlink:href="#g40" y="7650"/><rect x="160" y="7667" width="8" height="17" class="foreground"/><use xlink:href="#g50" y="7667"/><rect x="160" y="7684" width="56" height="17" fill="#008787"/><rect x="216" y="7684" width="8" height="17" fill="#444444"/><use xlink:href="#g51" y="7684"/><use xlink:href="#g28" y="7701"/><use xlink:href="#g28" y="7718"/><use xlink:href="#g28" y="7735"/><use xlink:href="#g16" y="7786"/><rect x="0" y="7803" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="7803"/></g><g><use xlink:href="#g30" y="7854"/><use xlink:href="#g31" y="7871"/><use xlink:href="#g32" y="7888"/><use xlink:href="#g33" y="7905"/><use xlink:href="#g34" y="7922"/><use xlink:href="#g35" y="7939"/><use xlink:href="#g36" y="7956"/><use xlink:href="#g37" y="7973"/><use xlink:href="#g38" y="7990"/><use xlink:href="#g39" y="8007"/><use xlink:href="#g40" y="8024"/><rect x="168" y="8041" width="8" height="17" class="foreground"/><use xlink:href="#g53" y="8041"/><rect x="168" y="8058" width="136" height="17" fill="#008787"/><rect x="304" y="8058" width="8" height="17" fill="#444444"/><use xlink:href="#g54" y="8058"/><rect x="168" y="8075" width="136" height="17" fill="#008787"/><rect x="304" y="8075" width="8" height="17" fill="#444444"/><use xlink:href="#g55" y="8075"/><rect x="168" y="8092" width="136" height="17" fill="#008787"/><rect x="304" y="8092" width="8" height="17" fill="#00afaf"/><use xlink:href="#g56" y="8092"/><rect x="168" y="8109" width="136" height="17" fill="#008787"/><rect x="304" y="8109" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g57" y="8109"/><rect x="168" y="8126" width="136" height="17" fill="#008787"/><rect x="304" y="8126" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g58" y="8126"/><rect x="168" y="8143" width="136" height="17" fill="#008787"/><rect x="304" y="8143" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g59" y="8143"/><rect x="168" y="8160" width="136" height="17" fill="#008787"/><rect x="304" y="8160" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g60" y="8160"/><rect x="0" y="8177" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="8177"/></g><g><use xlink:href="#g30" y="8228"/><use xlink:href="#g31" y="8245"/><use xlink:href="#g32" y="8262"/><use xlink:href="#g33" y="8279"/><use xlink:href="#g34" y="8296"/><use xlink:href="#g35" y="8313"/><use xlink:href="#g36" y="8330"/><use xlink:href="#g37" y="8347"/><use xlink:href="#g38" y="8364"/><use xlink:href="#g39" y="8381"/><use xlink:href="#g40" y="8398"/><rect x="176" y="8415" width="8" height="17" class="foreground"/><use xlink:href="#g61" y="8415"/><rect x="176" y="8432" width="112" height="17" fill="#008787"/><rect x="288" y="8432" width="8" height="17" fill="#444444"/><use xlink:href="#g62" y="8432"/><rect x="176" y="8449" width="112" height="17" fill="#008787"/><rect x="288" y="8449" width="8" height="17" fill="#444444"/><use xlink:href="#g63" y="8449"/><rect x="176" y="8466" width="112" height="17" fill="#008787"/><rect x="288" y="8466" width="8" height="17" fill="#444444"/><use xlink:href="#g64" y="8466"/><rect x="176" y="8483" width="112" height="17" fill="#008787"/><rect x="288" y="8483" width="8" height="17" fill="#444444"/><use xlink:href="#g65" y="8483"/><rect x="176" y="8500" width="112" height="17" fill="#008787"/><rect x="288" y="8500" width="8" height="17" fill="#444444"/><use xlink:href="#g66" y="8500"/><rect x="176" y="8517" width="112" height="17" fill="#008787"/><rect x="288" y="8517" width="8" height="17" fill="#444444"/><use xlink:href="#g67" y="8517"/><use xlink:href="#g16" y="8534"/><rect x="0" y="8551" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="8551"/></g><g><use xlink:href="#g30" y="8602"/><use xlink:href="#g31" y="8619"/><use xlink:href="#g32" y="8636"/><use xlink:href="#g33" y="8653"/><use xlink:href="#g34" y="8670"/><use xlink:href="#g35" y="8687"/><use xlink:href="#g36" y="8704"/><use xlink:href="#g37" y="8721"/><use xlink:href="#g38" y="8738"/><use xlink:href="#g39" y="8755"/><use xlink:href="#g40" y="8772"/><rect x="184" y="8789" width="8" height="17" class="foreground"/><use xlink:href="#g68" y="8789"/><rect x="184" y="8806" width="72" height="17" fill="#008787"/><rect x="256" y="8806" width="8" height="17" fill="#444444"/><use xlink:href="#g69" y="8806"/><rect x="184" y="8823" width="72" height="17" fill="#008787"/><rect x="256" y="8823" width="8" height="17" fill="#444444"/><use xlink:href="#g70" y="8823"/><rect x="184" y="8840" width="72" height="17" fill="#008787"/><rect x="256" y="8840" width="8" height="17" fill="#444444"/><use xlink:href="#g71" y="8840"/><use xlink:href="#g28" y="8857"/><use xlink:href="#g28" y="8874"/><use xlink:href="#g28" y="8891"/><use xlink:href="#g16" y="8908"/><rect x="0" y="8925" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="8925"/></g><g><use xlink:href="#g30" y="8976"/><use xlink:href="#g31" y="8993"/><use xlink:href="#g32" y="9010"/><use xlink:href="#g33" y="9027"/><use xlink:href="#g34" y="9044"/><use xlink:href="#g35" y="9061"/><use xlink:href="#g36" y="9078"/><use xlink:href="#g37" y="9095"/><use xlink:href="#g38" y="9112"/><use xlink:href="#g39" y="9129"/><use xlink:href="#g40" y="9146"/><rect x="208" y="9163" width="8" height="17" class="foreground"/><use xlink:href="#g72" y="9163"/><rect x="184" y="9180" width="72" height="17" fill="#ffffff"/><rect x="256" y="9180" width="8" height="17" fill="#444444"/><use xlink:href="#g73" y="9180"/><rect x="184" y="9197" width="72" height="17" fill="#008787"/><rect x="256" y="9197" width="8" height="17" fill="#444444"/><use xlink:href="#g70" y="9197"/><rect x="184" y="9214" width="72" height="17" fill="#008787"/><rect x="256" y="9214" width="8" height="17" fill="#444444"/><use xlink:href="#g71" y="9214"/><use xlink:href="#g28" y="9231"/><use xlink:href="#g28" y="9248"/><use xlink:href="#g28" y="9265"/><use xlink:href="#g16" y="9282"/><rect x="0" y="9299" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="9299"/></g><g><use xlink:href="#g32" y="9350"/><use xlink:href="#g33" y="9367"/><use xlink:href="#g34" y="9384"/><use xlink:href="#g35" y="9401"/><use xlink:href="#g36" y="9418"/><use xlink:href="#g37" y="9435"/><use xlink:href="#g38" y="9452"/><use xlink:href="#g39" y="9469"/><use xlink:href="#g40" y="9486"/><use xlink:href="#g74" y="9503"/><use xlink:href="#g75" y="9520"/><rect x="128" y="9537" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="9537"/><use xlink:href="#g28" y="9554"/><use xlink:href="#g28" y="9571"/><use xlink:href="#g28" y="9588"/><use xlink:href="#g28" y="9605"/><use xlink:href="#g16" y="9622"/><use xlink:href="#g16" y="9639"/><use xlink:href="#g16" y="9656"/><rect x="0" y="9673" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="9673"/></g><g><use xlink:href="#g32" y="9724"/><use xlink:href="#g33" y="9741"/><use xlink:href="#g34" y="9758"/><use xlink:href="#g35" y="9775"/><use xlink:href="#g36" y="9792"/><use xlink:href="#g37" y="9809"/><use xlink:href="#g38" y="9826"/><use xlink:href="#g39" y="9843"/><use xlink:href="#g40" y="9860"/><use xlink:href="#g74" y="9877"/><use xlink:href="#g75" y="9894"/><rect x="136" y="9911" width="8" height="17" class="foreground"/><use xlink:href="#g76" y="9911"/><rect x="136" y="9928" width="120" height="17" fill="#008787"/><rect x="256" y="9928" width="8" height="17" fill="#444444"/><use xlink:href="#g77" y="9928"/><rect x="136" y="9945" width="120" height="17" fill="#008787"/><rect x="256" y="9945" width="8" height="17" fill="#00afaf"/><use xlink:href="#g78" y="9945"/><rect x="136" y="9962" width="120" height="17" fill="#008787"/><rect x="256" y="9962" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g79" y="9962"/><rect x="136" y="9979" width="120" height="17" fill="#008787"/><rect x="256" y="9979" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g80" y="9979"/><rect x="136" y="9996" width="120" height="17" fill="#008787"/><rect x="256" y="9996" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g81" y="9996"/><rect x="136" y="10013" width="120" height="17" fill="#008787"/><rect x="256" y="10013" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g82" y="10013"/><rect x="136" y="10030" width="120" height="17" fill="#008787"/><rect x="256" y="10030" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g83" y="10030"/><rect x="0" y="10047" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="10047"/></g><g><use xlink:href="#g32" y="10098"/><use xlink:href="#g33" y="10115"/><use xlink:href="#g34" y="10132"/><use xlink:href="#g35" y="10149"/><use xlink:href="#g36" y="10166"/><use xlink:href="#g37" y="10183"/><use xlink:href="#g38" y="10200"/><use xlink:href="#g39" y="10217"/><use xlink:href="#g40" y="10234"/><use xlink:href="#g74" y="10251"/><use xlink:href="#g75" y="10268"/><rect x="144" y="10285" width="8" height="17" class="foreground"/><use xlink:href="#g84" y="10285"/><rect x="144" y="10302" width="80" height="17" fill="#008787"/><rect x="224" y="10302" width="8" height="17" fill="#444444"/><use xlink:href="#g85" y="10302"/><rect x="144" y="10319" width="80" height="17" fill="#008787"/><rect x="224" y="10319" width="8" height="17" fill="#444444"/><use xlink:href="#g86" y="10319"/><use xlink:href="#g28" y="10336"/><use xlink:href="#g28" y="10353"/><use xlink:href="#g16" y="10370"/><use xlink:href="#g16" y="10387"/><use xlink:href="#g16" y="10404"/><rect x="0" y="10421" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="10421"/></g><g><use xlink:href="#g32" y="10472"/><use xlink:href="#g33" y="10489"/><use xlink:href="#g34" y="10506"/><use xlink:href="#g35" y="10523"/><use xlink:href="#g36" y="10540"/><use xlink:href="#g37" y="10557"/><use xlink:href="#g38" y="10574"/><use xlink:href="#g39" y="10591"/><use xlink:href="#g40" y="10608"/><use xlink:href="#g74" y="10625"/><use xlink:href="#g75" y="10642"/><rect x="152" y="10659" width="8" height="17" class="foreground"/><use xlink:href="#g87" y="10659"/><rect x="152" y="10676" width="80" height="17" fill="#008787"/><rect x="232" y="10676" width="8" height="17" fill="#444444"/><use xlink:href="#g88" y="10676"/><use xlink:href="#g28" y="10693"/><use xlink:href="#g28" y="10710"/><use xlink:href="#g28" y="10727"/><use xlink:href="#g16" y="10744"/><use xlink:href="#g16" y="10761"/><use xlink:href="#g16" y="10778"/><rect x="0" y="10795" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="10795"/></g><g><use xlink:href="#g32" y="10846"/><use xlink:href="#g33" y="10863"/><use xlink:href="#g34" y="10880"/><use xlink:href="#g35" y="10897"/><use xlink:href="#g36" y="10914"/><use xlink:href="#g37" y="10931"/><use xlink:href="#g38" y="10948"/><use xlink:href="#g39" y="10965"/><use xlink:href="#g40" y="10982"/><use xlink:href="#g74" y="10999"/><use xlink:href="#g75" y="11016"/><rect x="160" y="11033" width="8" height="17" class="foreground"/><use xlink:href="#g89" y="11033"/><rect x="160" y="11050" width="80" height="17" fill="#008787"/><rect x="240" y="11050" width="8" height="17" fill="#444444"/><use xlink:href="#g90" y="11050"/><use xlink:href="#g28" y="11067"/><use xlink:href="#g28" y="11084"/><use xlink:href="#g28" y="11101"/><use xlink:href="#g16" y="11118"/><use xlink:href="#g16" y="11135"/><use xlink:href="#g16" y="11152"/><rect x="0" y="11169" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="11169"/></g><g><use xlink:href="#g32" y="11220"/><use xlink:href="#g33" y="11237"/><use xlink:href="#g34" y="11254"/><use xlink:href="#g35" y="11271"/><use xlink:href="#g36" y="11288"/><use xlink:href="#g37" y="11305"/><use xlink:href="#g38" y="11322"/><use xlink:href="#g39" y="11339"/><use xlink:href="#g40" y="11356"/><use xlink:href="#g74" y="11373"/><use xlink:href="#g75" y="11390"/><rect x="192" y="11407" width="8" height="17" class="foreground"/><use xlink:href="#g91" y="11407"/><rect x="160" y="11424" width="80" height="17" fill="#ffffff"/><rect x="240" y="11424" width="8" height="17" fill="#444444"/><use xlink:href="#g92" y="11424"/><use xlink:href="#g28" y="11441"/><use xlink:href="#g28" y="11458"/><use xlink:href="#g28" y="11475"/><use xlink:href="#g16" y="11492"/><use xlink:href="#g16" y="11509"/><use xlink:href="#g16" y="11526"/><rect x="0" y="11543" width="528" height="17" fill="#262626"/><use xlink:href="#g93" y="11543"/></g><g><use xlink:href="#g32" y="11594"/><use xlink:href="#g33" y="11611"/><use xlink:href="#g34" y="11628"/><use xlink:href="#g35" y="11645"/><use xlink:href="#g36" y="11662"/><use xlink:href="#g37" y="11679"/><use xlink:href="#g38" y="11696"/><use xlink:href="#g39" y="11713"/><use xlink:href="#g40" y="11730"/><use xlink:href="#g74" y="11747"/><use xlink:href="#g75" y="11764"/><rect x="200" y="11781" width="8" height="17" class="foreground"/><use xlink:href="#g94" y="11781"/><rect x="200" y="11798" width="136" height="17" fill="#008787"/><rect x="336" y="11798" width="8" height="17" fill="#444444"/><use xlink:href="#g95" y="11798"/><rect x="200" y="11815" width="136" height="17" fill="#008787"/><rect x="336" y="11815" width="8" height="17" fill="#444444"/><use xlink:href="#g96" y="11815"/><rect x="200" y="11832" width="136" height="17" fill="#008787"/><rect x="336" y="11832" width="8" height="17" fill="#00afaf"/><use xlink:href="#g97" y="11832"/><rect x="200" y="11849" width="136" height="17" fill="#008787"/><rect x="336" y="11849" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g98" y="11849"/><rect x="200" y="11866" width="136" height="17" fill="#008787"/><rect x="336" y="11866" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g99" y="11866"/><rect x="200" y="11883" width="136" height="17" fill="#008787"/><rect x="336" y="11883" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g100" y="11883"/><rect x="200" y="11900" width="136" height="17" fill="#008787"/><rect x="336" y="11900" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g101" y="11900"/><rect x="0" y="11917" width="528" height="17" fill="#262626"/><use xlink:href="#g93" y="11917"/></g><g><use xlink:href="#g32" y="11968"/><use xlink:href="#g33" y="11985"/><use xlink:href="#g34" y="12002"/><use xlink:href="#g35" y="12019"/><use xlink:href="#g36" y="12036"/><use xlink:href="#g37" y="12053"/><use xlink:href="#g38" y="12070"/><use xlink:href="#g39" y="12087"/><use xlink:href="#g40" y="12104"/><use xlink:href="#g74" y="12121"/><use xlink:href="#g75" y="12138"/><rect x="208" y="12155" width="8" height="17" class="foreground"/><use xlink:href="#g102" y="12155"/><rect x="208" y="12172" width="112" height="17" fill="#008787"/><rect x="320" y="12172" width="8" height="17" fill="#444444"/><use xlink:href="#g103" y="12172"/><rect x="208" y="12189" width="112" height="17" fill="#008787"/><rect x="320" y="12189" width="8" height="17" fill="#444444"/><use xlink:href="#g104" y="12189"/><rect x="208" y="12206" width="112" height="17" fill="#008787"/><rect x="320" y="12206" width="8" height="17" fill="#444444"/><use xlink:href="#g105" y="12206"/><rect x="208" y="12223" width="112" height="17" fill="#008787"/><rect x="320" y="12223" width="8" height="17" fill="#444444"/><use xlink:href="#g106" y="12223"/><rect x="208" y="12240" width="112" height="17" fill="#008787"/><rect x="320" y="12240" width="8" height="17" fill="#444444"/><use xlink:href="#g107" y="12240"/><rect x="208" y="12257" width="112" height="17" fill="#008787"/><rect x="320" y="12257" width="8" height="17" fill="#444444"/><use xlink:href="#g108" y="12257"/><use xlink:href="#g16" y="12274"/><rect x="0" y="12291" width="528" height="17" fill="#262626"/><use xlink:href="#g93" y="12291"/></g><g><use xlink:href="#g32" y="12342"/><use xlink:href="#g33" y="12359"/><use xlink:href="#g34" y="12376"/><use xlink:href="#g35" y="12393"/><use xlink:href="#g36" y="12410"/><use xlink:href="#g37" y="12427"/><use xlink:href="#g38" y="12444"/><use xlink:href="#g39" y="12461"/><use xlink:href="#g40" y="12478"/><use xlink:href="#g74" y="12495"/><use xlink:href="#g75" y="12512"/><rect x="216" y="12529" width="8" height="17" class="foreground"/><use xlink:href="#g109" y="12529"/><rect x="216" y="12546" width="72" height="17" fill="#008787"/><rect x="288" y="12546" width="8" height="17" fill="#444444"/><use xlink:href="#g110" y="12546"/><rect x="216" y="12563" width="72" height="17" fill="#008787"/><rect x="288" y="12563" width="8" height="17" fill="#444444"/><use xlink:href="#g111" y="12563"/><rect x="216" y="12580" width="72" height="17" fill="#008787"/><rect x="288" y="12580" width="8" height="17" fill="#444444"/><use xlink:href="#g112" y="12580"/><use xlink:href="#g28" y="12597"/><use xlink:href="#g16" y="12614"/><use xlink:href="#g16" y="12631"/><use xlink:href="#g16" y="12648"/><rect x="0" y="12665" width="528" height="17" fill="#262626"/><use xlink:href="#g93" y="12665"/></g><g><use xlink:href="#g32" y="12716"/><use xlink:href="#g33" y="12733"/><use xlink:href="#g34" y="12750"/><use xlink:href="#g35" y="12767"/><use xlink:href="#g36" y="12784"/><use xlink:href="#g37" y="12801"/><use xlink:href="#g38" y="12818"/><use xlink:href="#g39" y="12835"/><use xlink:href="#g40" y="12852"/><use xlink:href="#g74" y="12869"/><use xlink:href="#g75" y="12886"/><rect x="240" y="12903" width="8" height="17" class="foreground"/><use xlink:href="#g113" y="12903"/><rect x="216" y="12920" width="72" height="17" fill="#ffffff"/><rect x="288" y="12920" width="8" height="17" fill="#444444"/><use xlink:href="#g114" y="12920"/><rect x="216" y="12937" width="72" height="17" fill="#008787"/><rect x="288" y="12937" width="8" height="17" fill="#444444"/><use xlink:href="#g111" y="12937"/><rect x="216" y="12954" width="72" height="17" fill="#008787"/><rect x="288" y="12954" width="8" height="17" fill="#444444"/><use xlink:href="#g112" y="12954"/><use xlink:href="#g28" y="12971"/><use xlink:href="#g16" y="12988"/><use xlink:href="#g16" y="13005"/><use xlink:href="#g16" y="13022"/><rect x="0" y="13039" width="528" height="17" fill="#262626"/><use xlink:href="#g93" y="13039"/></g><g><use xlink:href="#g37" y="13090"/><use xlink:href="#g38" y="13107"/><use xlink:href="#g39" y="13124"/><use xlink:href="#g40" y="13141"/><use xlink:href="#g74" y="13158"/><use xlink:href="#g75" y="13175"/><use xlink:href="#g115" y="13192"/><use xlink:href="#g116" y="13209"/><use xlink:href="#g117" y="13226"/><use xlink:href="#g118" y="13243"/><use xlink:href="#g119" y="13260"/><rect x="128" y="13277" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="13277"/><use xlink:href="#g16" y="13294"/><use xlink:href="#g16" y="13311"/><use xlink:href="#g16" y="13328"/><use xlink:href="#g16" y="13396"/><rect x="0" y="13413" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="13413"/></g><g><use xlink:href="#g37" y="13464"/><use xlink:href="#g38" y="13481"/><use xlink:href="#g39" y="13498"/><use xlink:href="#g40" y="13515"/><use xlink:href="#g74" y="13532"/><use xlink:href="#g75" y="13549"/><use xlink:href="#g115" y="13566"/><use xlink:href="#g116" y="13583"/><use xlink:href="#g117" y="13600"/><use xlink:href="#g118" y="13617"/><use xlink:href="#g119" y="13634"/><rect x="136" y="13651" width="8" height="17" class="foreground"/><use xlink:href="#g41" y="13651"/><rect x="136" y="13668" width="56" height="17" fill="#008787"/><rect x="192" y="13668" width="8" height="17" fill="#444444"/><use xlink:href="#g120" y="13668"/><rect x="136" y="13685" width="56" height="17" fill="#008787"/><rect x="192" y="13685" width="8" height="17" fill="#444444"/><use xlink:href="#g121" y="13685"/><rect x="136" y="13702" width="56" height="17" fill="#008787"/><rect x="192" y="13702" width="8" height="17" fill="#444444"/><use xlink:href="#g122" y="13702"/><rect x="136" y="13719" width="56" height="17" fill="#008787"/><rect x="192" y="13719" width="8" height="17" fill="#444444"/><use xlink:href="#g45" y="13719"/><use xlink:href="#g16" y="13770"/><rect x="0" y="13787" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="13787"/></g><g><use xlink:href="#g37" y="13838"/><use xlink:href="#g38" y="13855"/><use xlink:href="#g39" y="13872"/><use xlink:href="#g40" y="13889"/><use xlink:href="#g74" y="13906"/><use xlink:href="#g75" y="13923"/><use xlink:href="#g115" y="13940"/><use xlink:href="#g116" y="13957"/><use xlink:href="#g117" y="13974"/><use xlink:href="#g118" y="13991"/><use xlink:href="#g119" y="14008"/><rect x="144" y="14025" width="8" height="17" class="foreground"/><use xlink:href="#g46" y="14025"/><rect x="144" y="14042" width="56" height="17" fill="#008787"/><rect x="200" y="14042" width="8" height="17" fill="#444444"/><use xlink:href="#g123" y="14042"/><use xlink:href="#g16" y="14059"/><use xlink:href="#g16" y="14076"/><use xlink:href="#g28" y="14093"/><use xlink:href="#g16" y="14144"/><rect x="0" y="14161" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="14161"/></g><g><use xlink:href="#g37" y="14212"/><use xlink:href="#g38" y="14229"/><use xlink:href="#g39" y="14246"/><use xlink:href="#g40" y="14263"/><use xlink:href="#g74" y="14280"/><use xlink:href="#g75" y="14297"/><use xlink:href="#g115" y="14314"/><use xlink:href="#g116" y="14331"/><use xlink:href="#g117" y="14348"/><use xlink:href="#g118" y="14365"/><use xlink:href="#g119" y="14382"/><rect x="152" y="14399" width="8" height="17" class="foreground"/><use xlink:href="#g48" y="14399"/><rect x="152" y="14416" width="56" height="17" fill="#008787"/><rect x="208" y="14416" width="8" height="17" fill="#444444"/><use xlink:href="#g124" y="14416"/><use xlink:href="#g16" y="14433"/><use xlink:href="#g16" y="14450"/><use xlink:href="#g28" y="14467"/><use xlink:href="#g16" y="14518"/><rect x="0" y="14535" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="14535"/></g><g><use xlink:href="#g37" y="14586"/><use xlink:href="#g38" y="14603"/><use xlink:href="#g39" y="14620"/><use xlink:href="#g40" y="14637"/><use xlink:href="#g74" y="14654"/><use xlink:href="#g75" y="14671"/><use xlink:href="#g115" y="14688"/><use xlink:href="#g116" y="14705"/><use xlink:href="#g117" y="14722"/><use xlink:href="#g118" y="14739"/><use xlink:href="#g119" y="14756"/><rect x="160" y="14773" width="8" height="17" class="foreground"/><use xlink:href="#g50" y="14773"/><rect x="160" y="14790" width="56" height="17" fill="#008787"/><rect x="216" y="14790" width="8" height="17" fill="#444444"/><use xlink:href="#g125" y="14790"/><use xlink:href="#g16" y="14807"/><use xlink:href="#g16" y="14824"/><use xlink:href="#g28" y="14841"/><use xlink:href="#g16" y="14892"/><rect x="0" y="14909" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="14909"/></g><g><use xlink:href="#g37" y="14960"/><use xlink:href="#g38" y="14977"/><use xlink:href="#g39" y="14994"/><use xlink:href="#g40" y="15011"/><use xlink:href="#g74" y="15028"/><use xlink:href="#g75" y="15045"/><use xlink:href="#g115" y="15062"/><use xlink:href="#g116" y="15079"/><use xlink:href="#g117" y="15096"/><use xlink:href="#g118" y="15113"/><use xlink:href="#g119" y="15130"/><rect x="168" y="15147" width="8" height="17" class="foreground"/><use xlink:href="#g53" y="15147"/><rect x="168" y="15164" width="136" height="17" fill="#008787"/><rect x="304" y="15164" width="8" height="17" fill="#444444"/><use xlink:href="#g126" y="15164"/><rect x="168" y="15181" width="136" height="17" fill="#008787"/><rect x="304" y="15181" width="8" height="17" fill="#444444"/><use xlink:href="#g127" y="15181"/><rect x="168" y="15198" width="136" height="17" fill="#008787"/><rect x="304" y="15198" width="8" height="17" fill="#00afaf"/><use xlink:href="#g128" y="15198"/><rect x="168" y="15215" width="136" height="17" fill="#008787"/><rect x="304" y="15215" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g56" y="15215"/><rect x="168" y="15232" width="136" height="17" fill="#008787"/><rect x="304" y="15232" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g129" y="15232"/><rect x="168" y="15249" width="136" height="17" fill="#008787"/><rect x="304" y="15249" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g58" y="15249"/><rect x="168" y="15266" width="136" height="17" fill="#008787"/><rect x="304" y="15266" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g60" y="15266"/><rect x="0" y="15283" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="15283"/></g><g><use xlink:href="#g37" y="15334"/><use xlink:href="#g38" y="15351"/><use xlink:href="#g39" y="15368"/><use xlink:href="#g40" y="15385"/><use xlink:href="#g74" y="15402"/><use xlink:href="#g75" y="15419"/><use xlink:href="#g115" y="15436"/><use xlink:href="#g116" y="15453"/><use xlink:href="#g117" y="15470"/><use xlink:href="#g118" y="15487"/><use xlink:href="#g119" y="15504"/><rect x="176" y="15521" width="8" height="17" class="foreground"/><use xlink:href="#g130" y="15521"/><rect x="176" y="15538" width="64" height="17" fill="#008787"/><rect x="240" y="15538" width="8" height="17" fill="#444444"/><use xlink:href="#g131" y="15538"/><rect x="176" y="15555" width="64" height="17" fill="#008787"/><rect x="240" y="15555" width="8" height="17" fill="#444444"/><use xlink:href="#g132" y="15555"/><rect x="176" y="15572" width="64" height="17" fill="#008787"/><rect x="240" y="15572" width="8" height="17" fill="#444444"/><use xlink:href="#g133" y="15572"/><use xlink:href="#g28" y="15589"/><use xlink:href="#g28" y="15606"/><use xlink:href="#g28" y="15623"/><use xlink:href="#g16" y="15640"/><rect x="0" y="15657" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="15657"/></g><g><use xlink:href="#g37" y="15708"/><use xlink:href="#g38" y="15725"/><use xlink:href="#g39" y="15742"/><use xlink:href="#g40" y="15759"/><use xlink:href="#g74" y="15776"/><use xlink:href="#g75" y="15793"/><use xlink:href="#g115" y="15810"/><use xlink:href="#g116" y="15827"/><use xlink:href="#g117" y="15844"/><use xlink:href="#g118" y="15861"/><use xlink:href="#g119" y="15878"/><rect x="184" y="15895" width="8" height="17" class="foreground"/><use xlink:href="#g134" y="15895"/><rect x="184" y="15912" width="56" height="17" fill="#008787"/><rect x="240" y="15912" width="8" height="17" fill="#444444"/><use xlink:href="#g135" y="15912"/><use xlink:href="#g16" y="15929"/><use xlink:href="#g16" y="15946"/><use xlink:href="#g28" y="15963"/><use xlink:href="#g28" y="15980"/><use xlink:href="#g28" y="15997"/><use xlink:href="#g16" y="16014"/><rect x="0" y="16031" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="16031"/></g><g><use xlink:href="#g37" y="16082"/><use xlink:href="#g38" y="16099"/><use xlink:href="#g39" y="16116"/><use xlink:href="#g40" y="16133"/><use xlink:href="#g74" y="16150"/><use xlink:href="#g75" y="16167"/><use xlink:href="#g115" y="16184"/><use xlink:href="#g116" y="16201"/><use xlink:href="#g117" y="16218"/><use xlink:href="#g118" y="16235"/><use xlink:href="#g119" y="16252"/><rect x="200" y="16269" width="8" height="17" class="foreground"/><use xlink:href="#g136" y="16269"/><rect x="184" y="16286" width="56" height="17" fill="#ffffff"/><rect x="240" y="16286" width="8" height="17" fill="#444444"/><use xlink:href="#g137" y="16286"/><use xlink:href="#g16" y="16303"/><use xlink:href="#g16" y="16320"/><use xlink:href="#g28" y="16337"/><use xlink:href="#g28" y="16354"/><use xlink:href="#g28" y="16371"/><use xlink:href="#g16" y="16388"/><rect x="0" y="16405" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="16405"/></g><g><use xlink:href="#g39" y="16456"/><use xlink:href="#g40" y="16473"/><use xlink:href="#g74" y="16490"/><use xlink:href="#g75" y="16507"/><use xlink:href="#g115" y="16524"/><use xlink:href="#g116" y="16541"/><use xlink:href="#g117" y="16558"/><use xlink:href="#g118" y="16575"/><use xlink:href="#g119" y="16592"/><use xlink:href="#g138" y="16609"/><use xlink:href="#g139" y="16626"/><rect x="128" y="16643" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="16643"/><use xlink:href="#g16" y="16660"/><use xlink:href="#g28" y="16677"/><use xlink:href="#g28" y="16694"/><use xlink:href="#g28" y="16711"/><use xlink:href="#g16" y="16728"/><use xlink:href="#g16" y="16745"/><use xlink:href="#g16" y="16762"/><rect x="0" y="16779" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="16779"/></g><g><use xlink:href="#g39" y="16830"/><use xlink:href="#g40" y="16847"/><use xlink:href="#g74" y="16864"/><use xlink:href="#g75" y="16881"/><use xlink:href="#g115" y="16898"/><use xlink:href="#g116" y="16915"/><use xlink:href="#g117" y="16932"/><use xlink:href="#g118" y="16949"/><use xlink:href="#g119" y="16966"/><use xlink:href="#g138" y="16983"/><use xlink:href="#g139" y="17000"/><rect x="136" y="17017" width="8" height="17" class="foreground"/><use xlink:href="#g140" y="17017"/><rect x="136" y="17034" width="144" height="17" fill="#008787"/><rect x="280" y="17034" width="8" height="17" fill="#444444"/><use xlink:href="#g141" y="17034"/><rect x="136" y="17051" width="144" height="17" fill="#008787"/><rect x="280" y="17051" width="8" height="17" fill="#444444"/><use xlink:href="#g142" y="17051"/><rect x="136" y="17068" width="144" height="17" fill="#008787"/><rect x="280" y="17068" width="8" height="17" fill="#00afaf"/><use xlink:href="#g143" y="17068"/><rect x="136" y="17085" width="144" height="17" fill="#008787"/><rect x="280" y="17085" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g144" y="17085"/><rect x="136" y="17102" width="144" height="17" fill="#008787"/><rect x="280" y="17102" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g145" y="17102"/><rect x="136" y="17119" width="144" height="17" fill="#008787"/><rect x="280" y="17119" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g146" y="17119"/><rect x="136" y="17136" width="144" height="17" fill="#008787"/><rect x="280" y="17136" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g147" y="17136"/><rect x="0" y="17153" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="17153"/></g><g><use xlink:href="#g39" y="17204"/><use xlink:href="#g40" y="17221"/><use xlink:href="#g74" y="17238"/><use xlink:href="#g75" y="17255"/><use xlink:href="#g115" y="17272"/><use xlink:href="#g116" y="17289"/><use xlink:href="#g117" y="17306"/><use xlink:href="#g118" y="17323"/><use xlink:href="#g119" y="17340"/><use xlink:href="#g138" y="17357"/><use xlink:href="#g139" y="17374"/><rect x="144" y="17391" width="8" height="17" class="foreground"/><use xlink:href="#g148" y="17391"/><rect x="144" y="17408" width="64" height="17" fill="#008787"/><rect x="208" y="17408" width="8" height="17" fill="#444444"/><use xlink:href="#g149" y="17408"/><rect x="144" y="17425" width="64" height="17" fill="#008787"/><rect x="208" y="17425" width="8" height="17" fill="#444444"/><use xlink:href="#g150" y="17425"/><use xlink:href="#g28" y="17442"/><use xlink:href="#g28" y="17459"/><use xlink:href="#g16" y="17476"/><use xlink:href="#g16" y="17493"/><use xlink:href="#g16" y="17510"/><rect x="0" y="17527" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="17527"/></g><g><use xlink:href="#g39" y="17578"/><use xlink:href="#g40" y="17595"/><use xlink:href="#g74" y="17612"/><use xlink:href="#g75" y="17629"/><use xlink:href="#g115" y="17646"/><use xlink:href="#g116" y="17663"/><use xlink:href="#g117" y="17680"/><use xlink:href="#g118" y="17697"/><use xlink:href="#g119" y="17714"/><use xlink:href="#g138" y="17731"/><use xlink:href="#g139" y="17748"/><rect x="152" y="17765" width="8" height="17" class="foreground"/><use xlink:href="#g151" y="17765"/><rect x="152" y="17782" width="64" height="17" fill="#008787"/><rect x="216" y="17782" width="8" height="17" fill="#444444"/><use xlink:href="#g152" y="17782"/><rect x="152" y="17799" width="64" height="17" fill="#008787"/><rect x="216" y="17799" width="8" height="17" fill="#444444"/><use xlink:href="#g153" y="17799"/><use xlink:href="#g28" y="17816"/><use xlink:href="#g28" y="17833"/><use xlink:href="#g16" y="17850"/><use xlink:href="#g16" y="17867"/><use xlink:href="#g16" y="17884"/><rect x="0" y="17901" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="17901"/></g><g><use xlink:href="#g39" y="17952"/><use xlink:href="#g40" y="17969"/><use xlink:href="#g74" y="17986"/><use xlink:href="#g75" y="18003"/><use xlink:href="#g115" y="18020"/><use xlink:href="#g116" y="18037"/><use xlink:href="#g117" y="18054"/><use xlink:href="#g118" y="18071"/><use xlink:href="#g119" y="18088"/><use xlink:href="#g138" y="18105"/><use xlink:href="#g139" y="18122"/><rect x="168" y="18139" width="8" height="17" class="foreground"/><use xlink:href="#g154" y="18139"/><rect x="152" y="18156" width="64" height="17" fill="#ffffff"/><rect x="216" y="18156" width="8" height="17" fill="#444444"/><use xlink:href="#g155" y="18156"/><rect x="152" y="18173" width="64" height="17" fill="#008787"/><rect x="216" y="18173" width="8" height="17" fill="#444444"/><use xlink:href="#g153" y="18173"/><use xlink:href="#g28" y="18190"/><use xlink:href="#g28" y="18207"/><use xlink:href="#g16" y="18224"/><use xlink:href="#g16" y="18241"/><use xlink:href="#g16" y="18258"/><rect x="0" y="18275" width="528" height="17" fill="#262626"/><use xlink:href="#g156" y="18275"/></g><g><use xlink:href="#g39" y="18326"/><use xlink:href="#g40" y="18343"/><use xlink:href="#g74" y="18360"/><use xlink:href="#g75" y="18377"/><use xlink:href="#g115" y="18394"/><use xlink:href="#g116" y="18411"/><use xlink:href="#g117" y="18428"/><use xlink:href="#g118" y="18445"/><use xlink:href="#g119" y="18462"/><use xlink:href="#g138" y="18479"/><use xlink:href="#g139" y="18496"/><rect x="176" y="18513" width="8" height="17" class="foreground"/><use xlink:href="#g157" y="18513"/><rect x="176" y="18530" width="136" height="17" fill="#008787"/><rect x="312" y="18530" width="8" height="17" fill="#444444"/><use xlink:href="#g158" y="18530"/><rect x="176" y="18547" width="136" height="17" fill="#008787"/><rect x="312" y="18547" width="8" height="17" fill="#444444"/><use xlink:href="#g159" y="18547"/><rect x="176" y="18564" width="136" height="17" fill="#008787"/><rect x="312" y="18564" width="8" height="17" fill="#00afaf"/><use xlink:href="#g160" y="18564"/><rect x="176" y="18581" width="136" height="17" fill="#008787"/><rect x="312" y="18581" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g161" y="18581"/><rect x="176" y="18598" width="136" height="17" fill="#008787"/><rect x="312" y="18598" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g162" y="18598"/><rect x="176" y="18615" width="136" height="17" fill="#008787"/><rect x="312" y="18615" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g163" y="18615"/><rect x="176" y="18632" width="136" height="17" fill="#008787"/><rect x="312" y="18632" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g164" y="18632"/><rect x="0" y="18649" width="528" height="17" fill="#262626"/><use xlink:href="#g156" y="18649"/></g><g><use xlink:href="#g39" y="18700"/><use xlink:href="#g40" y="18717"/><use xlink:href="#g74" y="18734"/><use xlink:href="#g75" y="18751"/><use xlink:href="#g115" y="18768"/><use xlink:href="#g116" y="18785"/><use xlink:href="#g117" y="18802"/><use xlink:href="#g118" y="18819"/><use xlink:href="#g119" y="18836"/><use xlink:href="#g138" y="18853"/><use xlink:href="#g139" y="18870"/><rect x="208" y="18887" width="8" height="17" class="foreground"/><use xlink:href="#g165" y="18887"/><rect x="176" y="18904" width="136" height="17" fill="#ffffff"/><rect x="312" y="18904" width="8" height="17" fill="#444444"/><use xlink:href="#g166" y="18904"/><rect x="176" y="18921" width="136" height="17" fill="#008787"/><rect x="312" y="18921" width="8" height="17" fill="#444444"/><use xlink:href="#g159" y="18921"/><rect x="176" y="18938" width="136" height="17" fill="#008787"/><rect x="312" y="18938" width="8" height="17" fill="#00afaf"/><use xlink:href="#g160" y="18938"/><rect x="176" y="18955" width="136" height="17" fill="#008787"/><rect x="312" y="18955" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g161" y="18955"/><rect x="176" y="18972" width="136" height="17" fill="#008787"/><rect x="312" y="18972" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g162" y="18972"/><rect x="176" y="18989" width="136" height="17" fill="#008787"/><rect x="312" y="18989" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g163" y="18989"/><rect x="176" y="19006" width="136" height="17" fill="#008787"/><rect x="312" y="19006" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g164" y="19006"/><rect x="0" y="19023" width="528" height="17" fill="#262626"/><use xlink:href="#g156" y="19023"/></g><g><use xlink:href="#g74" y="19074"/><use xlink:href="#g75" y="19091"/><use xlink:href="#g115" y="19108"/><use xlink:href="#g116" y="19125"/><use xlink:href="#g117" y="19142"/><use xlink:href="#g118" y="19159"/><use xlink:href="#g119" y="19176"/><use xlink:href="#g138" y="19193"/><use xlink:href="#g139" y="19210"/><use xlink:href="#g167" y="19227"/><use xlink:href="#g168" y="19244"/><rect x="128" y="19261" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="19261"/><use xlink:href="#g28" y="19278"/><use xlink:href="#g28" y="19295"/><use xlink:href="#g16" y="19312"/><use xlink:href="#g16" y="19329"/><use xlink:href="#g16" y="19346"/><use xlink:href="#g16" y="19363"/><use xlink:href="#g16" y="19380"/><rect x="0" y="19397" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="19397"/></g><g><use xlink:href="#g74" y="19448"/><use xlink:href="#g75" y="19465"/><use xlink:href="#g115" y="19482"/><use xlink:href="#g116" y="19499"/><use xlink:href="#g117" y="19516"/><use xlink:href="#g118" y="19533"/><use xlink:href="#g119" y="19550"/><use xlink:href="#g138" y="19567"/><use xlink:href="#g139" y="19584"/><use xlink:href="#g167" y="19601"/><use xlink:href="#g168" y="19618"/><rect x="208" y="19635" width="8" height="17" class="foreground"/><use xlink:href="#g165" y="19635"/><use xlink:href="#g28" y="19652"/><use xlink:href="#g28" y="19669"/><use xlink:href="#g16" y="19686"/><use xlink:href="#g16" y="19703"/><use xlink:href="#g16" y="19720"/><use xlink:href="#g16" y="19737"/><use xlink:href="#g16" y="19754"/><rect x="0" y="19771" width="528" height="17" fill="#262626"/><use xlink:href="#g156" y="19771"/></g><g><use xlink:href="#g74" y="19822"/><use xlink:href="#g75" y="19839"/><use xlink:href="#g115" y="19856"/><use xlink:href="#g116" y="19873"/><use xlink:href="#g117" y="19890"/><use xlink:href="#g118" y="19907"/><use xlink:href="#g119" y="19924"/><use xlink:href="#g138" y="19941"/><use xlink:href="#g139" y="19958"/><use xlink:href="#g167" y="19975"/><use xlink:href="#g168" y="19992"/><rect x="216" y="20009" width="8" height="17" class="foreground"/><use xlink:href="#g169" y="20009"/><use xlink:href="#g28" y="20026"/><use xlink:href="#g28" y="20043"/><use xlink:href="#g16" y="20060"/><use xlink:href="#g16" y="20077"/><use xlink:href="#g16" y="20094"/><use xlink:href="#g16" y="20111"/><use xlink:href="#g16" y="20128"/><rect x="0" y="20145" width="528" height="17" fill="#262626"/><use xlink:href="#g156" y="20145"/></g><g><use xlink:href="#g74" y="20196"/><use xlink:href="#g75" y="20213"/><use xlink:href="#g115" y="20230"/><use xlink:href="#g116" y="20247"/><use xlink:href="#g117" y="20264"/><use xlink:href="#g118" y="20281"/><use xlink:href="#g119" y="20298"/><use xlink:href="#g138" y="20315"/><use xlink:href="#g139" y="20332"/><use xlink:href="#g167" y="20349"/><use xlink:href="#g168" y="20366"/><rect x="224" y="20383" width="8" height="17" class="foreground"/><use xlink:href="#g170" y="20383"/><use xlink:href="#g28" y="20400"/><use xlink:href="#g28" y="20417"/><use xlink:href="#g16" y="20434"/><use xlink:href="#g16" y="20451"/><use xlink:href="#g16" y="20468"/><use xlink:href="#g16" y="20485"/><use xlink:href="#g16" y="20502"/><rect x="0" y="20519" width="528" height="17" fill="#262626"/><use xlink:href="#g156" y="20519"/></g><g><use xlink:href="#g116" y="20570"/><use xlink:href="#g117" y="20587"/><use xlink:href="#g118" y="20604"/><use xlink:href="#g119" y="20621"/><use xlink:href="#g138" y="20638"/><use xlink:href="#g139" y="20655"/><use xlink:href="#g167" y="20672"/><use xlink:href="#g168" y="20689"/><use xlink:href="#g171" y="20706"/><use xlink:href="#g172" y="20723"/><use xlink:href="#g173" y="20740"/><rect x="128" y="20757" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="20757"/><use xlink:href="#g16" y="20774"/><use xlink:href="#g16" y="20791"/><use xlink:href="#g16" y="20808"/><use xlink:href="#g16" y="20825"/><use xlink:href="#g16" y="20842"/><use xlink:href="#g16" y="20876"/><rect x="0" y="20893" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="20893"/></g><g><use xlink:href="#g116" y="20944"/><use xlink:href="#g117" y="20961"/><use xlink:href="#g118" y="20978"/><use xlink:href="#g119" y="20995"/><use xlink:href="#g138" y="21012"/><use xlink:href="#g139" y="21029"/><use xlink:href="#g167" y="21046"/><use xlink:href="#g168" y="21063"/><use xlink:href="#g171" y="21080"/><use xlink:href="#g172" y="21097"/><use xlink:href="#g173" y="21114"/><rect x="136" y="21131" width="8" height="17" class="foreground"/><use xlink:href="#g174" y="21131"/><rect x="136" y="21148" width="56" height="17" fill="#008787"/><rect x="192" y="21148" width="8" height="17" fill="#444444"/><use xlink:href="#g120" y="21148"/><rect x="136" y="21165" width="56" height="17" fill="#008787"/><rect x="192" y="21165" width="8" height="17" fill="#444444"/><use xlink:href="#g121" y="21165"/><rect x="136" y="21182" width="56" height="17" fill="#008787"/><rect x="192" y="21182" width="8" height="17" fill="#444444"/><use xlink:href="#g122" y="21182"/><rect x="136" y="21199" width="56" height="17" fill="#008787"/><rect x="192" y="21199" width="8" height="17" fill="#444444"/><use xlink:href="#g175" y="21199"/><use xlink:href="#g16" y="21216"/><use xlink:href="#g16" y="21250"/><rect x="0" y="21267" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="21267"/></g><g><use xlink:href="#g116" y="21318"/><use xlink:href="#g117" y="21335"/><use xlink:href="#g118" y="21352"/><use xlink:href="#g119" y="21369"/><use xlink:href="#g138" y="21386"/><use xlink:href="#g139" y="21403"/><use xlink:href="#g167" y="21420"/><use xlink:href="#g168" y="21437"/><use xlink:href="#g171" y="21454"/><use xlink:href="#g172" y="21471"/><use xlink:href="#g173" y="21488"/><rect x="144" y="21505" width="8" height="17" class="foreground"/><use xlink:href="#g176" y="21505"/><rect x="144" y="21522" width="56" height="17" fill="#008787"/><rect x="200" y="21522" width="8" height="17" fill="#444444"/><use xlink:href="#g123" y="21522"/><use xlink:href="#g16" y="21539"/><use xlink:href="#g16" y="21556"/><use xlink:href="#g16" y="21573"/><use xlink:href="#g16" y="21590"/><use xlink:href="#g16" y="21624"/><rect x="0" y="21641" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="21641"/></g><g><use xlink:href="#g116" y="21692"/><use xlink:href="#g117" y="21709"/><use xlink:href="#g118" y="21726"/><use xlink:href="#g119" y="21743"/><use xlink:href="#g138" y="21760"/><use xlink:href="#g139" y="21777"/><use xlink:href="#g167" y="21794"/><use xlink:href="#g168" y="21811"/><use xlink:href="#g171" y="21828"/><use xlink:href="#g172" y="21845"/><use xlink:href="#g173" y="21862"/><rect x="152" y="21879" width="8" height="17" class="foreground"/><use xlink:href="#g177" y="21879"/><rect x="152" y="21896" width="56" height="17" fill="#008787"/><rect x="208" y="21896" width="8" height="17" fill="#444444"/><use xlink:href="#g124" y="21896"/><use xlink:href="#g16" y="21913"/><use xlink:href="#g16" y="21930"/><use xlink:href="#g16" y="21947"/><use xlink:href="#g16" y="21964"/><use xlink:href="#g16" y="21998"/><rect x="0" y="22015" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="22015"/></g><g><use xlink:href="#g116" y="22066"/><use xlink:href="#g117" y="22083"/><use xlink:href="#g118" y="22100"/><use xlink:href="#g119" y="22117"/><use xlink:href="#g138" y="22134"/><use xlink:href="#g139" y="22151"/><use xlink:href="#g167" y="22168"/><use xlink:href="#g168" y="22185"/><use xlink:href="#g171" y="22202"/><use xlink:href="#g172" y="22219"/><use xlink:href="#g173" y="22236"/><rect x="160" y="22253" width="8" height="17" class="foreground"/><use xlink:href="#g178" y="22253"/><rect x="160" y="22270" width="56" height="17" fill="#008787"/><rect x="216" y="22270" width="8" height="17" fill="#444444"/><use xlink:href="#g125" y="22270"/><use xlink:href="#g16" y="22287"/><use xlink:href="#g16" y="22304"/><use xlink:href="#g16" y="22321"/><use xlink:href="#g16" y="22338"/><use xlink:href="#g16" y="22372"/><rect x="0" y="22389" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="22389"/></g><g><use xlink:href="#g116" y="22440"/><use xlink:href="#g117" y="22457"/><use xlink:href="#g118" y="22474"/><use xlink:href="#g119" y="22491"/><use xlink:href="#g138" y="22508"/><use xlink:href="#g139" y="22525"/><use xlink:href="#g167" y="22542"/><use xlink:href="#g168" y="22559"/><use xlink:href="#g171" y="22576"/><use xlink:href="#g172" y="22593"/><use xlink:href="#g173" y="22610"/><rect x="168" y="22627" width="8" height="17" class="foreground"/><use xlink:href="#g179" y="22627"/><rect x="168" y="22644" width="136" height="17" fill="#008787"/><rect x="304" y="22644" width="8" height="17" fill="#444444"/><use xlink:href="#g180" y="22644"/><rect x="168" y="22661" width="136" height="17" fill="#008787"/><rect x="304" y="22661" width="8" height="17" fill="#444444"/><use xlink:href="#g126" y="22661"/><rect x="168" y="22678" width="136" height="17" fill="#008787"/><rect x="304" y="22678" width="8" height="17" fill="#00afaf"/><use xlink:href="#g127" y="22678"/><rect x="168" y="22695" width="136" height="17" fill="#008787"/><rect x="304" y="22695" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g128" y="22695"/><rect x="168" y="22712" width="136" height="17" fill="#008787"/><rect x="304" y="22712" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g181" y="22712"/><rect x="168" y="22729" width="136" height="17" fill="#008787"/><rect x="304" y="22729" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g129" y="22729"/><rect x="168" y="22746" width="136" height="17" fill="#008787"/><rect x="304" y="22746" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g182" y="22746"/><rect x="0" y="22763" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="22763"/></g><g><use xlink:href="#g116" y="22814"/><use xlink:href="#g117" y="22831"/><use xlink:href="#g118" y="22848"/><use xlink:href="#g119" y="22865"/><use xlink:href="#g138" y="22882"/><use xlink:href="#g139" y="22899"/><use xlink:href="#g167" y="22916"/><use xlink:href="#g168" y="22933"/><use xlink:href="#g171" y="22950"/><use xlink:href="#g172" y="22967"/><use xlink:href="#g173" y="22984"/><rect x="176" y="23001" width="8" height="17" class="foreground"/><use xlink:href="#g183" y="23001"/><rect x="176" y="23018" width="136" height="17" fill="#008787"/><rect x="312" y="23018" width="8" height="17" fill="#444444"/><use xlink:href="#g184" y="23018"/><rect x="176" y="23035" width="136" height="17" fill="#008787"/><rect x="312" y="23035" width="8" height="17" fill="#444444"/><use xlink:href="#g185" y="23035"/><rect x="176" y="23052" width="136" height="17" fill="#008787"/><rect x="312" y="23052" width="8" height="17" fill="#444444"/><use xlink:href="#g186" y="23052"/><rect x="176" y="23069" width="136" height="17" fill="#008787"/><rect x="312" y="23069" width="8" height="17" fill="#444444"/><use xlink:href="#g187" y="23069"/><rect x="176" y="23086" width="136" height="17" fill="#008787"/><rect x="312" y="23086" width="8" height="17" fill="#444444"/><use xlink:href="#g188" y="23086"/><use xlink:href="#g28" y="23103"/><use xlink:href="#g16" y="23120"/><rect x="0" y="23137" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="23137"/></g><g><use xlink:href="#g116" y="23188"/><use xlink:href="#g117" y="23205"/><use xlink:href="#g118" y="23222"/><use xlink:href="#g119" y="23239"/><use xlink:href="#g138" y="23256"/><use xlink:href="#g139" y="23273"/><use xlink:href="#g167" y="23290"/><use xlink:href="#g168" y="23307"/><use xlink:href="#g171" y="23324"/><use xlink:href="#g172" y="23341"/><use xlink:href="#g173" y="23358"/><rect x="184" y="23375" width="8" height="17" class="foreground"/><use xlink:href="#g189" y="23375"/><rect x="184" y="23392" width="136" height="17" fill="#008787"/><rect x="320" y="23392" width="8" height="17" fill="#444444"/><use xlink:href="#g190" y="23392"/><rect x="184" y="23409" width="136" height="17" fill="#008787"/><rect x="320" y="23409" width="8" height="17" fill="#444444"/><use xlink:href="#g191" y="23409"/><rect x="184" y="23426" width="136" height="17" fill="#008787"/><rect x="320" y="23426" width="8" height="17" fill="#444444"/><use xlink:href="#g192" y="23426"/><rect x="184" y="23443" width="136" height="17" fill="#008787"/><rect x="320" y="23443" width="8" height="17" fill="#444444"/><use xlink:href="#g193" y="23443"/><use xlink:href="#g16" y="23460"/><use xlink:href="#g28" y="23477"/><use xlink:href="#g16" y="23494"/><rect x="0" y="23511" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="23511"/></g><g><use xlink:href="#g116" y="23562"/><use xlink:href="#g117" y="23579"/><use xlink:href="#g118" y="23596"/><use xlink:href="#g119" y="23613"/><use xlink:href="#g138" y="23630"/><use xlink:href="#g139" y="23647"/><use xlink:href="#g167" y="23664"/><use xlink:href="#g168" y="23681"/><use xlink:href="#g171" y="23698"/><use xlink:href="#g172" y="23715"/><use xlink:href="#g173" y="23732"/><rect x="264" y="23749" width="8" height="17" class="foreground"/><use xlink:href="#g194" y="23749"/><rect x="184" y="23766" width="136" height="17" fill="#ffffff"/><rect x="320" y="23766" width="8" height="17" fill="#444444"/><use xlink:href="#g195" y="23766"/><rect x="184" y="23783" width="136" height="17" fill="#008787"/><rect x="320" y="23783" width="8" height="17" fill="#444444"/><use xlink:href="#g191" y="23783"/><rect x="184" y="23800" width="136" height="17" fill="#008787"/><rect x="320" y="23800" width="8" height="17" fill="#444444"/><use xlink:href="#g192" y="23800"/><rect x="184" y="23817" width="136" height="17" fill="#008787"/><rect x="320" y="23817" width="8" height="17" fill="#444444"/><use xlink:href="#g193" y="23817"/><use xlink:href="#g16" y="23834"/><use xlink:href="#g28" y="23851"/><use xlink:href="#g16" y="23868"/><rect x="0" y="23885" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="23885"/></g><g><use xlink:href="#g118" y="23936"/><use xlink:href="#g119" y="23953"/><use xlink:href="#g138" y="23970"/><use xlink:href="#g139" y="23987"/><use xlink:href="#g167" y="24004"/><use xlink:href="#g168" y="24021"/><use xlink:href="#g171" y="24038"/><use xlink:href="#g172" y="24055"/><use xlink:href="#g173" y="24072"/><use xlink:href="#g196" y="24089"/><use xlink:href="#g197" y="24106"/><rect x="128" y="24123" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="24123"/><use xlink:href="#g16" y="24140"/><use xlink:href="#g16" y="24157"/><use xlink:href="#g16" y="24174"/><use xlink:href="#g28" y="24191"/><use xlink:href="#g16" y="24208"/><use xlink:href="#g16" y="24225"/><use xlink:href="#g16" y="24242"/><rect x="0" y="24259" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="24259"/></g><g><use xlink:href="#g118" y="24310"/><use xlink:href="#g119" y="24327"/><use xlink:href="#g138" y="24344"/><use xlink:href="#g139" y="24361"/><use xlink:href="#g167" y="24378"/><use xlink:href="#g168" y="24395"/><use xlink:href="#g171" y="24412"/><use xlink:href="#g172" y="24429"/><use xlink:href="#g173" y="24446"/><use xlink:href="#g196" y="24463"/><use xlink:href="#g197" y="24480"/><rect x="136" y="24497" width="8" height="17" class="foreground"/><use xlink:href="#g198" y="24497"/><rect x="136" y="24514" width="80" height="17" fill="#008787"/><rect x="216" y="24514" width="8" height="17" fill="#444444"/><use xlink:href="#g199" y="24514"/><rect x="136" y="24531" width="80" height="17" fill="#008787"/><rect x="216" y="24531" width="8" height="17" fill="#444444"/><use xlink:href="#g200" y="24531"/><rect x="136" y="24548" width="80" height="17" fill="#008787"/><rect x="216" y="24548" width="8" height="17" fill="#444444"/><use xlink:href="#g201" y="24548"/><rect x="136" y="24565" width="80" height="17" fill="#008787"/><rect x="216" y="24565" width="8" height="17" fill="#444444"/><use xlink:href="#g202" y="24565"/><rect x="136" y="24582" width="80" height="17" fill="#008787"/><rect x="216" y="24582" width="8" height="17" fill="#00afaf"/><use xlink:href="#g203" y="24582"/><rect x="136" y="24599" width="80" height="17" fill="#008787"/><rect x="216" y="24599" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g204" y="24599"/><rect x="136" y="24616" width="80" height="17" fill="#008787"/><rect x="216" y="24616" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g205" y="24616"/><rect x="0" y="24633" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="24633"/></g><g><use xlink:href="#g118" y="24684"/><use xlink:href="#g119" y="24701"/><use xlink:href="#g138" y="24718"/><use xlink:href="#g139" y="24735"/><use xlink:href="#g167" y="24752"/><use xlink:href="#g168" y="24769"/><use xlink:href="#g171" y="24786"/><use xlink:href="#g172" y="24803"/><use xlink:href="#g173" y="24820"/><use xlink:href="#g196" y="24837"/><use xlink:href="#g197" y="24854"/><rect x="144" y="24871" width="8" height="17" class="foreground"/><use xlink:href="#g206" y="24871"/><rect x="144" y="24888" width="56" height="17" fill="#008787"/><rect x="200" y="24888" width="8" height="17" fill="#444444"/><use xlink:href="#g207" y="24888"/><use xlink:href="#g16" y="24905"/><use xlink:href="#g16" y="24922"/><use xlink:href="#g28" y="24939"/><use xlink:href="#g16" y="24956"/><use xlink:href="#g16" y="24973"/><use xlink:href="#g16" y="24990"/><rect x="0" y="25007" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="25007"/></g><g><use xlink:href="#g118" y="25058"/><use xlink:href="#g119" y="25075"/><use xlink:href="#g138" y="25092"/><use xlink:href="#g139" y="25109"/><use xlink:href="#g167" y="25126"/><use xlink:href="#g168" y="25143"/><use xlink:href="#g171" y="25160"/><use xlink:href="#g172" y="25177"/><use xlink:href="#g173" y="25194"/><use xlink:href="#g196" y="25211"/><use xlink:href="#g197" y="25228"/><rect x="160" y="25245" width="8" height="17" class="foreground"/><use xlink:href="#g208" y="25245"/><rect x="144" y="25262" width="56" height="17" fill="#ffffff"/><rect x="200" y="25262" width="8" height="17" fill="#444444"/><use xlink:href="#g209" y="25262"/><use xlink:href="#g16" y="25279"/><use xlink:href="#g16" y="25296"/><use xlink:href="#g28" y="25313"/><use xlink:href="#g16" y="25330"/><use xlink:href="#g16" y="25347"/><use xlink:href="#g16" y="25364"/><rect x="0" y="25381" width="528" height="17" fill="#262626"/><use xlink:href="#g210" y="25381"/></g><g><use xlink:href="#g118" y="25432"/><use xlink:href="#g119" y="25449"/><use xlink:href="#g138" y="25466"/><use xlink:href="#g139" y="25483"/><use xlink:href="#g167" y="25500"/><use xlink:href="#g168" y="25517"/><use xlink:href="#g171" y="25534"/><use xlink:href="#g172" y="25551"/><use xlink:href="#g173" y="25568"/><use xlink:href="#g196" y="25585"/><use xlink:href="#g197" y="25602"/><rect x="168" y="25619" width="8" height="17" class="foreground"/><use xlink:href="#g211" y="25619"/><rect x="168" y="25636" width="136" height="17" fill="#008787"/><rect x="304" y="25636" width="8" height="17" fill="#444444"/><use xlink:href="#g212" y="25636"/><rect x="168" y="25653" width="136" height="17" fill="#008787"/><rect x="304" y="25653" width="8" height="17" fill="#444444"/><use xlink:href="#g180" y="25653"/><rect x="168" y="25670" width="136" height="17" fill="#008787"/><rect x="304" y="25670" width="8" height="17" fill="#00afaf"/><use xlink:href="#g126" y="25670"/><rect x="168" y="25687" width="136" height="17" fill="#008787"/><rect x="304" y="25687" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g213" y="25687"/><rect x="168" y="25704" width="136" height="17" fill="#008787"/><rect x="304" y="25704" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g128" y="25704"/><rect x="168" y="25721" width="136" height="17" fill="#008787"/><rect x="304" y="25721" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g181" y="25721"/><rect x="168" y="25738" width="136" height="17" fill="#008787"/><rect x="304" y="25738" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g182" y="25738"/><rect x="0" y="25755" width="528" height="17" fill="#262626"/><use xlink:href="#g210" y="25755"/></g><g><use xlink:href="#g118" y="25806"/><use xlink:href="#g119" y="25823"/><use xlink:href="#g138" y="25840"/><use xlink:href="#g139" y="25857"/><use xlink:href="#g167" y="25874"/><use xlink:href="#g168" y="25891"/><use xlink:href="#g171" y="25908"/><use xlink:href="#g172" y="25925"/><use xlink:href="#g173" y="25942"/><use xlink:href="#g196" y="25959"/><use xlink:href="#g197" y="25976"/><rect x="176" y="25993" width="8" height="17" class="foreground"/><use xlink:href="#g214" y="25993"/><rect x="176" y="26010" width="136" height="17" fill="#008787"/><rect x="312" y="26010" width="8" height="17" fill="#444444"/><use xlink:href="#g215" y="26010"/><rect x="176" y="26027" width="136" height="17" fill="#008787"/><rect x="312" y="26027" width="8" height="17" fill="#444444"/><use xlink:href="#g216" y="26027"/><rect x="176" y="26044" width="136" height="17" fill="#008787"/><rect x="312" y="26044" width="8" height="17" fill="#444444"/><use xlink:href="#g217" y="26044"/><rect x="176" y="26061" width="136" height="17" fill="#008787"/><rect x="312" y="26061" width="8" height="17" fill="#444444"/><use xlink:href="#g218" y="26061"/><rect x="176" y="26078" width="136" height="17" fill="#008787"/><rect x="312" y="26078" width="8" height="17" fill="#444444"/><use xlink:href="#g219" y="26078"/><use xlink:href="#g16" y="26095"/><use xlink:href="#g16" y="26112"/><rect x="0" y="26129" width="528" height="17" fill="#262626"/><use xlink:href="#g210" y="26129"/></g><g><use xlink:href="#g118" y="26180"/><use xlink:href="#g119" y="26197"/><use xlink:href="#g138" y="26214"/><use xlink:href="#g139" y="26231"/><use xlink:href="#g167" y="26248"/><use xlink:href="#g168" y="26265"/><use xlink:href="#g171" y="26282"/><use xlink:href="#g172" y="26299"/><use xlink:href="#g173" y="26316"/><use xlink:href="#g196" y="26333"/><use xlink:href="#g197" y="26350"/><rect x="168" y="26367" width="8" height="17" class="foreground"/><use xlink:href="#g220" y="26367"/><use xlink:href="#g16" y="26384"/><use xlink:href="#g16" y="26401"/><use xlink:href="#g16" y="26418"/><use xlink:href="#g28" y="26435"/><use xlink:href="#g16" y="26452"/><use xlink:href="#g16" y="26469"/><use xlink:href="#g16" y="26486"/><rect x="0" y="26503" width="528" height="17" fill="#262626"/><use xlink:href="#g210" y="26503"/></g><g><use xlink:href="#g118" y="26554"/><use xlink:href="#g119" y="26571"/><use xlink:href="#g138" y="26588"/><use xlink:href="#g139" y="26605"/><use xlink:href="#g167" y="26622"/><use xlink:href="#g168" y="26639"/><use xlink:href="#g171" y="26656"/><use xlink:href="#g172" y="26673"/><use xlink:href="#g173" y="26690"/><use xlink:href="#g196" y="26707"/><use xlink:href="#g197" y="26724"/><rect x="176" y="26741" width="8" height="17" class="foreground"/><use xlink:href="#g221" y="26741"/><rect x="176" y="26758" width="136" height="17" fill="#008787"/><rect x="312" y="26758" width="8" height="17" fill="#444444"/><use xlink:href="#g184" y="26758"/><rect x="176" y="26775" width="136" height="17" fill="#008787"/><rect x="312" y="26775" width="8" height="17" fill="#444444"/><use xlink:href="#g185" y="26775"/><rect x="176" y="26792" width="136" height="17" fill="#008787"/><rect x="312" y="26792" width="8" height="17" fill="#444444"/><use xlink:href="#g186" y="26792"/><rect x="176" y="26809" width="136" height="17" fill="#008787"/><rect x="312" y="26809" width="8" height="17" fill="#444444"/><use xlink:href="#g222" y="26809"/><rect x="176" y="26826" width="136" height="17" fill="#008787"/><rect x="312" y="26826" width="8" height="17" fill="#444444"/><use xlink:href="#g188" y="26826"/><use xlink:href="#g16" y="26843"/><use xlink:href="#g16" y="26860"/><rect x="0" y="26877" width="528" height="17" fill="#262626"/><use xlink:href="#g210" y="26877"/></g><g><use xlink:href="#g118" y="26928"/><use xlink:href="#g119" y="26945"/><use xlink:href="#g138" y="26962"/><use xlink:href="#g139" y="26979"/><use xlink:href="#g167" y="26996"/><use xlink:href="#g168" y="27013"/><use xlink:href="#g171" y="27030"/><use xlink:href="#g172" y="27047"/><use xlink:href="#g173" y="27064"/><use xlink:href="#g196" y="27081"/><use xlink:href="#g197" y="27098"/><rect x="184" y="27115" width="8" height="17" class="foreground"/><use xlink:href="#g223" y="27115"/><rect x="184" y="27132" width="136" height="17" fill="#008787"/><rect x="320" y="27132" width="8" height="17" fill="#444444"/><use xlink:href="#g190" y="27132"/><rect x="184" y="27149" width="136" height="17" fill="#008787"/><rect x="320" y="27149" width="8" height="17" fill="#444444"/><use xlink:href="#g191" y="27149"/><rect x="184" y="27166" width="136" height="17" fill="#008787"/><rect x="320" y="27166" width="8" height="17" fill="#444444"/><use xlink:href="#g192" y="27166"/><rect x="184" y="27183" width="136" height="17" fill="#008787"/><rect x="320" y="27183" width="8" height="17" fill="#444444"/><use xlink:href="#g224" y="27183"/><use xlink:href="#g16" y="27200"/><use xlink:href="#g16" y="27217"/><use xlink:href="#g16" y="27234"/><rect x="0" y="27251" width="528" height="17" fill="#262626"/><use xlink:href="#g210" y="27251"/></g><g><use xlink:href="#g118" y="27302"/><use xlink:href="#g119" y="27319"/><use xlink:href="#g138" y="27336"/><use xlink:href="#g139" y="27353"/><use xlink:href="#g167" y="27370"/><use xlink:href="#g168" y="27387"/><use xlink:href="#g171" y="27404"/><use xlink:href="#g172" y="27421"/><use xlink:href="#g173" y="27438"/><use xlink:href="#g196" y="27455"/><use xlink:href="#g197" y="27472"/><rect x="264" y="27489" width="8" height="17" class="foreground"/><use xlink:href="#g225" y="27489"/><rect x="184" y="27506" width="136" height="17" fill="#ffffff"/><rect x="320" y="27506" width="8" height="17" fill="#444444"/><use xlink:href="#g195" y="27506"/><rect x="184" y="27523" width="136" height="17" fill="#008787"/><rect x="320" y="27523" width="8" height="17" fill="#444444"/><use xlink:href="#g191" y="27523"/><rect x="184" y="27540" width="136" height="17" fill="#008787"/><rect x="320" y="27540" width="8" height="17" fill="#444444"/><use xlink:href="#g192" y="27540"/><rect x="184" y="27557" width="136" height="17" fill="#008787"/><rect x="320" y="27557" width="8" height="17" fill="#444444"/><use xlink:href="#g224" y="27557"/><use xlink:href="#g16" y="27574"/><use xlink:href="#g16" y="27591"/><use xlink:href="#g16" y="27608"/><rect x="0" y="27625" width="528" height="17" fill="#262626"/><use xlink:href="#g210" y="27625"/></g><g><use xlink:href="#g138" y="27676"/><use xlink:href="#g139" y="27693"/><use xlink:href="#g167" y="27710"/><use xlink:href="#g168" y="27727"/><use xlink:href="#g171" y="27744"/><use xlink:href="#g172" y="27761"/><use xlink:href="#g173" y="27778"/><use xlink:href="#g196" y="27795"/><use xlink:href="#g197" y="27812"/><use xlink:href="#g226" y="27829"/><use xlink:href="#g227" y="27846"/><rect x="128" y="27863" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="27863"/><use xlink:href="#g16" y="27880"/><use xlink:href="#g28" y="27897"/><use xlink:href="#g16" y="27914"/><use xlink:href="#g16" y="27931"/><use xlink:href="#g16" y="27948"/><use xlink:href="#g16" y="27965"/><use xlink:href="#g16" y="27982"/><rect x="0" y="27999" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="27999"/></g><g><use xlink:href="#g138" y="28050"/><use xlink:href="#g139" y="28067"/><use xlink:href="#g167" y="28084"/><use xlink:href="#g168" y="28101"/><use xlink:href="#g171" y="28118"/><use xlink:href="#g172" y="28135"/><use xlink:href="#g173" y="28152"/><use xlink:href="#g196" y="28169"/><use xlink:href="#g197" y="28186"/><use xlink:href="#g226" y="28203"/><use xlink:href="#g227" y="28220"/><rect x="136" y="28237" width="8" height="17" class="foreground"/><use xlink:href="#g198" y="28237"/><rect x="136" y="28254" width="80" height="17" fill="#008787"/><rect x="216" y="28254" width="8" height="17" fill="#444444"/><use xlink:href="#g199" y="28254"/><rect x="136" y="28271" width="80" height="17" fill="#008787"/><rect x="216" y="28271" width="8" height="17" fill="#444444"/><use xlink:href="#g228" y="28271"/><rect x="136" y="28288" width="80" height="17" fill="#008787"/><rect x="216" y="28288" width="8" height="17" fill="#444444"/><use xlink:href="#g201" y="28288"/><rect x="136" y="28305" width="80" height="17" fill="#008787"/><rect x="216" y="28305" width="8" height="17" fill="#444444"/><use xlink:href="#g229" y="28305"/><rect x="136" y="28322" width="80" height="17" fill="#008787"/><rect x="216" y="28322" width="8" height="17" fill="#00afaf"/><use xlink:href="#g203" y="28322"/><rect x="136" y="28339" width="80" height="17" fill="#008787"/><rect x="216" y="28339" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g204" y="28339"/><rect x="136" y="28356" width="80" height="17" fill="#008787"/><rect x="216" y="28356" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g205" y="28356"/><rect x="0" y="28373" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="28373"/></g><g><use xlink:href="#g138" y="28424"/><use xlink:href="#g139" y="28441"/><use xlink:href="#g167" y="28458"/><use xlink:href="#g168" y="28475"/><use xlink:href="#g171" y="28492"/><use xlink:href="#g172" y="28509"/><use xlink:href="#g173" y="28526"/><use xlink:href="#g196" y="28543"/><use xlink:href="#g197" y="28560"/><use xlink:href="#g226" y="28577"/><use xlink:href="#g227" y="28594"/><rect x="144" y="28611" width="8" height="17" class="foreground"/><use xlink:href="#g230" y="28611"/><rect x="144" y="28628" width="64" height="17" fill="#008787"/><rect x="208" y="28628" width="8" height="17" fill="#444444"/><use xlink:href="#g231" y="28628"/><rect x="144" y="28645" width="64" height="17" fill="#008787"/><rect x="208" y="28645" width="8" height="17" fill="#444444"/><use xlink:href="#g232" y="28645"/><use xlink:href="#g16" y="28662"/><use xlink:href="#g16" y="28679"/><use xlink:href="#g16" y="28696"/><use xlink:href="#g16" y="28713"/><use xlink:href="#g16" y="28730"/><rect x="0" y="28747" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="28747"/></g><g><use xlink:href="#g138" y="28798"/><use xlink:href="#g139" y="28815"/><use xlink:href="#g167" y="28832"/><use xlink:href="#g168" y="28849"/><use xlink:href="#g171" y="28866"/><use xlink:href="#g172" y="28883"/><use xlink:href="#g173" y="28900"/><use xlink:href="#g196" y="28917"/><use xlink:href="#g197" y="28934"/><use xlink:href="#g226" y="28951"/><use xlink:href="#g227" y="28968"/><rect x="152" y="28985" width="8" height="17" class="foreground"/><use xlink:href="#g233" y="28985"/><rect x="152" y="29002" width="64" height="17" fill="#008787"/><rect x="216" y="29002" width="8" height="17" fill="#444444"/><use xlink:href="#g234" y="29002"/><use xlink:href="#g28" y="29019"/><use xlink:href="#g16" y="29036"/><use xlink:href="#g16" y="29053"/><use xlink:href="#g16" y="29070"/><use xlink:href="#g16" y="29087"/><use xlink:href="#g16" y="29104"/><rect x="0" y="29121" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="29121"/></g><g><use xlink:href="#g138" y="29172"/><use xlink:href="#g139" y="29189"/><use xlink:href="#g167" y="29206"/><use xlink:href="#g168" y="29223"/><use xlink:href="#g171" y="29240"/><use xlink:href="#g172" y="29257"/><use xlink:href="#g173" y="29274"/><use xlink:href="#g196" y="29291"/><use xlink:href="#g197" y="29308"/><use xlink:href="#g226" y="29325"/><use xlink:href="#g227" y="29342"/><rect x="160" y="29359" width="8" height="17" class="foreground"/><use xlink:href="#g235" y="29359"/><rect x="160" y="29376" width="64" height="17" fill="#008787"/><rect x="224" y="29376" width="8" height="17" fill="#444444"/><use xlink:href="#g236" y="29376"/><use xlink:href="#g28" y="29393"/><use xlink:href="#g16" y="29410"/><use xlink:href="#g16" y="29427"/><use xlink:href="#g16" y="29444"/><use xlink:href="#g16" y="29461"/><use xlink:href="#g16" y="29478"/><rect x="0" y="29495" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="29495"/></g><g><use xlink:href="#g138" y="29546"/><use xlink:href="#g139" y="29563"/><use xlink:href="#g167" y="29580"/><use xlink:href="#g168" y="29597"/><use xlink:href="#g171" y="29614"/><use xlink:href="#g172" y="29631"/><use xlink:href="#g173" y="29648"/><use xlink:href="#g196" y="29665"/><use xlink:href="#g197" y="29682"/><use xlink:href="#g226" y="29699"/><use xlink:href="#g227" y="29716"/><rect x="168" y="29733" width="8" height="17" class="foreground"/><use xlink:href="#g237" y="29733"/><rect x="168" y="29750" width="64" height="17" fill="#008787"/><rect x="232" y="29750" width="8" height="17" fill="#444444"/><use xlink:href="#g238" y="29750"/><use xlink:href="#g28" y="29767"/><use xlink:href="#g16" y="29784"/><use xlink:href="#g16" y="29801"/><use xlink:href="#g16" y="29818"/><use xlink:href="#g16" y="29835"/><use xlink:href="#g16" y="29852"/><rect x="0" y="29869" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="29869"/></g><g><use xlink:href="#g138" y="29920"/><use xlink:href="#g139" y="29937"/><use xlink:href="#g167" y="29954"/><use xlink:href="#g168" y="29971"/><use xlink:href="#g171" y="29988"/><use xlink:href="#g172" y="30005"/><use xlink:href="#g173" y="30022"/><use xlink:href="#g196" y="30039"/><use xlink:href="#g197" y="30056"/><use xlink:href="#g226" y="30073"/><use xlink:href="#g227" y="30090"/><rect x="176" y="30107" width="8" height="17" class="foreground"/><use xlink:href="#g239" y="30107"/><rect x="176" y="30124" width="64" height="17" fill="#008787"/><rect x="240" y="30124" width="8" height="17" fill="#444444"/><use xlink:href="#g240" y="30124"/><use xlink:href="#g28" y="30141"/><use xlink:href="#g16" y="30158"/><use xlink:href="#g16" y="30175"/><use xlink:href="#g16" y="30192"/><use xlink:href="#g16" y="30209"/><use xlink:href="#g16" y="30226"/><rect x="0" y="30243" width="528" height="17" fill="#262626"/><use xlink:href="#g241" y="30243"/></g><g><use xlink:href="#g138" y="30294"/><use xlink:href="#g139" y="30311"/><use xlink:href="#g167" y="30328"/><use xlink:href="#g168" y="30345"/><use xlink:href="#g171" y="30362"/><use xlink:href="#g172" y="30379"/><use xlink:href="#g173" y="30396"/><use xlink:href="#g196" y="30413"/><use xlink:href="#g197" y="30430"/><use xlink:href="#g226" y="30447"/><use xlink:href="#g227" y="30464"/><rect x="184" y="30481" width="8" height="17" class="foreground"/><use xlink:href="#g242" y="30481"/><rect x="184" y="30498" width="136" height="17" fill="#008787"/><rect x="320" y="30498" width="8" height="17" fill="#444444"/><use xlink:href="#g243" y="30498"/><rect x="184" y="30515" width="136" height="17" fill="#008787"/><rect x="320" y="30515" width="8" height="17" fill="#444444"/><use xlink:href="#g244" y="30515"/><rect x="184" y="30532" width="136" height="17" fill="#008787"/><rect x="320" y="30532" width="8" height="17" fill="#00afaf"/><use xlink:href="#g245" y="30532"/><rect x="184" y="30549" width="136" height="17" fill="#008787"/><rect x="320" y="30549" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g246" y="30549"/><rect x="184" y="30566" width="136" height="17" fill="#008787"/><rect x="320" y="30566" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g247" y="30566"/><rect x="184" y="30583" width="136" height="17" fill="#008787"/><rect x="320" y="30583" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g248" y="30583"/><rect x="184" y="30600" width="136" height="17" fill="#008787"/><rect x="320" y="30600" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g249" y="30600"/><rect x="0" y="30617" width="528" height="17" fill="#262626"/><use xlink:href="#g241" y="30617"/></g><g><use xlink:href="#g138" y="30668"/><use xlink:href="#g139" y="30685"/><use xlink:href="#g167" y="30702"/><use xlink:href="#g168" y="30719"/><use xlink:href="#g171" y="30736"/><use xlink:href="#g172" y="30753"/><use xlink:href="#g173" y="30770"/><use xlink:href="#g196" y="30787"/><use xlink:href="#g197" y="30804"/><use xlink:href="#g226" y="30821"/><use xlink:href="#g227" y="30838"/><rect x="192" y="30855" width="8" height="17" class="foreground"/><use xlink:href="#g250" y="30855"/><rect x="192" y="30872" width="136" height="17" fill="#008787"/><rect x="328" y="30872" width="8" height="17" fill="#444444"/><use xlink:href="#g251" y="30872"/><rect x="192" y="30889" width="136" height="17" fill="#008787"/><rect x="328" y="30889" width="8" height="17" fill="#444444"/><use xlink:href="#g252" y="30889"/><rect x="192" y="30906" width="136" height="17" fill="#008787"/><rect x="328" y="30906" width="8" height="17" fill="#444444"/><use xlink:href="#g253" y="30906"/><rect x="192" y="30923" width="136" height="17" fill="#008787"/><rect x="328" y="30923" width="8" height="17" fill="#444444"/><use xlink:href="#g254" y="30923"/><rect x="192" y="30940" width="136" height="17" fill="#008787"/><rect x="328" y="30940" width="8" height="17" fill="#444444"/><use xlink:href="#g255" y="30940"/><use xlink:href="#g16" y="30957"/><use xlink:href="#g16" y="30974"/><rect x="0" y="30991" width="528" height="17" fill="#262626"/><use xlink:href="#g241" y="30991"/></g><g><use xlink:href="#g138" y="31042"/><use xlink:href="#g139" y="31059"/><use xlink:href="#g167" y="31076"/><use xlink:href="#g168" y="31093"/><use xlink:href="#g171" y="31110"/><use xlink:href="#g172" y="31127"/><use xlink:href="#g173" y="31144"/><use xlink:href="#g196" y="31161"/><use xlink:href="#g197" y="31178"/><use xlink:href="#g226" y="31195"/><use xlink:href="#g227" y="31212"/><rect x="280" y="31229" width="8" height="17" class="foreground"/><use xlink:href="#g256" y="31229"/><rect x="192" y="31246" width="136" height="17" fill="#ffffff"/><rect x="328" y="31246" width="8" height="17" fill="#444444"/><use xlink:href="#g257" y="31246"/><rect x="192" y="31263" width="136" height="17" fill="#008787"/><rect x="328" y="31263" width="8" height="17" fill="#444444"/><use xlink:href="#g252" y="31263"/><rect x="192" y="31280" width="136" height="17" fill="#008787"/><rect x="328" y="31280" width="8" height="17" fill="#444444"/><use xlink:href="#g253" y="31280"/><rect x="192" y="31297" width="136" height="17" fill="#008787"/><rect x="328" y="31297" width="8" height="17" fill="#444444"/><use xlink:href="#g254" y="31297"/><rect x="192" y="31314" width="136" height="17" fill="#008787"/><rect x="328" y="31314" width="8" height="17" fill="#444444"/><use xlink:href="#g255" y="31314"/><use xlink:href="#g16" y="31331"/><use xlink:href="#g16" y="31348"/><rect x="0" y="31365" width="528" height="17" fill="#262626"/><use xlink:href="#g241" y="31365"/></g><g><use xlink:href="#g138" y="31416"/><use xlink:href="#g139" y="31433"/><use xlink:href="#g167" y="31450"/><use xlink:href="#g168" y="31467"/><use xlink:href="#g171" y="31484"/><use xlink:href="#g172" y="31501"/><use xlink:href="#g173" y="31518"/><use xlink:href="#g196" y="31535"/><use xlink:href="#g197" y="31552"/><use xlink:href="#g226" y="31569"/><use xlink:href="#g227" y="31586"/><rect x="288" y="31603" width="8" height="17" class="foreground"/><use xlink:href="#g258" y="31603"/><use xlink:href="#g16" y="31620"/><use xlink:href="#g28" y="31637"/><use xlink:href="#g16" y="31654"/><use xlink:href="#g16" y="31671"/><use xlink:href="#g16" y="31688"/><use xlink:href="#g16" y="31705"/><use xlink:href="#g16" y="31722"/><rect x="0" y="31739" width="528" height="17" fill="#262626"/><use xlink:href="#g241" y="31739"/></g><g><use xlink:href="#g138" y="31790"/><use xlink:href="#g139" y="31807"/><use xlink:href="#g167" y="31824"/><use xlink:href="#g168" y="31841"/><use xlink:href="#g171" y="31858"/><use xlink:href="#g172" y="31875"/><use xlink:href="#g173" y="31892"/><use xlink:href="#g196" y="31909"/><use xlink:href="#g197" y="31926"/><use xlink:href="#g226" y="31943"/><use xlink:href="#g227" y="31960"/><rect x="296" y="31977" width="8" height="17" class="foreground"/><use xlink:href="#g259" y="31977"/><use xlink:href="#g16" y="31994"/><use xlink:href="#g28" y="32011"/><use xlink:href="#g16" y="32028"/><use xlink:href="#g16" y="32045"/><use xlink:href="#g16" y="32062"/><use xlink:href="#g16" y="32079"/><use xlink:href="#g16" y="32096"/><rect x="0" y="32113" width="528" height="17" fill="#262626"/><use xlink:href="#g241" y="32113"/></g><g><use xlink:href="#g138" y="32164"/><use xlink:href="#g139" y="32181"/><use xlink:href="#g167" y="32198"/><use xlink:href="#g168" y="32215"/><use xlink:href="#g171" y="32232"/><use xlink:href="#g172" y="32249"/><use xlink:href="#g173" y="32266"/><use xlink:href="#g196" y="32283"/><use xlink:href="#g197" y="32300"/><use xlink:href="#g226" y="32317"/><use xlink:href="#g227" y="32334"/><rect x="304" y="32351" width="8" height="17" class="foreground"/><use xlink:href="#g260" y="32351"/><use xlink:href="#g16" y="32368"/><use xlink:href="#g28" y="32385"/><use xlink:href="#g16" y="32402"/><use xlink:href="#g16" y="32419"/><use xlink:href="#g16" y="32436"/><use xlink:href="#g16" y="32453"/><use xlink:href="#g16" y="32470"/><rect x="0" y="32487" width="528" height="17" fill="#262626"/><use xlink:href="#g241" y="32487"/></g><g><use xlink:href="#g138" y="32538"/><use xlink:href="#g139" y="32555"/><use xlink:href="#g167" y="32572"/><use xlink:href="#g168" y="32589"/><use xlink:href="#g171" y="32606"/><use xlink:href="#g172" y="32623"/><use xlink:href="#g173" y="32640"/><use xlink:href="#g196" y="32657"/><use xlink:href="#g197" y="32674"/><use xlink:href="#g226" y="32691"/><use xlink:href="#g227" y="32708"/><rect x="312" y="32725" width="8" height="17" class="foreground"/><use xlink:href="#g261" y="32725"/><use xlink:href="#g16" y="32742"/><use xlink:href="#g28" y="32759"/><use xlink:href="#g16" y="32776"/><use xlink:href="#g16" y="32793"/><use xlink:href="#g16" y="32810"/><use xlink:href="#g16" y="32827"/><use xlink:href="#g16" y="32844"/><rect x="0" y="32861" width="528" height="17" fill="#262626"/><use xlink:href="#g241" y="32861"/></g><g><use xlink:href="#g197" y="32912"/><use xlink:href="#g226" y="32929"/><use xlink:href="#g227" y="32946"/><use xlink:href="#g262" y="32963"/><use xlink:href="#g263" y="32980"/><use xlink:href="#g264" y="32997"/><use xlink:href="#g265" y="33014"/><use xlink:href="#g266" y="33031"/><use xlink:href="#g267" y="33048"/><use xlink:href="#g268" y="33065"/><use xlink:href="#g269" y="33082"/><rect x="128" y="33099" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="33099"/><use xlink:href="#g16" y="33218"/><rect x="0" y="33235" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="33235"/></g><g><use xlink:href="#g197" y="33286"/><use xlink:href="#g226" y="33303"/><use xlink:href="#g227" y="33320"/><use xlink:href="#g262" y="33337"/><use xlink:href="#g263" y="33354"/><use xlink:href="#g264" y="33371"/><use xlink:href="#g265" y="33388"/><use xlink:href="#g266" y="33405"/><use xlink:href="#g267" y="33422"/><use xlink:href="#g268" y="33439"/><use xlink:href="#g269" y="33456"/><rect x="136" y="33473" width="8" height="17" class="foreground"/><use xlink:href="#g270" y="33473"/><rect x="136" y="33490" width="56" height="17" fill="#008787"/><rect x="192" y="33490" width="8" height="17" fill="#444444"/><use xlink:href="#g42" y="33490"/><rect x="136" y="33507" width="56" height="17" fill="#008787"/><rect x="192" y="33507" width="8" height="17" fill="#444444"/><use xlink:href="#g43" y="33507"/><rect x="136" y="33524" width="56" height="17" fill="#008787"/><rect x="192" y="33524" width="8" height="17" fill="#444444"/><use xlink:href="#g44" y="33524"/><rect x="136" y="33541" width="56" height="17" fill="#008787"/><rect x="192" y="33541" width="8" height="17" fill="#444444"/><use xlink:href="#g45" y="33541"/><use xlink:href="#g16" y="33592"/><rect x="0" y="33609" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="33609"/></g><g><use xlink:href="#g197" y="33660"/><use xlink:href="#g226" y="33677"/><use xlink:href="#g227" y="33694"/><use xlink:href="#g262" y="33711"/><use xlink:href="#g263" y="33728"/><use xlink:href="#g264" y="33745"/><use xlink:href="#g265" y="33762"/><use xlink:href="#g266" y="33779"/><use xlink:href="#g267" y="33796"/><use xlink:href="#g268" y="33813"/><use xlink:href="#g269" y="33830"/><rect x="144" y="33847" width="8" height="17" class="foreground"/><use xlink:href="#g271" y="33847"/><rect x="144" y="33864" width="56" height="17" fill="#008787"/><rect x="200" y="33864" width="8" height="17" fill="#444444"/><use xlink:href="#g47" y="33864"/><use xlink:href="#g28" y="33881"/><use xlink:href="#g28" y="33898"/><use xlink:href="#g28" y="33915"/><use xlink:href="#g16" y="33966"/><rect x="0" y="33983" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="33983"/></g><g><use xlink:href="#g197" y="34034"/><use xlink:href="#g226" y="34051"/><use xlink:href="#g227" y="34068"/><use xlink:href="#g262" y="34085"/><use xlink:href="#g263" y="34102"/><use xlink:href="#g264" y="34119"/><use xlink:href="#g265" y="34136"/><use xlink:href="#g266" y="34153"/><use xlink:href="#g267" y="34170"/><use xlink:href="#g268" y="34187"/><use xlink:href="#g269" y="34204"/><rect x="152" y="34221" width="8" height="17" class="foreground"/><use xlink:href="#g272" y="34221"/><rect x="152" y="34238" width="56" height="17" fill="#008787"/><rect x="208" y="34238" width="8" height="17" fill="#444444"/><use xlink:href="#g49" y="34238"/><use xlink:href="#g28" y="34255"/><use xlink:href="#g28" y="34272"/><use xlink:href="#g28" y="34289"/><use xlink:href="#g16" y="34340"/><rect x="0" y="34357" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="34357"/></g><g><use xlink:href="#g197" y="34408"/><use xlink:href="#g226" y="34425"/><use xlink:href="#g227" y="34442"/><use xlink:href="#g262" y="34459"/><use xlink:href="#g263" y="34476"/><use xlink:href="#g264" y="34493"/><use xlink:href="#g265" y="34510"/><use xlink:href="#g266" y="34527"/><use xlink:href="#g267" y="34544"/><use xlink:href="#g268" y="34561"/><use xlink:href="#g269" y="34578"/><rect x="160" y="34595" width="8" height="17" class="foreground"/><use xlink:href="#g273" y="34595"/><rect x="160" y="34612" width="56" height="17" fill="#008787"/><rect x="216" y="34612" width="8" height="17" fill="#444444"/><use xlink:href="#g51" y="34612"/><use xlink:href="#g28" y="34629"/><use xlink:href="#g28" y="34646"/><use xlink:href="#g28" y="34663"/><use xlink:href="#g16" y="34714"/><rect x="0" y="34731" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="34731"/></g><g><use xlink:href="#g197" y="34782"/><use xlink:href="#g226" y="34799"/><use xlink:href="#g227" y="34816"/><use xlink:href="#g262" y="34833"/><use xlink:href="#g263" y="34850"/><use xlink:href="#g264" y="34867"/><use xlink:href="#g265" y="34884"/><use xlink:href="#g266" y="34901"/><use xlink:href="#g267" y="34918"/><use xlink:href="#g268" y="34935"/><use xlink:href="#g269" y="34952"/><rect x="168" y="34969" width="8" height="17" class="foreground"/><use xlink:href="#g274" y="34969"/><rect x="168" y="34986" width="136" height="17" fill="#008787"/><rect x="304" y="34986" width="8" height="17" fill="#444444"/><use xlink:href="#g275" y="34986"/><rect x="168" y="35003" width="136" height="17" fill="#008787"/><rect x="304" y="35003" width="8" height="17" fill="#444444"/><use xlink:href="#g276" y="35003"/><rect x="168" y="35020" width="136" height="17" fill="#008787"/><rect x="304" y="35020" width="8" height="17" fill="#00afaf"/><use xlink:href="#g277" y="35020"/><rect x="168" y="35037" width="136" height="17" fill="#008787"/><rect x="304" y="35037" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g213" y="35037"/><rect x="168" y="35054" width="136" height="17" fill="#008787"/><rect x="304" y="35054" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g278" y="35054"/><rect x="168" y="35071" width="136" height="17" fill="#008787"/><rect x="304" y="35071" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g279" y="35071"/><rect x="168" y="35088" width="136" height="17" fill="#008787"/><rect x="304" y="35088" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g182" y="35088"/><rect x="0" y="35105" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="35105"/></g><g><use xlink:href="#g197" y="35156"/><use xlink:href="#g226" y="35173"/><use xlink:href="#g227" y="35190"/><use xlink:href="#g262" y="35207"/><use xlink:href="#g263" y="35224"/><use xlink:href="#g264" y="35241"/><use xlink:href="#g265" y="35258"/><use xlink:href="#g266" y="35275"/><use xlink:href="#g267" y="35292"/><use xlink:href="#g268" y="35309"/><use xlink:href="#g269" y="35326"/><rect x="264" y="35343" width="8" height="17" class="foreground"/><use xlink:href="#g194" y="35343"/><rect x="168" y="35360" width="136" height="17" fill="#ffffff"/><rect x="304" y="35360" width="8" height="17" fill="#444444"/><use xlink:href="#g280" y="35360"/><rect x="168" y="35377" width="136" height="17" fill="#008787"/><rect x="304" y="35377" width="8" height="17" fill="#444444"/><use xlink:href="#g276" y="35377"/><rect x="168" y="35394" width="136" height="17" fill="#008787"/><rect x="304" y="35394" width="8" height="17" fill="#00afaf"/><use xlink:href="#g277" y="35394"/><rect x="168" y="35411" width="136" height="17" fill="#008787"/><rect x="304" y="35411" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g213" y="35411"/><rect x="168" y="35428" width="136" height="17" fill="#008787"/><rect x="304" y="35428" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g278" y="35428"/><rect x="168" y="35445" width="136" height="17" fill="#008787"/><rect x="304" y="35445" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g279" y="35445"/><rect x="168" y="35462" width="136" height="17" fill="#008787"/><rect x="304" y="35462" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g182" y="35462"/><rect x="0" y="35479" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="35479"/></g><g><use xlink:href="#g197" y="35530"/><use xlink:href="#g226" y="35547"/><use xlink:href="#g227" y="35564"/><use xlink:href="#g262" y="35581"/><use xlink:href="#g263" y="35598"/><use xlink:href="#g264" y="35615"/><use xlink:href="#g265" y="35632"/><use xlink:href="#g266" y="35649"/><use xlink:href="#g267" y="35666"/><use xlink:href="#g268" y="35683"/><use xlink:href="#g269" y="35700"/><rect x="200" y="35717" width="8" height="17" class="foreground"/><use xlink:href="#g136" y="35717"/><rect x="168" y="35734" width="136" height="17" fill="#008787"/><rect x="304" y="35734" width="8" height="17" fill="#444444"/><use xlink:href="#g275" y="35734"/><rect x="168" y="35751" width="136" height="17" fill="#ffffff"/><rect x="304" y="35751" width="8" height="17" fill="#444444"/><use xlink:href="#g281" y="35751"/><rect x="168" y="35768" width="136" height="17" fill="#008787"/><rect x="304" y="35768" width="8" height="17" fill="#00afaf"/><use xlink:href="#g277" y="35768"/><rect x="168" y="35785" width="136" height="17" fill="#008787"/><rect x="304" y="35785" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g213" y="35785"/><rect x="168" y="35802" width="136" height="17" fill="#008787"/><rect x="304" y="35802" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g278" y="35802"/><rect x="168" y="35819" width="136" height="17" fill="#008787"/><rect x="304" y="35819" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g279" y="35819"/><rect x="168" y="35836" width="136" height="17" fill="#008787"/><rect x="304" y="35836" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g182" y="35836"/><rect x="0" y="35853" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="35853"/></g><g><use xlink:href="#g197" y="35904"/><use xlink:href="#g226" y="35921"/><use xlink:href="#g227" y="35938"/><use xlink:href="#g262" y="35955"/><use xlink:href="#g263" y="35972"/><use xlink:href="#g264" y="35989"/><use xlink:href="#g265" y="36006"/><use xlink:href="#g266" y="36023"/><use xlink:href="#g267" y="36040"/><use xlink:href="#g268" y="36057"/><use xlink:href="#g269" y="36074"/><rect x="208" y="36091" width="8" height="17" class="foreground"/><use xlink:href="#g72" y="36091"/><rect x="168" y="36108" width="136" height="17" fill="#008787"/><rect x="304" y="36108" width="8" height="17" fill="#444444"/><use xlink:href="#g275" y="36108"/><rect x="168" y="36125" width="136" height="17" fill="#008787"/><rect x="304" y="36125" width="8" height="17" fill="#444444"/><use xlink:href="#g276" y="36125"/><rect x="168" y="36142" width="136" height="17" fill="#ffffff"/><rect x="304" y="36142" width="8" height="17" fill="#00afaf"/><use xlink:href="#g282" y="36142"/><rect x="168" y="36159" width="136" height="17" fill="#008787"/><rect x="304" y="36159" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g213" y="36159"/><rect x="168" y="36176" width="136" height="17" fill="#008787"/><rect x="304" y="36176" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g278" y="36176"/><rect x="168" y="36193" width="136" height="17" fill="#008787"/><rect x="304" y="36193" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g279" y="36193"/><rect x="168" y="36210" width="136" height="17" fill="#008787"/><rect x="304" y="36210" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g182" y="36210"/><rect x="0" y="36227" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="36227"/></g><g><use xlink:href="#g197" y="36278"/><use xlink:href="#g226" y="36295"/><use xlink:href="#g227" y="36312"/><use xlink:href="#g262" y="36329"/><use xlink:href="#g263" y="36346"/><use xlink:href="#g264" y="36363"/><use xlink:href="#g265" y="36380"/><use xlink:href="#g266" y="36397"/><use xlink:href="#g267" y="36414"/><use xlink:href="#g268" y="36431"/><use xlink:href="#g269" y="36448"/><rect x="192" y="36465" width="8" height="17" class="foreground"/><use xlink:href="#g283" y="36465"/><rect x="168" y="36482" width="136" height="17" fill="#008787"/><rect x="304" y="36482" width="8" height="17" fill="#444444"/><use xlink:href="#g275" y="36482"/><rect x="168" y="36499" width="136" height="17" fill="#008787"/><rect x="304" y="36499" width="8" height="17" fill="#444444"/><use xlink:href="#g276" y="36499"/><rect x="168" y="36516" width="136" height="17" fill="#008787"/><rect x="304" y="36516" width="8" height="17" fill="#00afaf"/><use xlink:href="#g277" y="36516"/><rect x="168" y="36533" width="136" height="17" fill="#ffffff"/><rect x="304" y="36533" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g284" y="36533"/><rect x="168" y="36550" width="136" height="17" fill="#008787"/><rect x="304" y="36550" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g278" y="36550"/><rect x="168" y="36567" width="136" height="17" fill="#008787"/><rect x="304" y="36567" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g279" y="36567"/><rect x="168" y="36584" width="136" height="17" fill="#008787"/><rect x="304" y="36584" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g182" y="36584"/><rect x="0" y="36601" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="36601"/></g><g><use xlink:href="#g197" y="36652"/><use xlink:href="#g226" y="36669"/><use xlink:href="#g227" y="36686"/><use xlink:href="#g262" y="36703"/><use xlink:href="#g263" y="36720"/><use xlink:href="#g264" y="36737"/><use xlink:href="#g265" y="36754"/><use xlink:href="#g266" y="36771"/><use xlink:href="#g267" y="36788"/><use xlink:href="#g268" y="36805"/><use xlink:href="#g269" y="36822"/><rect x="248" y="36839" width="8" height="17" class="foreground"/><use xlink:href="#g285" y="36839"/><rect x="168" y="36856" width="136" height="17" fill="#008787"/><rect x="304" y="36856" width="8" height="17" fill="#444444"/><use xlink:href="#g275" y="36856"/><rect x="168" y="36873" width="136" height="17" fill="#008787"/><rect x="304" y="36873" width="8" height="17" fill="#444444"/><use xlink:href="#g276" y="36873"/><rect x="168" y="36890" width="136" height="17" fill="#008787"/><rect x="304" y="36890" width="8" height="17" fill="#00afaf"/><use xlink:href="#g277" y="36890"/><rect x="168" y="36907" width="136" height="17" fill="#008787"/><rect x="304" y="36907" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g213" y="36907"/><rect x="168" y="36924" width="136" height="17" fill="#ffffff"/><rect x="304" y="36924" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g286" y="36924"/><rect x="168" y="36941" width="136" height="17" fill="#008787"/><rect x="304" y="36941" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g279" y="36941"/><rect x="168" y="36958" width="136" height="17" fill="#008787"/><rect x="304" y="36958" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g182" y="36958"/><rect x="0" y="36975" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="36975"/></g><g><use xlink:href="#g197" y="37026"/><use xlink:href="#g226" y="37043"/><use xlink:href="#g227" y="37060"/><use xlink:href="#g262" y="37077"/><use xlink:href="#g263" y="37094"/><use xlink:href="#g264" y="37111"/><use xlink:href="#g265" y="37128"/><use xlink:href="#g266" y="37145"/><use xlink:href="#g267" y="37162"/><use xlink:href="#g268" y="37179"/><use xlink:href="#g269" y="37196"/><rect x="184" y="37213" width="8" height="17" class="foreground"/><use xlink:href="#g287" y="37213"/><rect x="168" y="37230" width="136" height="17" fill="#008787"/><rect x="304" y="37230" width="8" height="17" fill="#444444"/><use xlink:href="#g275" y="37230"/><rect x="168" y="37247" width="136" height="17" fill="#008787"/><rect x="304" y="37247" width="8" height="17" fill="#444444"/><use xlink:href="#g276" y="37247"/><rect x="168" y="37264" width="136" height="17" fill="#008787"/><rect x="304" y="37264" width="8" height="17" fill="#00afaf"/><use xlink:href="#g277" y="37264"/><rect x="168" y="37281" width="136" height="17" fill="#008787"/><rect x="304" y="37281" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g213" y="37281"/><rect x="168" y="37298" width="136" height="17" fill="#008787"/><rect x="304" y="37298" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g278" y="37298"/><rect x="168" y="37315" width="136" height="17" fill="#ffffff"/><rect x="304" y="37315" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g288" y="37315"/><rect x="168" y="37332" width="136" height="17" fill="#008787"/><rect x="304" y="37332" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g182" y="37332"/><rect x="0" y="37349" width="528" height="17" fill="#262626"/><use xlink:href="#g52" y="37349"/></g><g><use xlink:href="#g227" y="37400"/><use xlink:href="#g262" y="37417"/><use xlink:href="#g263" y="37434"/><use xlink:href="#g264" y="37451"/><use xlink:href="#g265" y="37468"/><use xlink:href="#g266" y="37485"/><use xlink:href="#g267" y="37502"/><use xlink:href="#g268" y="37519"/><use xlink:href="#g269" y="37536"/><use xlink:href="#g289" y="37553"/><use xlink:href="#g290" y="37570"/><rect x="128" y="37587" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="37587"/><use xlink:href="#g28" y="37604"/><use xlink:href="#g28" y="37621"/><use xlink:href="#g291" y="37638"/><use xlink:href="#g291" y="37655"/><use xlink:href="#g16" y="37672"/><use xlink:href="#g16" y="37689"/><use xlink:href="#g16" y="37706"/><rect x="0" y="37723" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="37723"/></g><g><use xlink:href="#g227" y="37774"/><use xlink:href="#g262" y="37791"/><use xlink:href="#g263" y="37808"/><use xlink:href="#g264" y="37825"/><use xlink:href="#g265" y="37842"/><use xlink:href="#g266" y="37859"/><use xlink:href="#g267" y="37876"/><use xlink:href="#g268" y="37893"/><use xlink:href="#g269" y="37910"/><use xlink:href="#g289" y="37927"/><use xlink:href="#g290" y="37944"/><rect x="136" y="37961" width="8" height="17" class="foreground"/><use xlink:href="#g292" y="37961"/><rect x="136" y="37978" width="152" height="17" fill="#008787"/><rect x="288" y="37978" width="8" height="17" fill="#444444"/><use xlink:href="#g293" y="37978"/><rect x="136" y="37995" width="152" height="17" fill="#008787"/><rect x="288" y="37995" width="8" height="17" fill="#444444"/><use xlink:href="#g294" y="37995"/><rect x="136" y="38012" width="152" height="17" fill="#008787"/><rect x="288" y="38012" width="8" height="17" fill="#444444"/><use xlink:href="#g295" y="38012"/><rect x="136" y="38029" width="152" height="17" fill="#008787"/><rect x="288" y="38029" width="8" height="17" fill="#444444"/><use xlink:href="#g296" y="38029"/><rect x="136" y="38046" width="152" height="17" fill="#008787"/><rect x="288" y="38046" width="8" height="17" fill="#00afaf"/><use xlink:href="#g297" y="38046"/><rect x="136" y="38063" width="152" height="17" fill="#008787"/><rect x="288" y="38063" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g298" y="38063"/><rect x="136" y="38080" width="152" height="17" fill="#008787"/><rect x="288" y="38080" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g299" y="38080"/><rect x="0" y="38097" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="38097"/></g><g><use xlink:href="#g227" y="38148"/><use xlink:href="#g262" y="38165"/><use xlink:href="#g263" y="38182"/><use xlink:href="#g264" y="38199"/><use xlink:href="#g265" y="38216"/><use xlink:href="#g266" y="38233"/><use xlink:href="#g267" y="38250"/><use xlink:href="#g268" y="38267"/><use xlink:href="#g269" y="38284"/><use xlink:href="#g289" y="38301"/><use xlink:href="#g290" y="38318"/><rect x="144" y="38335" width="8" height="17" class="foreground"/><use xlink:href="#g300" y="38335"/><rect x="144" y="38352" width="152" height="17" fill="#008787"/><rect x="296" y="38352" width="8" height="17" fill="#444444"/><use xlink:href="#g301" y="38352"/><rect x="144" y="38369" width="152" height="17" fill="#008787"/><rect x="296" y="38369" width="8" height="17" fill="#444444"/><use xlink:href="#g302" y="38369"/><rect x="144" y="38386" width="152" height="17" fill="#008787"/><rect x="296" y="38386" width="8" height="17" fill="#444444"/><use xlink:href="#g303" y="38386"/><rect x="144" y="38403" width="152" height="17" fill="#008787"/><rect x="296" y="38403" width="8" height="17" fill="#444444"/><use xlink:href="#g304" y="38403"/><rect x="144" y="38420" width="152" height="17" fill="#008787"/><rect x="296" y="38420" width="8" height="17" fill="#00afaf"/><use xlink:href="#g305" y="38420"/><rect x="144" y="38437" width="152" height="17" fill="#008787"/><rect x="296" y="38437" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g306" y="38437"/><rect x="144" y="38454" width="152" height="17" fill="#008787"/><rect x="296" y="38454" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g307" y="38454"/><rect x="0" y="38471" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="38471"/></g><g><use xlink:href="#g227" y="38522"/><use xlink:href="#g262" y="38539"/><use xlink:href="#g263" y="38556"/><use xlink:href="#g264" y="38573"/><use xlink:href="#g265" y="38590"/><use xlink:href="#g266" y="38607"/><use xlink:href="#g267" y="38624"/><use xlink:href="#g268" y="38641"/><use xlink:href="#g269" y="38658"/><use xlink:href="#g289" y="38675"/><use xlink:href="#g290" y="38692"/><rect x="152" y="38709" width="8" height="17" class="foreground"/><use xlink:href="#g308" y="38709"/><rect x="152" y="38726" width="80" height="17" fill="#008787"/><rect x="232" y="38726" width="8" height="17" fill="#444444"/><use xlink:href="#g309" y="38726"/><rect x="152" y="38743" width="80" height="17" fill="#008787"/><rect x="232" y="38743" width="8" height="17" fill="#444444"/><use xlink:href="#g310" y="38743"/><rect x="152" y="38760" width="80" height="17" fill="#008787"/><rect x="232" y="38760" width="8" height="17" fill="#444444"/><use xlink:href="#g311" y="38760"/><rect x="152" y="38777" width="80" height="17" fill="#008787"/><rect x="232" y="38777" width="8" height="17" fill="#444444"/><use xlink:href="#g312" y="38777"/><use xlink:href="#g16" y="38794"/><use xlink:href="#g16" y="38811"/><use xlink:href="#g16" y="38828"/><rect x="0" y="38845" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="38845"/></g><g><use xlink:href="#g227" y="38896"/><use xlink:href="#g262" y="38913"/><use xlink:href="#g263" y="38930"/><use xlink:href="#g264" y="38947"/><use xlink:href="#g265" y="38964"/><use xlink:href="#g266" y="38981"/><use xlink:href="#g267" y="38998"/><use xlink:href="#g268" y="39015"/><use xlink:href="#g269" y="39032"/><use xlink:href="#g289" y="39049"/><use xlink:href="#g290" y="39066"/><rect x="160" y="39083" width="8" height="17" class="foreground"/><use xlink:href="#g314" y="39083"/><rect x="160" y="39100" width="136" height="17" fill="#008787"/><rect x="296" y="39100" width="8" height="17" fill="#444444"/><use xlink:href="#g315" y="39100"/><rect x="160" y="39117" width="136" height="17" fill="#008787"/><rect x="296" y="39117" width="8" height="17" fill="#444444"/><use xlink:href="#g316" y="39117"/><rect x="160" y="39134" width="136" height="17" fill="#008787"/><rect x="296" y="39134" width="8" height="17" fill="#00afaf"/><use xlink:href="#g317" y="39134"/><rect x="160" y="39151" width="136" height="17" fill="#008787"/><rect x="296" y="39151" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g318" y="39151"/><rect x="160" y="39168" width="136" height="17" fill="#008787"/><rect x="296" y="39168" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g319" y="39168"/><rect x="160" y="39185" width="136" height="17" fill="#008787"/><rect x="296" y="39185" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g320" y="39185"/><rect x="160" y="39202" width="136" height="17" fill="#008787"/><rect x="296" y="39202" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g321" y="39202"/><rect x="0" y="39219" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="39219"/></g><g><use xlink:href="#g227" y="39270"/><use xlink:href="#g262" y="39287"/><use xlink:href="#g263" y="39304"/><use xlink:href="#g264" y="39321"/><use xlink:href="#g265" y="39338"/><use xlink:href="#g266" y="39355"/><use xlink:href="#g267" y="39372"/><use xlink:href="#g268" y="39389"/><use xlink:href="#g269" y="39406"/><use xlink:href="#g289" y="39423"/><use xlink:href="#g290" y="39440"/><rect x="168" y="39457" width="8" height="17" class="foreground"/><use xlink:href="#g322" y="39457"/><rect x="168" y="39474" width="136" height="17" fill="#008787"/><rect x="304" y="39474" width="8" height="17" fill="#444444"/><use xlink:href="#g323" y="39474"/><rect x="168" y="39491" width="136" height="17" fill="#008787"/><rect x="304" y="39491" width="8" height="17" fill="#444444"/><use xlink:href="#g324" y="39491"/><rect x="168" y="39508" width="136" height="17" fill="#008787"/><rect x="304" y="39508" width="8" height="17" fill="#444444"/><use xlink:href="#g325" y="39508"/><rect x="168" y="39525" width="136" height="17" fill="#008787"/><rect x="304" y="39525" width="8" height="17" fill="#444444"/><use xlink:href="#g326" y="39525"/><rect x="168" y="39542" width="136" height="17" fill="#008787"/><rect x="304" y="39542" width="8" height="17" fill="#00afaf"/><use xlink:href="#g327" y="39542"/><rect x="168" y="39559" width="136" height="17" fill="#008787"/><rect x="304" y="39559" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g328" y="39559"/><rect x="168" y="39576" width="136" height="17" fill="#008787"/><rect x="304" y="39576" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g329" y="39576"/><rect x="0" y="39593" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="39593"/></g><g><use xlink:href="#g227" y="39644"/><use xlink:href="#g262" y="39661"/><use xlink:href="#g263" y="39678"/><use xlink:href="#g264" y="39695"/><use xlink:href="#g265" y="39712"/><use xlink:href="#g266" y="39729"/><use xlink:href="#g267" y="39746"/><use xlink:href="#g268" y="39763"/><use xlink:href="#g269" y="39780"/><use xlink:href="#g289" y="39797"/><use xlink:href="#g290" y="39814"/><rect x="176" y="39831" width="8" height="17" class="foreground"/><use xlink:href="#g330" y="39831"/><use xlink:href="#g28" y="39848"/><use xlink:href="#g28" y="39865"/><use xlink:href="#g28" y="39882"/><use xlink:href="#g28" y="39899"/><use xlink:href="#g16" y="39916"/><use xlink:href="#g16" y="39933"/><use xlink:href="#g16" y="39950"/><rect x="0" y="39967" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="39967"/></g><g><use xlink:href="#g263" y="40018"/><use xlink:href="#g264" y="40035"/><use xlink:href="#g265" y="40052"/><use xlink:href="#g266" y="40069"/><use xlink:href="#g267" y="40086"/><use xlink:href="#g268" y="40103"/><use xlink:href="#g269" y="40120"/><use xlink:href="#g289" y="40137"/><use xlink:href="#g290" y="40154"/><use xlink:href="#g331" y="40171"/><use xlink:href="#g332" y="40188"/><rect x="128" y="40205" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="40205"/><use xlink:href="#g28" y="40222"/><use xlink:href="#g28" y="40239"/><use xlink:href="#g16" y="40256"/><use xlink:href="#g16" y="40273"/><use xlink:href="#g16" y="40290"/><use xlink:href="#g16" y="40307"/><use xlink:href="#g16" y="40324"/><rect x="0" y="40341" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="40341"/></g><g><use xlink:href="#g263" y="40392"/><use xlink:href="#g264" y="40409"/><use xlink:href="#g265" y="40426"/><use xlink:href="#g266" y="40443"/><use xlink:href="#g267" y="40460"/><use xlink:href="#g268" y="40477"/><use xlink:href="#g269" y="40494"/><use xlink:href="#g289" y="40511"/><use xlink:href="#g290" y="40528"/><use xlink:href="#g331" y="40545"/><use xlink:href="#g332" y="40562"/><rect x="136" y="40579" width="8" height="17" class="foreground"/><use xlink:href="#g333" y="40579"/><rect x="136" y="40596" width="152" height="17" fill="#008787"/><rect x="288" y="40596" width="8" height="17" fill="#444444"/><use xlink:href="#g293" y="40596"/><rect x="136" y="40613" width="152" height="17" fill="#008787"/><rect x="288" y="40613" width="8" height="17" fill="#444444"/><use xlink:href="#g294" y="40613"/><rect x="136" y="40630" width="152" height="17" fill="#008787"/><rect x="288" y="40630" width="8" height="17" fill="#444444"/><use xlink:href="#g334" y="40630"/><rect x="136" y="40647" width="152" height="17" fill="#008787"/><rect x="288" y="40647" width="8" height="17" fill="#444444"/><use xlink:href="#g335" y="40647"/><rect x="136" y="40664" width="152" height="17" fill="#008787"/><rect x="288" y="40664" width="8" height="17" fill="#00afaf"/><use xlink:href="#g297" y="40664"/><rect x="136" y="40681" width="152" height="17" fill="#008787"/><rect x="288" y="40681" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g298" y="40681"/><rect x="136" y="40698" width="152" height="17" fill="#008787"/><rect x="288" y="40698" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g299" y="40698"/><rect x="0" y="40715" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="40715"/></g><g><use xlink:href="#g263" y="40766"/><use xlink:href="#g264" y="40783"/><use xlink:href="#g265" y="40800"/><use xlink:href="#g266" y="40817"/><use xlink:href="#g267" y="40834"/><use xlink:href="#g268" y="40851"/><use xlink:href="#g269" y="40868"/><use xlink:href="#g289" y="40885"/><use xlink:href="#g290" y="40902"/><use xlink:href="#g331" y="40919"/><use xlink:href="#g332" y="40936"/><rect x="144" y="40953" width="8" height="17" class="foreground"/><use xlink:href="#g336" y="40953"/><rect x="144" y="40970" width="152" height="17" fill="#008787"/><rect x="296" y="40970" width="8" height="17" fill="#444444"/><use xlink:href="#g301" y="40970"/><rect x="144" y="40987" width="152" height="17" fill="#008787"/><rect x="296" y="40987" width="8" height="17" fill="#444444"/><use xlink:href="#g302" y="40987"/><rect x="144" y="41004" width="152" height="17" fill="#008787"/><rect x="296" y="41004" width="8" height="17" fill="#444444"/><use xlink:href="#g337" y="41004"/><rect x="144" y="41021" width="152" height="17" fill="#008787"/><rect x="296" y="41021" width="8" height="17" fill="#444444"/><use xlink:href="#g338" y="41021"/><rect x="144" y="41038" width="152" height="17" fill="#008787"/><rect x="296" y="41038" width="8" height="17" fill="#00afaf"/><use xlink:href="#g305" y="41038"/><rect x="144" y="41055" width="152" height="17" fill="#008787"/><rect x="296" y="41055" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g306" y="41055"/><rect x="144" y="41072" width="152" height="17" fill="#008787"/><rect x="296" y="41072" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g307" y="41072"/><rect x="0" y="41089" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="41089"/></g><g><use xlink:href="#g263" y="41140"/><use xlink:href="#g264" y="41157"/><use xlink:href="#g265" y="41174"/><use xlink:href="#g266" y="41191"/><use xlink:href="#g267" y="41208"/><use xlink:href="#g268" y="41225"/><use xlink:href="#g269" y="41242"/><use xlink:href="#g289" y="41259"/><use xlink:href="#g290" y="41276"/><use xlink:href="#g331" y="41293"/><use xlink:href="#g332" y="41310"/><rect x="152" y="41327" width="8" height="17" class="foreground"/><use xlink:href="#g339" y="41327"/><rect x="152" y="41344" width="80" height="17" fill="#008787"/><rect x="232" y="41344" width="8" height="17" fill="#444444"/><use xlink:href="#g309" y="41344"/><rect x="152" y="41361" width="80" height="17" fill="#008787"/><rect x="232" y="41361" width="8" height="17" fill="#444444"/><use xlink:href="#g310" y="41361"/><rect x="152" y="41378" width="80" height="17" fill="#008787"/><rect x="232" y="41378" width="8" height="17" fill="#444444"/><use xlink:href="#g340" y="41378"/><rect x="152" y="41395" width="80" height="17" fill="#008787"/><rect x="232" y="41395" width="8" height="17" fill="#444444"/><use xlink:href="#g341" y="41395"/><use xlink:href="#g16" y="41412"/><use xlink:href="#g16" y="41429"/><use xlink:href="#g16" y="41446"/><rect x="0" y="41463" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="41463"/></g><g><use xlink:href="#g263" y="41514"/><use xlink:href="#g264" y="41531"/><use xlink:href="#g265" y="41548"/><use xlink:href="#g266" y="41565"/><use xlink:href="#g267" y="41582"/><use xlink:href="#g268" y="41599"/><use xlink:href="#g269" y="41616"/><use xlink:href="#g289" y="41633"/><use xlink:href="#g290" y="41650"/><use xlink:href="#g331" y="41667"/><use xlink:href="#g332" y="41684"/><rect x="160" y="41701" width="8" height="17" class="foreground"/><use xlink:href="#g342" y="41701"/><rect x="160" y="41718" width="136" height="17" fill="#008787"/><rect x="296" y="41718" width="8" height="17" fill="#444444"/><use xlink:href="#g315" y="41718"/><rect x="160" y="41735" width="136" height="17" fill="#008787"/><rect x="296" y="41735" width="8" height="17" fill="#444444"/><use xlink:href="#g316" y="41735"/><rect x="160" y="41752" width="136" height="17" fill="#008787"/><rect x="296" y="41752" width="8" height="17" fill="#00afaf"/><use xlink:href="#g343" y="41752"/><rect x="160" y="41769" width="136" height="17" fill="#008787"/><rect x="296" y="41769" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g344" y="41769"/><rect x="160" y="41786" width="136" height="17" fill="#008787"/><rect x="296" y="41786" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g319" y="41786"/><rect x="160" y="41803" width="136" height="17" fill="#008787"/><rect x="296" y="41803" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g320" y="41803"/><rect x="160" y="41820" width="136" height="17" fill="#008787"/><rect x="296" y="41820" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g321" y="41820"/><rect x="0" y="41837" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="41837"/></g><g><use xlink:href="#g263" y="41888"/><use xlink:href="#g264" y="41905"/><use xlink:href="#g265" y="41922"/><use xlink:href="#g266" y="41939"/><use xlink:href="#g267" y="41956"/><use xlink:href="#g268" y="41973"/><use xlink:href="#g269" y="41990"/><use xlink:href="#g289" y="42007"/><use xlink:href="#g290" y="42024"/><use xlink:href="#g331" y="42041"/><use xlink:href="#g332" y="42058"/><rect x="168" y="42075" width="8" height="17" class="foreground"/><use xlink:href="#g345" y="42075"/><rect x="168" y="42092" width="136" height="17" fill="#008787"/><rect x="304" y="42092" width="8" height="17" fill="#444444"/><use xlink:href="#g323" y="42092"/><rect x="168" y="42109" width="136" height="17" fill="#008787"/><rect x="304" y="42109" width="8" height="17" fill="#444444"/><use xlink:href="#g324" y="42109"/><rect x="168" y="42126" width="136" height="17" fill="#008787"/><rect x="304" y="42126" width="8" height="17" fill="#444444"/><use xlink:href="#g346" y="42126"/><rect x="168" y="42143" width="136" height="17" fill="#008787"/><rect x="304" y="42143" width="8" height="17" fill="#444444"/><use xlink:href="#g347" y="42143"/><rect x="168" y="42160" width="136" height="17" fill="#008787"/><rect x="304" y="42160" width="8" height="17" fill="#00afaf"/><use xlink:href="#g327" y="42160"/><rect x="168" y="42177" width="136" height="17" fill="#008787"/><rect x="304" y="42177" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g328" y="42177"/><rect x="168" y="42194" width="136" height="17" fill="#008787"/><rect x="304" y="42194" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g329" y="42194"/><rect x="0" y="42211" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="42211"/></g><g><use xlink:href="#g263" y="42262"/><use xlink:href="#g264" y="42279"/><use xlink:href="#g265" y="42296"/><use xlink:href="#g266" y="42313"/><use xlink:href="#g267" y="42330"/><use xlink:href="#g268" y="42347"/><use xlink:href="#g269" y="42364"/><use xlink:href="#g289" y="42381"/><use xlink:href="#g290" y="42398"/><use xlink:href="#g331" y="42415"/><use xlink:href="#g332" y="42432"/><rect x="176" y="42449" width="8" height="17" class="foreground"/><use xlink:href="#g330" y="42449"/><use xlink:href="#g28" y="42466"/><use xlink:href="#g28" y="42483"/><use xlink:href="#g16" y="42500"/><use xlink:href="#g16" y="42517"/><use xlink:href="#g16" y="42534"/><use xlink:href="#g16" y="42551"/><use xlink:href="#g16" y="42568"/><rect x="0" y="42585" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="42585"/></g><g><use xlink:href="#g263" y="42636"/><use xlink:href="#g264" y="42653"/><use xlink:href="#g265" y="42670"/><use xlink:href="#g266" y="42687"/><use xlink:href="#g267" y="42704"/><use xlink:href="#g268" y="42721"/><use xlink:href="#g269" y="42738"/><use xlink:href="#g289" y="42755"/><use xlink:href="#g290" y="42772"/><use xlink:href="#g331" y="42789"/><use xlink:href="#g332" y="42806"/><rect x="184" y="42823" width="8" height="17" class="foreground"/><use xlink:href="#g348" y="42823"/><use xlink:href="#g28" y="42840"/><use xlink:href="#g28" y="42857"/><use xlink:href="#g16" y="42874"/><use xlink:href="#g16" y="42891"/><use xlink:href="#g16" y="42908"/><use xlink:href="#g16" y="42925"/><use xlink:href="#g16" y="42942"/><rect x="0" y="42959" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="42959"/></g><g><use xlink:href="#g263" y="43010"/><use xlink:href="#g264" y="43027"/><use xlink:href="#g265" y="43044"/><use xlink:href="#g266" y="43061"/><use xlink:href="#g267" y="43078"/><use xlink:href="#g268" y="43095"/><use xlink:href="#g269" y="43112"/><use xlink:href="#g289" y="43129"/><use xlink:href="#g290" y="43146"/><use xlink:href="#g331" y="43163"/><use xlink:href="#g332" y="43180"/><rect x="184" y="43197" width="8" height="17" fill="#ff0000"/><rect x="192" y="43197" width="8" height="17" class="foreground"/><use xlink:href="#g349" y="43197"/><use xlink:href="#g28" y="43214"/><use xlink:href="#g28" y="43231"/><use xlink:href="#g16" y="43248"/><use xlink:href="#g16" y="43265"/><use xlink:href="#g16" y="43282"/><use xlink:href="#g16" y="43299"/><use xlink:href="#g16" y="43316"/><rect x="0" y="43333" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="43333"/></g><g><use xlink:href="#g263" y="43384"/><use xlink:href="#g264" y="43401"/><use xlink:href="#g265" y="43418"/><use xlink:href="#g266" y="43435"/><use xlink:href="#g267" y="43452"/><use xlink:href="#g268" y="43469"/><use xlink:href="#g269" y="43486"/><use xlink:href="#g289" y="43503"/><use xlink:href="#g290" y="43520"/><use xlink:href="#g331" y="43537"/><use xlink:href="#g332" y="43554"/><rect x="184" y="43571" width="16" height="17" fill="#ff0000"/><rect x="200" y="43571" width="8" height="17" class="foreground"/><use xlink:href="#g350" y="43571"/><use xlink:href="#g28" y="43588"/><use xlink:href="#g28" y="43605"/><use xlink:href="#g16" y="43622"/><use xlink:href="#g16" y="43639"/><use xlink:href="#g16" y="43656"/><use xlink:href="#g16" y="43673"/><use xlink:href="#g16" y="43690"/><rect x="0" y="43707" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="43707"/></g><g><use xlink:href="#g263" y="43758"/><use xlink:href="#g264" y="43775"/><use xlink:href="#g265" y="43792"/><use xlink:href="#g266" y="43809"/><use xlink:href="#g267" y="43826"/><use xlink:href="#g268" y="43843"/><use xlink:href="#g269" y="43860"/><use xlink:href="#g289" y="43877"/><use xlink:href="#g290" y="43894"/><use xlink:href="#g331" y="43911"/><use xlink:href="#g332" y="43928"/><rect x="184" y="43945" width="24" height="17" fill="#ff0000"/><rect x="208" y="43945" width="8" height="17" class="foreground"/><use xlink:href="#g351" y="43945"/><use xlink:href="#g28" y="43962"/><use xlink:href="#g28" y="43979"/><use xlink:href="#g16" y="43996"/><use xlink:href="#g16" y="44013"/><use xlink:href="#g16" y="44030"/><use xlink:href="#g16" y="44047"/><use xlink:href="#g16" y="44064"/><rect x="0" y="44081" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="44081"/></g><g><use xlink:href="#g263" y="44132"/><use xlink:href="#g264" y="44149"/><use xlink:href="#g265" y="44166"/><use xlink:href="#g266" y="44183"/><use xlink:href="#g267" y="44200"/><use xlink:href="#g268" y="44217"/><use xlink:href="#g269" y="44234"/><use xlink:href="#g289" y="44251"/><use xlink:href="#g290" y="44268"/><use xlink:href="#g331" y="44285"/><use xlink:href="#g332" y="44302"/><rect x="184" y="44319" width="32" height="17" fill="#ff0000"/><rect x="216" y="44319" width="8" height="17" class="foreground"/><use xlink:href="#g352" y="44319"/><use xlink:href="#g28" y="44336"/><use xlink:href="#g28" y="44353"/><use xlink:href="#g16" y="44370"/><use xlink:href="#g16" y="44387"/><use xlink:href="#g16" y="44404"/><use xlink:href="#g16" y="44421"/><use xlink:href="#g16" y="44438"/><rect x="0" y="44455" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="44455"/></g><g><use xlink:href="#g263" y="44506"/><use xlink:href="#g264" y="44523"/><use xlink:href="#g265" y="44540"/><use xlink:href="#g266" y="44557"/><use xlink:href="#g267" y="44574"/><use xlink:href="#g268" y="44591"/><use xlink:href="#g269" y="44608"/><use xlink:href="#g289" y="44625"/><use xlink:href="#g290" y="44642"/><use xlink:href="#g331" y="44659"/><use xlink:href="#g332" y="44676"/><rect x="184" y="44693" width="40" height="17" fill="#ff0000"/><rect x="224" y="44693" width="8" height="17" class="foreground"/><use xlink:href="#g353" y="44693"/><use xlink:href="#g28" y="44710"/><use xlink:href="#g28" y="44727"/><use xlink:href="#g16" y="44744"/><use xlink:href="#g16" y="44761"/><use xlink:href="#g16" y="44778"/><use xlink:href="#g16" y="44795"/><use xlink:href="#g16" y="44812"/><rect x="0" y="44829" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="44829"/></g><g><use xlink:href="#g263" y="44880"/><use xlink:href="#g264" y="44897"/><use xlink:href="#g265" y="44914"/><use xlink:href="#g266" y="44931"/><use xlink:href="#g267" y="44948"/><use xlink:href="#g268" y="44965"/><use xlink:href="#g269" y="44982"/><use xlink:href="#g289" y="44999"/><use xlink:href="#g290" y="45016"/><use xlink:href="#g331" y="45033"/><use xlink:href="#g332" y="45050"/><rect x="184" y="45067" width="48" height="17" fill="#ff0000"/><rect x="232" y="45067" width="8" height="17" class="foreground"/><use xlink:href="#g354" y="45067"/><use xlink:href="#g28" y="45084"/><use xlink:href="#g28" y="45101"/><use xlink:href="#g16" y="45118"/><use xlink:href="#g16" y="45135"/><use xlink:href="#g16" y="45152"/><use xlink:href="#g16" y="45169"/><use xlink:href="#g16" y="45186"/><rect x="0" y="45203" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="45203"/></g><g><use xlink:href="#g263" y="45254"/><use xlink:href="#g264" y="45271"/><use xlink:href="#g265" y="45288"/><use xlink:href="#g266" y="45305"/><use xlink:href="#g267" y="45322"/><use xlink:href="#g268" y="45339"/><use xlink:href="#g269" y="45356"/><use xlink:href="#g289" y="45373"/><use xlink:href="#g290" y="45390"/><use xlink:href="#g331" y="45407"/><use xlink:href="#g332" y="45424"/><rect x="184" y="45441" width="56" height="17" fill="#ff0000"/><rect x="240" y="45441" width="8" height="17" class="foreground"/><use xlink:href="#g355" y="45441"/><use xlink:href="#g28" y="45458"/><use xlink:href="#g28" y="45475"/><use xlink:href="#g16" y="45492"/><use xlink:href="#g16" y="45509"/><use xlink:href="#g16" y="45526"/><use xlink:href="#g16" y="45543"/><use xlink:href="#g16" y="45560"/><rect x="0" y="45577" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="45577"/></g><g><use xlink:href="#g263" y="45628"/><use xlink:href="#g264" y="45645"/><use xlink:href="#g265" y="45662"/><use xlink:href="#g266" y="45679"/><use xlink:href="#g267" y="45696"/><use xlink:href="#g268" y="45713"/><use xlink:href="#g269" y="45730"/><use xlink:href="#g289" y="45747"/><use xlink:href="#g290" y="45764"/><use xlink:href="#g331" y="45781"/><use xlink:href="#g332" y="45798"/><rect x="184" y="45815" width="64" height="17" fill="#ff0000"/><rect x="248" y="45815" width="8" height="17" class="foreground"/><use xlink:href="#g356" y="45815"/><use xlink:href="#g28" y="45832"/><use xlink:href="#g28" y="45849"/><use xlink:href="#g16" y="45866"/><use xlink:href="#g16" y="45883"/><use xlink:href="#g16" y="45900"/><use xlink:href="#g16" y="45917"/><use xlink:href="#g16" y="45934"/><rect x="0" y="45951" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="45951"/></g><g><use xlink:href="#g263" y="46002"/><use xlink:href="#g264" y="46019"/><use xlink:href="#g265" y="46036"/><use xlink:href="#g266" y="46053"/><use xlink:href="#g267" y="46070"/><use xlink:href="#g268" y="46087"/><use xlink:href="#g269" y="46104"/><use xlink:href="#g289" y="46121"/><use xlink:href="#g290" y="46138"/><use xlink:href="#g331" y="46155"/><use xlink:href="#g332" y="46172"/><rect x="184" y="46189" width="72" height="17" fill="#ff0000"/><rect x="256" y="46189" width="8" height="17" class="foreground"/><use xlink:href="#g357" y="46189"/><use xlink:href="#g28" y="46206"/><use xlink:href="#g28" y="46223"/><use xlink:href="#g16" y="46240"/><use xlink:href="#g16" y="46257"/><use xlink:href="#g16" y="46274"/><use xlink:href="#g16" y="46291"/><use xlink:href="#g16" y="46308"/><rect x="0" y="46325" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="46325"/></g><g><use xlink:href="#g263" y="46376"/><use xlink:href="#g264" y="46393"/><use xlink:href="#g265" y="46410"/><use xlink:href="#g266" y="46427"/><use xlink:href="#g267" y="46444"/><use xlink:href="#g268" y="46461"/><use xlink:href="#g269" y="46478"/><use xlink:href="#g289" y="46495"/><use xlink:href="#g290" y="46512"/><use xlink:href="#g331" y="46529"/><use xlink:href="#g332" y="46546"/><rect x="184" y="46563" width="80" height="17" fill="#ff0000"/><rect x="264" y="46563" width="8" height="17" class="foreground"/><use xlink:href="#g358" y="46563"/><use xlink:href="#g28" y="46580"/><use xlink:href="#g28" y="46597"/><use xlink:href="#g16" y="46614"/><use xlink:href="#g16" y="46631"/><use xlink:href="#g16" y="46648"/><use xlink:href="#g16" y="46665"/><use xlink:href="#g16" y="46682"/><rect x="0" y="46699" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="46699"/></g><g><use xlink:href="#g263" y="46750"/><use xlink:href="#g264" y="46767"/><use xlink:href="#g265" y="46784"/><use xlink:href="#g266" y="46801"/><use xlink:href="#g267" y="46818"/><use xlink:href="#g268" y="46835"/><use xlink:href="#g269" y="46852"/><use xlink:href="#g289" y="46869"/><use xlink:href="#g290" y="46886"/><use xlink:href="#g331" y="46903"/><use xlink:href="#g332" y="46920"/><rect x="184" y="46937" width="88" height="17" fill="#ff0000"/><rect x="272" y="46937" width="8" height="17" class="foreground"/><use xlink:href="#g359" y="46937"/><use xlink:href="#g28" y="46954"/><use xlink:href="#g28" y="46971"/><use xlink:href="#g16" y="46988"/><use xlink:href="#g16" y="47005"/><use xlink:href="#g16" y="47022"/><use xlink:href="#g16" y="47039"/><use xlink:href="#g16" y="47056"/><rect x="0" y="47073" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="47073"/></g><g><use xlink:href="#g263" y="47124"/><use xlink:href="#g264" y="47141"/><use xlink:href="#g265" y="47158"/><use xlink:href="#g266" y="47175"/><use xlink:href="#g267" y="47192"/><use xlink:href="#g268" y="47209"/><use xlink:href="#g269" y="47226"/><use xlink:href="#g289" y="47243"/><use xlink:href="#g290" y="47260"/><use xlink:href="#g331" y="47277"/><use xlink:href="#g332" y="47294"/><rect x="184" y="47311" width="96" height="17" fill="#ff0000"/><rect x="280" y="47311" width="8" height="17" class="foreground"/><use xlink:href="#g360" y="47311"/><use xlink:href="#g28" y="47328"/><use xlink:href="#g28" y="47345"/><use xlink:href="#g16" y="47362"/><use xlink:href="#g16" y="47379"/><use xlink:href="#g16" y="47396"/><use xlink:href="#g16" y="47413"/><use xlink:href="#g16" y="47430"/><rect x="0" y="47447" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="47447"/></g><g><use xlink:href="#g263" y="47498"/><use xlink:href="#g264" y="47515"/><use xlink:href="#g265" y="47532"/><use xlink:href="#g266" y="47549"/><use xlink:href="#g267" y="47566"/><use xlink:href="#g268" y="47583"/><use xlink:href="#g269" y="47600"/><use xlink:href="#g289" y="47617"/><use xlink:href="#g290" y="47634"/><use xlink:href="#g331" y="47651"/><use xlink:href="#g332" y="47668"/><rect x="184" y="47685" width="104" height="17" fill="#ff0000"/><rect x="288" y="47685" width="8" height="17" class="foreground"/><use xlink:href="#g361" y="47685"/><use xlink:href="#g28" y="47702"/><use xlink:href="#g28" y="47719"/><use xlink:href="#g16" y="47736"/><use xlink:href="#g16" y="47753"/><use xlink:href="#g16" y="47770"/><use xlink:href="#g16" y="47787"/><use xlink:href="#g16" y="47804"/><rect x="0" y="47821" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="47821"/></g><g><use xlink:href="#g263" y="47872"/><use xlink:href="#g264" y="47889"/><use xlink:href="#g265" y="47906"/><use xlink:href="#g266" y="47923"/><use xlink:href="#g267" y="47940"/><use xlink:href="#g268" y="47957"/><use xlink:href="#g269" y="47974"/><use xlink:href="#g289" y="47991"/><use xlink:href="#g290" y="48008"/><use xlink:href="#g331" y="48025"/><use xlink:href="#g332" y="48042"/><rect x="184" y="48059" width="112" height="17" fill="#ff0000"/><rect x="296" y="48059" width="8" height="17" class="foreground"/><use xlink:href="#g362" y="48059"/><use xlink:href="#g28" y="48076"/><use xlink:href="#g28" y="48093"/><use xlink:href="#g16" y="48110"/><use xlink:href="#g16" y="48127"/><use xlink:href="#g16" y="48144"/><use xlink:href="#g16" y="48161"/><use xlink:href="#g16" y="48178"/><rect x="0" y="48195" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="48195"/></g><g><use xlink:href="#g263" y="48246"/><use xlink:href="#g264" y="48263"/><use xlink:href="#g265" y="48280"/><use xlink:href="#g266" y="48297"/><use xlink:href="#g267" y="48314"/><use xlink:href="#g268" y="48331"/><use xlink:href="#g269" y="48348"/><use xlink:href="#g289" y="48365"/><use xlink:href="#g290" y="48382"/><use xlink:href="#g331" y="48399"/><use xlink:href="#g332" y="48416"/><rect x="184" y="48433" width="104" height="17" fill="#ff0000"/><rect x="288" y="48433" width="8" height="17" class="foreground"/><use xlink:href="#g361" y="48433"/><use xlink:href="#g28" y="48450"/><use xlink:href="#g28" y="48467"/><use xlink:href="#g16" y="48484"/><use xlink:href="#g16" y="48501"/><use xlink:href="#g16" y="48518"/><use xlink:href="#g16" y="48535"/><use xlink:href="#g16" y="48552"/><rect x="0" y="48569" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="48569"/></g><g><use xlink:href="#g263" y="48620"/><use xlink:href="#g264" y="48637"/><use xlink:href="#g265" y="48654"/><use xlink:href="#g266" y="48671"/><use xlink:href="#g267" y="48688"/><use xlink:href="#g268" y="48705"/><use xlink:href="#g269" y="48722"/><use xlink:href="#g289" y="48739"/><use xlink:href="#g290" y="48756"/><use xlink:href="#g331" y="48773"/><use xlink:href="#g332" y="48790"/><rect x="184" y="48807" width="88" height="17" fill="#ff0000"/><rect x="272" y="48807" width="8" height="17" class="foreground"/><use xlink:href="#g359" y="48807"/><use xlink:href="#g28" y="48824"/><use xlink:href="#g28" y="48841"/><use xlink:href="#g16" y="48858"/><use xlink:href="#g16" y="48875"/><use xlink:href="#g16" y="48892"/><use xlink:href="#g16" y="48909"/><use xlink:href="#g16" y="48926"/><rect x="0" y="48943" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="48943"/></g><g><use xlink:href="#g263" y="48994"/><use xlink:href="#g264" y="49011"/><use xlink:href="#g265" y="49028"/><use xlink:href="#g266" y="49045"/><use xlink:href="#g267" y="49062"/><use xlink:href="#g268" y="49079"/><use xlink:href="#g269" y="49096"/><use xlink:href="#g289" y="49113"/><use xlink:href="#g290" y="49130"/><use xlink:href="#g331" y="49147"/><use xlink:href="#g332" y="49164"/><rect x="184" y="49181" width="80" height="17" fill="#ff0000"/><rect x="264" y="49181" width="8" height="17" class="foreground"/><use xlink:href="#g358" y="49181"/><use xlink:href="#g28" y="49198"/><use xlink:href="#g28" y="49215"/><use xlink:href="#g16" y="49232"/><use xlink:href="#g16" y="49249"/><use xlink:href="#g16" y="49266"/><use xlink:href="#g16" y="49283"/><use xlink:href="#g16" y="49300"/><rect x="0" y="49317" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="49317"/></g><g><use xlink:href="#g263" y="49368"/><use xlink:href="#g264" y="49385"/><use xlink:href="#g265" y="49402"/><use xlink:href="#g266" y="49419"/><use xlink:href="#g267" y="49436"/><use xlink:href="#g268" y="49453"/><use xlink:href="#g269" y="49470"/><use xlink:href="#g289" y="49487"/><use xlink:href="#g290" y="49504"/><use xlink:href="#g331" y="49521"/><use xlink:href="#g332" y="49538"/><rect x="184" y="49555" width="64" height="17" fill="#ff0000"/><rect x="248" y="49555" width="8" height="17" class="foreground"/><use xlink:href="#g356" y="49555"/><use xlink:href="#g28" y="49572"/><use xlink:href="#g28" y="49589"/><use xlink:href="#g16" y="49606"/><use xlink:href="#g16" y="49623"/><use xlink:href="#g16" y="49640"/><use xlink:href="#g16" y="49657"/><use xlink:href="#g16" y="49674"/><rect x="0" y="49691" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="49691"/></g><g><use xlink:href="#g263" y="49742"/><use xlink:href="#g264" y="49759"/><use xlink:href="#g265" y="49776"/><use xlink:href="#g266" y="49793"/><use xlink:href="#g267" y="49810"/><use xlink:href="#g268" y="49827"/><use xlink:href="#g269" y="49844"/><use xlink:href="#g289" y="49861"/><use xlink:href="#g290" y="49878"/><use xlink:href="#g331" y="49895"/><use xlink:href="#g332" y="49912"/><rect x="184" y="49929" width="48" height="17" fill="#ff0000"/><rect x="232" y="49929" width="8" height="17" class="foreground"/><use xlink:href="#g354" y="49929"/><use xlink:href="#g28" y="49946"/><use xlink:href="#g28" y="49963"/><use xlink:href="#g16" y="49980"/><use xlink:href="#g16" y="49997"/><use xlink:href="#g16" y="50014"/><use xlink:href="#g16" y="50031"/><use xlink:href="#g16" y="50048"/><rect x="0" y="50065" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="50065"/></g><g><use xlink:href="#g263" y="50116"/><use xlink:href="#g264" y="50133"/><use xlink:href="#g265" y="50150"/><use xlink:href="#g266" y="50167"/><use xlink:href="#g267" y="50184"/><use xlink:href="#g268" y="50201"/><use xlink:href="#g269" y="50218"/><use xlink:href="#g289" y="50235"/><use xlink:href="#g290" y="50252"/><use xlink:href="#g331" y="50269"/><use xlink:href="#g332" y="50286"/><rect x="184" y="50303" width="40" height="17" fill="#ff0000"/><rect x="224" y="50303" width="8" height="17" class="foreground"/><use xlink:href="#g353" y="50303"/><use xlink:href="#g28" y="50320"/><use xlink:href="#g28" y="50337"/><use xlink:href="#g16" y="50354"/><use xlink:href="#g16" y="50371"/><use xlink:href="#g16" y="50388"/><use xlink:href="#g16" y="50405"/><use xlink:href="#g16" y="50422"/><rect x="0" y="50439" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="50439"/></g><g><use xlink:href="#g263" y="50490"/><use xlink:href="#g264" y="50507"/><use xlink:href="#g265" y="50524"/><use xlink:href="#g266" y="50541"/><use xlink:href="#g267" y="50558"/><use xlink:href="#g268" y="50575"/><use xlink:href="#g269" y="50592"/><use xlink:href="#g289" y="50609"/><use xlink:href="#g290" y="50626"/><use xlink:href="#g331" y="50643"/><use xlink:href="#g332" y="50660"/><rect x="184" y="50677" width="24" height="17" fill="#ff0000"/><rect x="208" y="50677" width="8" height="17" class="foreground"/><use xlink:href="#g351" y="50677"/><use xlink:href="#g28" y="50694"/><use xlink:href="#g28" y="50711"/><use xlink:href="#g16" y="50728"/><use xlink:href="#g16" y="50745"/><use xlink:href="#g16" y="50762"/><use xlink:href="#g16" y="50779"/><use xlink:href="#g16" y="50796"/><rect x="0" y="50813" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="50813"/></g><g><use xlink:href="#g263" y="50864"/><use xlink:href="#g264" y="50881"/><use xlink:href="#g265" y="50898"/><use xlink:href="#g266" y="50915"/><use xlink:href="#g267" y="50932"/><use xlink:href="#g268" y="50949"/><use xlink:href="#g269" y="50966"/><use xlink:href="#g289" y="50983"/><use xlink:href="#g290" y="51000"/><use xlink:href="#g331" y="51017"/><use xlink:href="#g332" y="51034"/><rect x="184" y="51051" width="16" height="17" fill="#ff0000"/><rect x="200" y="51051" width="8" height="17" class="foreground"/><use xlink:href="#g350" y="51051"/><use xlink:href="#g28" y="51068"/><use xlink:href="#g28" y="51085"/><use xlink:href="#g16" y="51102"/><use xlink:href="#g16" y="51119"/><use xlink:href="#g16" y="51136"/><use xlink:href="#g16" y="51153"/><use xlink:href="#g16" y="51170"/><rect x="0" y="51187" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="51187"/></g><g><use xlink:href="#g263" y="51238"/><use xlink:href="#g264" y="51255"/><use xlink:href="#g265" y="51272"/><use xlink:href="#g266" y="51289"/><use xlink:href="#g267" y="51306"/><use xlink:href="#g268" y="51323"/><use xlink:href="#g269" y="51340"/><use xlink:href="#g289" y="51357"/><use xlink:href="#g290" y="51374"/><use xlink:href="#g331" y="51391"/><use xlink:href="#g332" y="51408"/><rect x="184" y="51425" width="8" height="17" fill="#ff0000"/><rect x="192" y="51425" width="8" height="17" class="foreground"/><use xlink:href="#g349" y="51425"/><use xlink:href="#g28" y="51442"/><use xlink:href="#g28" y="51459"/><use xlink:href="#g16" y="51476"/><use xlink:href="#g16" y="51493"/><use xlink:href="#g16" y="51510"/><use xlink:href="#g16" y="51527"/><use xlink:href="#g16" y="51544"/><rect x="0" y="51561" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="51561"/></g><g><use xlink:href="#g263" y="51612"/><use xlink:href="#g264" y="51629"/><use xlink:href="#g265" y="51646"/><use xlink:href="#g266" y="51663"/><use xlink:href="#g267" y="51680"/><use xlink:href="#g268" y="51697"/><use xlink:href="#g269" y="51714"/><use xlink:href="#g289" y="51731"/><use xlink:href="#g290" y="51748"/><use xlink:href="#g331" y="51765"/><use xlink:href="#g332" y="51782"/><rect x="184" y="51799" width="8" height="17" class="foreground"/><use xlink:href="#g348" y="51799"/><use xlink:href="#g28" y="51816"/><use xlink:href="#g28" y="51833"/><use xlink:href="#g16" y="51850"/><use xlink:href="#g16" y="51867"/><use xlink:href="#g16" y="51884"/><use xlink:href="#g16" y="51901"/><use xlink:href="#g16" y="51918"/><rect x="0" y="51935" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="51935"/></g><g><use xlink:href="#g263" y="51986"/><use xlink:href="#g264" y="52003"/><use xlink:href="#g265" y="52020"/><use xlink:href="#g266" y="52037"/><use xlink:href="#g267" y="52054"/><use xlink:href="#g268" y="52071"/><use xlink:href="#g269" y="52088"/><use xlink:href="#g289" y="52105"/><use xlink:href="#g290" y="52122"/><use xlink:href="#g331" y="52139"/><use xlink:href="#g332" y="52156"/><rect x="168" y="52173" width="8" height="17" class="foreground"/><use xlink:href="#g322" y="52173"/><use xlink:href="#g28" y="52190"/><use xlink:href="#g28" y="52207"/><use xlink:href="#g16" y="52224"/><use xlink:href="#g16" y="52241"/><use xlink:href="#g16" y="52258"/><use xlink:href="#g16" y="52275"/><use xlink:href="#g16" y="52292"/><rect x="0" y="52309" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="52309"/></g><g><use xlink:href="#g263" y="52360"/><use xlink:href="#g264" y="52377"/><use xlink:href="#g265" y="52394"/><use xlink:href="#g266" y="52411"/><use xlink:href="#g267" y="52428"/><use xlink:href="#g268" y="52445"/><use xlink:href="#g269" y="52462"/><use xlink:href="#g289" y="52479"/><use xlink:href="#g290" y="52496"/><use xlink:href="#g331" y="52513"/><use xlink:href="#g332" y="52530"/><rect x="160" y="52547" width="8" height="17" class="foreground"/><use xlink:href="#g363" y="52547"/><use xlink:href="#g28" y="52564"/><use xlink:href="#g28" y="52581"/><use xlink:href="#g16" y="52598"/><use xlink:href="#g16" y="52615"/><use xlink:href="#g16" y="52632"/><use xlink:href="#g16" y="52649"/><use xlink:href="#g16" y="52666"/><rect x="0" y="52683" width="528" height="17" fill="#262626"/><use xlink:href="#g313" y="52683"/></g><g><use xlink:href="#g263" y="52734"/><use xlink:href="#g264" y="52751"/><use xlink:href="#g265" y="52768"/><use xlink:href="#g266" y="52785"/><use xlink:href="#g267" y="52802"/><use xlink:href="#g268" y="52819"/><use xlink:href="#g269" y="52836"/><use xlink:href="#g289" y="52853"/><use xlink:href="#g290" y="52870"/><use xlink:href="#g331" y="52887"/><use xlink:href="#g332" y="52904"/><rect x="144" y="52921" width="8" height="17" class="foreground"/><use xlink:href="#g364" y="52921"/><use xlink:href="#g28" y="52938"/><use xlink:href="#g28" y="52955"/><use xlink:href="#g16" y="52972"/><use xlink:href="#g16" y="52989"/><use xlink:href="#g16" y="53006"/><use xlink:href="#g16" y="53023"/><use xlink:href="#g16" y="53040"/><rect x="0" y="53057" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="53057"/></g><g><use xlink:href="#g263" y="53108"/><use xlink:href="#g264" y="53125"/><use xlink:href="#g265" y="53142"/><use xlink:href="#g266" y="53159"/><use xlink:href="#g267" y="53176"/><use xlink:href="#g268" y="53193"/><use xlink:href="#g269" y="53210"/><use xlink:href="#g289" y="53227"/><use xlink:href="#g290" y="53244"/><use xlink:href="#g331" y="53261"/><use xlink:href="#g332" y="53278"/><rect x="136" y="53295" width="8" height="17" class="foreground"/><use xlink:href="#g365" y="53295"/><use xlink:href="#g28" y="53312"/><use xlink:href="#g28" y="53329"/><use xlink:href="#g16" y="53346"/><use xlink:href="#g16" y="53363"/><use xlink:href="#g16" y="53380"/><use xlink:href="#g16" y="53397"/><use xlink:href="#g16" y="53414"/><rect x="0" y="53431" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="53431"/></g><g><use xlink:href="#g263" y="53482"/><use xlink:href="#g264" y="53499"/><use xlink:href="#g265" y="53516"/><use xlink:href="#g266" y="53533"/><use xlink:href="#g267" y="53550"/><use xlink:href="#g268" y="53567"/><use xlink:href="#g269" y="53584"/><use xlink:href="#g289" y="53601"/><use xlink:href="#g290" y="53618"/><use xlink:href="#g331" y="53635"/><use xlink:href="#g332" y="53652"/><rect x="128" y="53669" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="53669"/><use xlink:href="#g28" y="53686"/><use xlink:href="#g28" y="53703"/><use xlink:href="#g16" y="53720"/><use xlink:href="#g16" y="53737"/><use xlink:href="#g16" y="53754"/><use xlink:href="#g16" y="53771"/><use xlink:href="#g16" y="53788"/><rect x="0" y="53805" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="53805"/></g><g><use xlink:href="#g263" y="53856"/><use xlink:href="#g264" y="53873"/><use xlink:href="#g265" y="53890"/><use xlink:href="#g266" y="53907"/><use xlink:href="#g267" y="53924"/><use xlink:href="#g268" y="53941"/><use xlink:href="#g269" y="53958"/><use xlink:href="#g289" y="53975"/><use xlink:href="#g290" y="53992"/><use xlink:href="#g331" y="54009"/><use xlink:href="#g332" y="54026"/><rect x="128" y="54043" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="54043"/><use xlink:href="#g28" y="54060"/><use xlink:href="#g28" y="54077"/><use xlink:href="#g16" y="54094"/><use xlink:href="#g16" y="54111"/><use xlink:href="#g16" y="54128"/><use xlink:href="#g16" y="54145"/><use xlink:href="#g16" y="54162"/><rect x="0" y="54179" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="54179"/></g><g><use xlink:href="#g263" y="54230"/><use xlink:href="#g264" y="54247"/><use xlink:href="#g265" y="54264"/><use xlink:href="#g266" y="54281"/><use xlink:href="#g267" y="54298"/><use xlink:href="#g268" y="54315"/><use xlink:href="#g269" y="54332"/><use xlink:href="#g289" y="54349"/><use xlink:href="#g290" y="54366"/><use xlink:href="#g331" y="54383"/><use xlink:href="#g332" y="54400"/><rect x="136" y="54417" width="8" height="17" class="foreground"/><use xlink:href="#g366" y="54417"/><rect x="136" y="54434" width="128" height="17" fill="#008787"/><rect x="264" y="54434" width="8" height="17" fill="#444444"/><use xlink:href="#g367" y="54434"/><rect x="136" y="54451" width="128" height="17" fill="#008787"/><rect x="264" y="54451" width="8" height="17" fill="#444444"/><use xlink:href="#g368" y="54451"/><rect x="136" y="54468" width="128" height="17" fill="#008787"/><rect x="264" y="54468" width="8" height="17" fill="#444444"/><use xlink:href="#g369" y="54468"/><rect x="136" y="54485" width="128" height="17" fill="#008787"/><rect x="264" y="54485" width="8" height="17" fill="#444444"/><use xlink:href="#g370" y="54485"/><rect x="136" y="54502" width="128" height="17" fill="#008787"/><rect x="264" y="54502" width="8" height="17" fill="#444444"/><use xlink:href="#g371" y="54502"/><rect x="136" y="54519" width="128" height="17" fill="#008787"/><rect x="264" y="54519" width="8" height="17" fill="#444444"/><use xlink:href="#g372" y="54519"/><rect x="136" y="54536" width="128" height="17" fill="#008787"/><rect x="264" y="54536" width="8" height="17" fill="#00afaf"/><use xlink:href="#g373" y="54536"/><rect x="0" y="54553" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="54553"/></g><g><use xlink:href="#g263" y="54604"/><use xlink:href="#g264" y="54621"/><use xlink:href="#g265" y="54638"/><use xlink:href="#g266" y="54655"/><use xlink:href="#g267" y="54672"/><use xlink:href="#g268" y="54689"/><use xlink:href="#g269" y="54706"/><use xlink:href="#g289" y="54723"/><use xlink:href="#g290" y="54740"/><use xlink:href="#g331" y="54757"/><use xlink:href="#g332" y="54774"/><rect x="144" y="54791" width="8" height="17" class="foreground"/><use xlink:href="#g374" y="54791"/><rect x="144" y="54808" width="128" height="17" fill="#008787"/><rect x="272" y="54808" width="8" height="17" fill="#444444"/><use xlink:href="#g375" y="54808"/><rect x="144" y="54825" width="128" height="17" fill="#008787"/><rect x="272" y="54825" width="8" height="17" fill="#444444"/><use xlink:href="#g376" y="54825"/><rect x="144" y="54842" width="128" height="17" fill="#008787"/><rect x="272" y="54842" width="8" height="17" fill="#444444"/><use xlink:href="#g377" y="54842"/><rect x="144" y="54859" width="128" height="17" fill="#008787"/><rect x="272" y="54859" width="8" height="17" fill="#444444"/><use xlink:href="#g378" y="54859"/><rect x="144" y="54876" width="128" height="17" fill="#008787"/><rect x="272" y="54876" width="8" height="17" fill="#444444"/><use xlink:href="#g379" y="54876"/><use xlink:href="#g16" y="54893"/><use xlink:href="#g16" y="54910"/><rect x="0" y="54927" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="54927"/></g><g><use xlink:href="#g263" y="54978"/><use xlink:href="#g264" y="54995"/><use xlink:href="#g265" y="55012"/><use xlink:href="#g266" y="55029"/><use xlink:href="#g267" y="55046"/><use xlink:href="#g268" y="55063"/><use xlink:href="#g269" y="55080"/><use xlink:href="#g289" y="55097"/><use xlink:href="#g290" y="55114"/><use xlink:href="#g331" y="55131"/><use xlink:href="#g332" y="55148"/><rect x="152" y="55165" width="8" height="17" class="foreground"/><use xlink:href="#g380" y="55165"/><rect x="152" y="55182" width="56" height="17" fill="#008787"/><rect x="208" y="55182" width="8" height="17" fill="#444444"/><use xlink:href="#g381" y="55182"/><use xlink:href="#g28" y="55199"/><use xlink:href="#g16" y="55216"/><use xlink:href="#g16" y="55233"/><use xlink:href="#g16" y="55250"/><use xlink:href="#g16" y="55267"/><use xlink:href="#g16" y="55284"/><rect x="0" y="55301" width="528" height="17" fill="#262626"/><use xlink:href="#g382" y="55301"/></g><g><use xlink:href="#g263" y="55352"/><use xlink:href="#g264" y="55369"/><use xlink:href="#g265" y="55386"/><use xlink:href="#g266" y="55403"/><use xlink:href="#g267" y="55420"/><use xlink:href="#g268" y="55437"/><use xlink:href="#g269" y="55454"/><use xlink:href="#g289" y="55471"/><use xlink:href="#g290" y="55488"/><use xlink:href="#g331" y="55505"/><use xlink:href="#g332" y="55522"/><rect x="160" y="55539" width="8" height="17" class="foreground"/><use xlink:href="#g383" y="55539"/><rect x="160" y="55556" width="136" height="17" fill="#008787"/><rect x="296" y="55556" width="8" height="17" fill="#444444"/><use xlink:href="#g315" y="55556"/><rect x="160" y="55573" width="136" height="17" fill="#008787"/><rect x="296" y="55573" width="8" height="17" fill="#444444"/><use xlink:href="#g316" y="55573"/><rect x="160" y="55590" width="136" height="17" fill="#008787"/><rect x="296" y="55590" width="8" height="17" fill="#00afaf"/><use xlink:href="#g343" y="55590"/><rect x="160" y="55607" width="136" height="17" fill="#008787"/><rect x="296" y="55607" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g344" y="55607"/><rect x="160" y="55624" width="136" height="17" fill="#008787"/><rect x="296" y="55624" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g319" y="55624"/><rect x="160" y="55641" width="136" height="17" fill="#008787"/><rect x="296" y="55641" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g320" y="55641"/><rect x="160" y="55658" width="136" height="17" fill="#008787"/><rect x="296" y="55658" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g321" y="55658"/><rect x="0" y="55675" width="528" height="17" fill="#262626"/><use xlink:href="#g382" y="55675"/></g><g><use xlink:href="#g263" y="55726"/><use xlink:href="#g264" y="55743"/><use xlink:href="#g265" y="55760"/><use xlink:href="#g266" y="55777"/><use xlink:href="#g267" y="55794"/><use xlink:href="#g268" y="55811"/><use xlink:href="#g269" y="55828"/><use xlink:href="#g289" y="55845"/><use xlink:href="#g290" y="55862"/><use xlink:href="#g331" y="55879"/><use xlink:href="#g332" y="55896"/><rect x="168" y="55913" width="8" height="17" class="foreground"/><use xlink:href="#g384" y="55913"/><rect x="168" y="55930" width="136" height="17" fill="#008787"/><rect x="304" y="55930" width="8" height="17" fill="#444444"/><use xlink:href="#g323" y="55930"/><rect x="168" y="55947" width="136" height="17" fill="#008787"/><rect x="304" y="55947" width="8" height="17" fill="#444444"/><use xlink:href="#g324" y="55947"/><rect x="168" y="55964" width="136" height="17" fill="#008787"/><rect x="304" y="55964" width="8" height="17" fill="#444444"/><use xlink:href="#g346" y="55964"/><rect x="168" y="55981" width="136" height="17" fill="#008787"/><rect x="304" y="55981" width="8" height="17" fill="#444444"/><use xlink:href="#g347" y="55981"/><rect x="168" y="55998" width="136" height="17" fill="#008787"/><rect x="304" y="55998" width="8" height="17" fill="#00afaf"/><use xlink:href="#g327" y="55998"/><rect x="168" y="56015" width="136" height="17" fill="#008787"/><rect x="304" y="56015" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g328" y="56015"/><rect x="168" y="56032" width="136" height="17" fill="#008787"/><rect x="304" y="56032" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g329" y="56032"/><rect x="0" y="56049" width="528" height="17" fill="#262626"/><use xlink:href="#g382" y="56049"/></g><g><use xlink:href="#g263" y="56100"/><use xlink:href="#g264" y="56117"/><use xlink:href="#g265" y="56134"/><use xlink:href="#g266" y="56151"/><use xlink:href="#g267" y="56168"/><use xlink:href="#g268" y="56185"/><use xlink:href="#g269" y="56202"/><use xlink:href="#g289" y="56219"/><use xlink:href="#g290" y="56236"/><use xlink:href="#g331" y="56253"/><use xlink:href="#g332" y="56270"/><rect x="176" y="56287" width="8" height="17" class="foreground"/><use xlink:href="#g385" y="56287"/><rect x="168" y="56304" width="136" height="17" fill="#ffffff"/><rect x="304" y="56304" width="8" height="17" fill="#444444"/><use xlink:href="#g386" y="56304"/><rect x="168" y="56321" width="136" height="17" fill="#008787"/><rect x="304" y="56321" width="8" height="17" fill="#444444"/><use xlink:href="#g324" y="56321"/><rect x="168" y="56338" width="136" height="17" fill="#008787"/><rect x="304" y="56338" width="8" height="17" fill="#444444"/><use xlink:href="#g346" y="56338"/><rect x="168" y="56355" width="136" height="17" fill="#008787"/><rect x="304" y="56355" width="8" height="17" fill="#444444"/><use xlink:href="#g347" y="56355"/><rect x="168" y="56372" width="136" height="17" fill="#008787"/><rect x="304" y="56372" width="8" height="17" fill="#00afaf"/><use xlink:href="#g327" y="56372"/><rect x="168" y="56389" width="136" height="17" fill="#008787"/><rect x="304" y="56389" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g328" y="56389"/><rect x="168" y="56406" width="136" height="17" fill="#008787"/><rect x="304" y="56406" width="8" height="17" fill="#a8a8a8"/><use xlink:href="#g329" y="56406"/><rect x="0" y="56423" width="528" height="17" fill="#262626"/><use xlink:href="#g382" y="56423"/></g><g><use xlink:href="#g265" y="56474"/><use xlink:href="#g266" y="56491"/><use xlink:href="#g267" y="56508"/><use xlink:href="#g268" y="56525"/><use xlink:href="#g269" y="56542"/><use xlink:href="#g289" y="56559"/><use xlink:href="#g290" y="56576"/><use xlink:href="#g331" y="56593"/><use xlink:href="#g332" y="56610"/><use xlink:href="#g387" y="56627"/><use xlink:href="#g388" y="56644"/><rect x="128" y="56661" width="8" height="17" class="foreground"/><use xlink:href="#g15" y="56661"/><use xlink:href="#g16" y="56678"/><use xlink:href="#g16" y="56695"/><use xlink:href="#g16" y="56712"/><use xlink:href="#g16" y="56729"/><use xlink:href="#g16" y="56746"/><use xlink:href="#g16" y="56763"/><use xlink:href="#g16" y="56780"/><rect x="0" y="56797" width="528" height="17" fill="#262626"/><use xlink:href="#g17" y="56797"/></g><g><use xlink:href="#g265" y="56848"/><use xlink:href="#g266" y="56865"/><use xlink:href="#g267" y="56882"/><use xlink:href="#g268" y="56899"/><use xlink:href="#g269" y="56916"/><use xlink:href="#g289" y="56933"/><use xlink:href="#g290" y="56950"/><use xlink:href="#g331" y="56967"/><use xlink:href="#g332" y="56984"/><use xlink:href="#g387" y="57001"/><use xlink:href="#g388" y="57018"/><use xlink:href="#g389" y="57035"/><use xlink:href="#g390" y="57052"/><rect x="0" y="57069" width="8" height="17" class="foreground"/><use xlink:href="#g1" y="57069"/><use xlink:href="#g16" y="57086"/><use xlink:href="#g16" y="57103"/><use xlink:href="#g16" y="57120"/><use xlink:href="#g16" y="57137"/><use xlink:href="#g16" y="57154"/><use xlink:href="#g16" y="57171"/></g><g><use xlink:href="#g265" y="57222"/><use xlink:href="#g266" y="57239"/><use xlink:href="#g267" y="57256"/><use xlink:href="#g268" y="57273"/><use xlink:href="#g269" y="57290"/><use xlink:href="#g289" y="57307"/><use xlink:href="#g290" y="57324"/><use xlink:href="#g331" y="57341"/><use xlink:href="#g332" y="57358"/><use xlink:href="#g387" y="57375"/><use xlink:href="#g388" y="57392"/><use xlink:href="#g389" y="57409"/><use xlink:href="#g390" y="57426"/><rect x="16" y="57443" width="8" height="17" class="foreground"/><use xlink:href="#g2" y="57443"/><use xlink:href="#g16" y="57460"/><use xlink:href="#g16" y="57477"/><use xlink:href="#g16" y="57494"/><use xlink:href="#g16" y="57511"/><use xlink:href="#g16" y="57528"/><use xlink:href="#g16" y="57545"/></g><g><use xlink:href="#g265" y="57596"/><use xlink:href="#g266" y="57613"/><use xlink:href="#g267" y="57630"/><use xlink:href="#g268" y="57647"/><use xlink:href="#g269" y="57664"/><use xlink:href="#g289" y="57681"/><use xlink:href="#g290" y="57698"/><use xlink:href="#g331" y="57715"/><use xlink:href="#g332" y="57732"/><use xlink:href="#g387" y="57749"/><use xlink:href="#g388" y="57766"/><use xlink:href="#g389" y="57783"/><use xlink:href="#g390" y="57800"/><use xlink:href="#g391" y="57817"/><rect x="0" y="57834" width="8" height="17" class="foreground"/><use xlink:href="#g1" y="57834"/><use xlink:href="#g16" y="57851"/><use xlink:href="#g16" y="57868"/><use xlink:href="#g16" y="57885"/><use xlink:href="#g16" y="57902"/><use xlink:href="#g16" y="57919"/></g></g></svg> +</svg>
\ No newline at end of file diff --git a/docs/assets/logo.png b/docs/assets/logo.png Binary files differnew file mode 100644 index 0000000..54ced97 --- /dev/null +++ b/docs/assets/logo.png diff --git a/docs/assets/render.md b/docs/assets/render.md new file mode 100644 index 0000000..9dce624 --- /dev/null +++ b/docs/assets/render.md @@ -0,0 +1,7 @@ +Render using [termtosvg](https://github.com/nbedos/termtosvg/blob/develop/man/termtosvg.md): + +``` +termtosvg render demo.cast demo1.svg -D 2 -m40 -M300 -t progress_bar +``` + +size: 66x20 diff --git a/docs/cloudshell/run-in-docker.txt b/docs/cloudshell/run-in-docker.txt new file mode 100644 index 0000000..3e0cc43 --- /dev/null +++ b/docs/cloudshell/run-in-docker.txt @@ -0,0 +1,3 @@ +Try redis in docker(which contains a redis-server): + + docker build -t iredis . && docker run -it iredis diff --git a/docs/update-redis-doc.md b/docs/update-redis-doc.md new file mode 100644 index 0000000..2be45c0 --- /dev/null +++ b/docs/update-redis-doc.md @@ -0,0 +1,9 @@ +# How to Catch Up with Latest Redis-doc + +1. `git pull` in submodule. +2. Overwrite `iredis/data/commands.json`. +3. Diff with old `commands.json`, make the changes. +4. `mv redis-doc/commands/*.md iredis/data/commands` +5. `prettier --write --prose-wrap always iredis/data/commands/*.md` + +Done! diff --git a/iredis/__init__.py b/iredis/__init__.py new file mode 100644 index 0000000..9a34ccc --- /dev/null +++ b/iredis/__init__.py @@ -0,0 +1 @@ +__version__ = "1.13.0" diff --git a/iredis/bottom.py b/iredis/bottom.py new file mode 100644 index 0000000..17c3af3 --- /dev/null +++ b/iredis/bottom.py @@ -0,0 +1,35 @@ +import logging +from .commands import commands_summary +from .utils import command_syntax + +BUTTOM_TEXT = "Ctrl-D to exit;" +logger = logging.getLogger(__name__) + + +class BottomToolbar: + CHAR = "⣾⣷⣯⣟⡿⢿⣻⣽" + + def __init__(self, command_holder): + self.index = 0 + # BottomToolbar can only read this variable + self.command_holder = command_holder + + def get_animation_char(self): + animation = self.CHAR[self.index] + + self.index += 1 + if self.index == len(self.CHAR): + self.index = 0 + return animation + + def render(self): + text = BUTTOM_TEXT + # add command help if valid + if self.command_holder.command: + try: + command_info = commands_summary[self.command_holder.command] + text = command_syntax(self.command_holder.command, command_info) + except KeyError as e: + logger.exception(e) + + return text diff --git a/iredis/client.py b/iredis/client.py new file mode 100644 index 0000000..bbdb87c --- /dev/null +++ b/iredis/client.py @@ -0,0 +1,758 @@ +""" +IRedis client. +""" +import re +import os +import sys +import logging +from subprocess import run +from importlib_resources import read_text +from packaging.version import parse as version_parse + +import redis +from prompt_toolkit.shortcuts import clear +from prompt_toolkit.formatted_text import FormattedText +from redis.connection import Connection, SSLConnection, UnixDomainSocketConnection +from redis.exceptions import ( + AuthenticationError, + ConnectionError, + TimeoutError, + ResponseError, +) + +from . import markdown, renders +from .data import commands as commands_data +from .commands import ( + command2callback, + commands_summary, + command2syntax, + groups, + split_command_args, + split_unknown_args, +) +from .completers import IRedisCompleter +from .config import config +from .exceptions import NotRedisCommand, InvalidArguments, AmbiguousCommand, NotSupport +from .renders import OutputRender +from .utils import ( + compose_command_syntax, + nativestr, + exit, + convert_formatted_text_to_bytes, + parse_url, +) +from .warning import confirm_dangerous_command + +logger = logging.getLogger(__name__) +CLIENT_COMMANDS = groups["iredis"] + + +class Client: + """ + iRedis client, hold a redis-py Client to interact with Redis. + """ + + def __init__( + self, + host="127.0.0.1", + port=6379, + db=0, + password=None, + path=None, + scheme="redis", + username=None, + client_name=None, + prompt=None, + verify_ssl=None, + ): + self.host = host + self.port = port + self.db = db + self.path = path + self.username = username + self.client_name = client_name + self.scheme = scheme + self.password = password + + # cli args --prompt will overwrite the prompt in iredisrc config file + self.prompt = "" + if config.prompt: + self.prompt = config.prompt + if prompt: + self.prompt = prompt + + self.verify_ssl = verify_ssl or "required" + + self.client_id = None + self.client_addr = None + + self.build_connection() + + # all command upper case + self.answer_callbacks = command2callback + self.set_default_pager(config) + try: + self.connection.connect() + except Exception as e: + print(str(e), file=sys.stderr) + sys.exit(1) + if not config.no_info: + try: + self.get_server_info() + except Exception as e: + logger.warning(f"[After Connection] {str(e)}") + config.no_version_reason = str(e) + else: + config.no_version_reason = "--no-info flag activated" + + if self.prompt and "client_addr" in self.prompt: + self.client_addr = ":".join( + str(x) for x in self.connection._sock.getsockname() + ) + if self.prompt and "client_id" in self.prompt: + self.client_id = str(self.execute("CLIENT ID")) + + if config.version and re.match(r"([\d\.]+)", config.version): + self.auth_compat(config.version) + + def build_connection(self): + """ + create a new connection and replace ``self.connection`` + """ + self.connection = self.create_connection( + self.host, + self.port, + self.db, + self.password, + self.path, + self.scheme, + self.username, + self.verify_ssl, + client_name=self.client_name, + ) + + def create_connection( + self, + host=None, + port=None, + db=0, + password=None, + path=None, + scheme="redis", + username=None, + verify_ssl=None, + client_name=None, + ): + if scheme in ("redis", "rediss"): + connection_kwargs = { + "host": host, + "port": port, + "db": db, + "password": password, + "socket_keepalive": config.socket_keepalive, + "client_name": client_name, + } + + # if username is set without setting paswword, password will be ignored + if password: + connection_kwargs["username"] = username + + if scheme == "rediss": + connection_kwargs["ssl_cert_reqs"] = verify_ssl + connection_class = SSLConnection + else: + connection_class = Connection + else: + connection_kwargs = { + "db": db, + "password": password, + "path": path, + "client_name": client_name, + "username": username, + } + connection_class = UnixDomainSocketConnection + + if config.decode: + connection_kwargs["encoding"] = config.decode + connection_kwargs["decode_responses"] = True + connection_kwargs["encoding_errors"] = "replace" + + logger.debug( + f"connection_class={connection_class}," + f" connection_kwargs={connection_kwargs}" + ) + + return connection_class(**connection_kwargs) + + def auth_compat(self, redis_version: str): + with_username = version_parse(redis_version) >= version_parse("6.0.0") + if with_username: + command2syntax["AUTH"] = "command_usernamex_password" + else: + command2syntax["AUTH"] = "command_password" + + def set_default_pager(self, config): + configured_pager = config.pager + os_environ_pager = os.environ.get("PAGER") + + if configured_pager: + logger.info('Default pager found in config file: "%s"', configured_pager) + os.environ["PAGER"] = configured_pager + elif os_environ_pager: + logger.info( + 'Default pager found in PAGER environment variable: "%s"', + os_environ_pager, + ) + os.environ["PAGER"] = os_environ_pager + else: + logger.info("No default pager found in environment. Using os default pager") + + # Set default set of less recommended options, if they are not already set. + # They are ignored if pager is different than less. + if not os.environ.get("LESS"): + os.environ["LESS"] = "-SRXF" + + def get_server_info(self): + # safe to decode Redis's INFO response + info_resp = nativestr(self.execute("INFO")) + version = re.findall(r"redis_version:(.+)\r\n", info_resp)[0] + logger.debug(f"[Redis Version] {version}") + config.version = version + + def __str__(self): + if self.prompt: # not None and not empty + return self.prompt.format( + client_name=self.client_name, + db=self.db, + host=self.host, + path=self.path, + port=self.port, + username=self.username, + client_addr=self.client_addr, + client_id=self.client_id, + ) + + if self.scheme == "unix": + prompt = f"redis {self.path}" + else: + prompt = f"{self.host}:{self.port}" + + if self.db: + prompt = f"{prompt}[{self.db}]" + + return f"{prompt}> " + + def client_execute_command(self, command_name, *args): + command = command_name.upper() + if command == "HELP": + yield self.do_help(*args) + if command == "PEEK": + yield from self.do_peek(*args) + if command == "CLEAR": + clear() + if command == "EXIT": + exit() + + def execute(self, *args, **kwargs): + logger.info( + f"execute: connection={self.connection} args={args}, kwargs={kwargs}" + ) + return self.execute_by_connection(self.connection, *args, **kwargs) + + def execute_by_connection(self, connection, command_name, *args, **options): + """Execute a command and return a parsed response + Here we retry once for ConnectionError. + """ + logger.info( + f"execute by connection: connection={connection}, name={command_name}," + f" {args}, {options}" + ) + retry_times = config.retry_times # FIXME configurable + last_error = None + need_refresh_connection = False + + while retry_times >= 0: + try: + if need_refresh_connection: + print( + f"{str(last_error)} retrying... retry left: {retry_times+1}", + file=sys.stderr, + ) + connection.disconnect() + connection.connect() + logger.info(f"New connection created, retry on {connection}.") + logger.info(f"send_command: {command_name} , {args}") + connection.send_command(command_name, *args) + response = connection.read_response() + except AuthenticationError: + raise + except (ConnectionError, TimeoutError) as e: + logger.warning(f"Connection Error, got {e}, retrying...") + last_error = e + retry_times -= 1 + need_refresh_connection = True + except redis.exceptions.ExecAbortError: + config.transaction = False + raise + except ResponseError as e: + response_message = str(e) + if response_message.startswith("MOVED"): + return self.reissue_with_redirect( + response_message, command_name, *args, **options + ) + raise e + + except KeyboardInterrupt: + logger.warning("received KeyboardInterrupt... rebuild connection...") + connection.disconnect() + connection.connect() + print( + "KeyboardInterrupt received! User canceled reading response!", + file=sys.stderr, + ) + return None + else: + return response + if last_error: + raise last_error + + def reissue_with_redirect(self, response, *args, **kwargs): + """ + For redis cluster, when server response a "MOVE ..." response, we auto- + redirect to the target node, reissue the original command. + + This feature is not supported for unix socket connection. + """ + # Redis Cluster only supports database zero. + _, _, ip_port = response.split(" ") + ip, port = ip_port.split(":") + port = int(port) + + print(response, file=sys.stderr) + + connection = self.create_connection( + ip, + port, + username=self.username, + password=self.password, + path=self.path, + scheme=self.scheme, + client_name=self.client_name, + ) + # if user sets dsn for dest node + # use username and password from dsn settings + if config.alias_dsn: + for dsn_name, dsn_url in config.alias_dsn.items(): + dsn = parse_url(dsn_url) + if dsn.host == ip and dsn.port == port: + print( + f"Connect {ip}:{port} via dns settings of {dsn_name}", + file=sys.stderr, + ) + connection = self.create_connection( + dsn.host, + dsn.port, + dsn.db, + dsn.password, + dsn.path, + dsn.scheme, + dsn.username, + ) + break + + connection.connect() + return self.execute_by_connection(connection, *args, **kwargs) + + def render_response(self, response, command_name): + "Parses a response from the Redis server" + logger.info(f"[Redis-Server] Response: {response}") + if config.raw: + callback = OutputRender.render_raw + # if in transaction, use queue render first + elif config.transaction: + callback = renders.OutputRender.render_transaction_queue + else: + callback = OutputRender.get_render(command_name=command_name) + rendered = callback(response) + logger.info(f"[render result] {rendered}") + return rendered + + def monitor(self): + """Redis' MONITOR command: + https://redis.io/commands/monitor + This command need to read from a stream resp, so + it's different + """ + while 1: + response = self.connection.read_response() + if config.raw: + yield OutputRender.render_raw(response) + else: + yield OutputRender.render_bulk_string_decode(response) + + def subscribing(self): + while 1: + response = self.connection.read_response() + if config.raw: + yield OutputRender.render_raw(response) + else: + yield OutputRender.render_subscribe(response) + + def unsubscribing(self): + "unsubscribe from all channels" + response = self.execute("UNSUBSCRIBE") + if config.raw: + yield OutputRender.render_raw(response) + else: + yield OutputRender.render_subscribe(response) + + def split_command_and_pipeline(self, rawinput, completer: IRedisCompleter): + """ + split user raw input to redis command and shell pipeline. + eg: + GET json | jq .key + return: GET json, jq . key + """ + grammar = completer.get_completer(input_text=rawinput).compiled_grammar + matched = grammar.match(rawinput) + if not matched: + # invalid command! + return rawinput, None + variables = matched.variables() + shell_command = variables.get("shellcommand") + if shell_command: + redis_command = rawinput.replace(shell_command, "") + shell_command = shell_command.lstrip("| ") + return redis_command, shell_command + return rawinput, None + + def send_command(self, raw_command, completer=None): # noqa + """ + Send raw_command to redis-server, return parsed response. + + :param raw_command: text raw_command, not parsed + :param completer: RedisGrammarCompleter will update completer + based on redis response. eg: update key completer after ``keys`` + raw_command + """ + if completer is None: # not in a tty + redis_command, shell_command = raw_command, None + else: + redis_command, shell_command = self.split_command_and_pipeline( + raw_command, completer + ) + logger.info(f"[Prepare command] Redis: {redis_command}, Shell: {shell_command}") + try: + try: + command_name, args = split_command_args(redis_command) + except (InvalidArguments, AmbiguousCommand): + logger.warn( + "This is not a iredis known command, send to redis-server anyway..." + ) + command_name, args = split_unknown_args(redis_command) + + logger.info(f"[Split command] command: {command_name}, args: {args}") + input_command_upper = command_name.upper() + # Confirm for dangerous command + if config.warning: + confirm = confirm_dangerous_command(input_command_upper) + if confirm is True: + print("Your Call!!", file=sys.stderr) + elif confirm is False: + print("Canceled!", file=sys.stderr) + return + # None: continue... + + self.pre_hook(raw_command, command_name, args, completer) + # if raw_command is not supposed to send to server + if input_command_upper in CLIENT_COMMANDS: + logger.info(f"{input_command_upper} is an iredis command.") + yield from self.client_execute_command(command_name, *args) + return + + redis_resp = self.execute(command_name, *args) + # if shell_command and enable shell, do not render, just run in shell pipe and show the + # subcommand's stdout/stderr + if shell_command and config.shell: + # pass the raw response of redis to shell command + stdin = OutputRender.render_raw(redis_resp) + run(shell_command, input=stdin, shell=True) + return + + self.after_hook(raw_command, command_name, args, completer, redis_resp) + yield self.render_response(redis_resp, command_name) + + # FIXME generator response do not support pipeline + if input_command_upper == "MONITOR": + # TODO special render for monitor + try: + yield from self.monitor() + except KeyboardInterrupt: + pass + elif input_command_upper in [ + "SUBSCRIBE", + "PSUBSCRIBE", + ]: # enter subscribe mode + try: + yield from self.subscribing() + except KeyboardInterrupt: + yield from self.unsubscribing() + except Exception as e: + logger.exception(e) + if config.raw: + render_callback = OutputRender.render_raw + else: + render_callback = OutputRender.render_error + yield render_callback(f"ERROR {str(e)}".encode()) + finally: + config.withscores = False + + def after_hook(self, command, command_name, args, completer, response): + # === After hook === + # SELECT db on AUTH + if command_name.upper() == "AUTH": + if self.db: + select_result = self.execute("SELECT", self.db) + if nativestr(select_result) != "OK": + raise ConnectionError("Invalid Database") + # When the connection is TimeoutError or ConnectionError, reconnect the connection will use it + self.connection.password = args[0] + elif command_name.upper() == "SELECT": + logger.debug("[After hook] Command is SELECT, change self.db.") + self.db = int(args[0]) + # When the connection is TimeoutError or ConnectionError, reconnect the connection will use it + self.connection.db = self.db + elif command_name.upper() == "MULTI": + logger.debug("[After hook] Command is MULTI, start transaction.") + config.transaction = True + + if completer: + completer.update_completer_for_response(command_name, args, response) + + def pre_hook(self, command, command_name, args, completer: IRedisCompleter): + """ + Before execute command, patch completers first. + Eg: When user run `GET foo`, key completer need to + touch foo. + + Only works when compile-grammar thread is done. + """ + if command_name.upper() == "HELLO": + raise NotSupport("IRedis currently not support RESP3, sorry about that.") + # TRANSACTION state change + if command_name.upper() in ["EXEC", "DISCARD"]: + logger.debug(f"[After hook] Command is {command_name}, unset transaction.") + config.transaction = False + # score display for sorted set + if command_name.upper() in ["ZSCAN", "ZPOPMAX", "ZPOPMIN"]: + config.withscores = True + + # not a tty + if not completer: + logger.warning( + "[Pre patch completer] Complter is None, not a tty, " + "not patch completers, not set withscores" + ) + return + completer.update_completer_for_input(command) + + redis_grammar = completer.get_completer(command).compiled_grammar + m = redis_grammar.match(command) + if not m: + # invalid command! + return + variables = m.variables() + # zset withscores + withscores = variables.get("withscores") + if withscores: + config.withscores = True + + def do_help(self, *args): + command_docs_name = "-".join(args).lower() + command_summary_name = " ".join(args).upper() + try: + doc = read_text(commands_data, f"{command_docs_name}.md") + except FileNotFoundError: + raise NotRedisCommand( + f"{command_summary_name} is not a valid Redis command." + ) + rendered_detail = markdown.render(doc) + summary_dict = commands_summary[command_summary_name] + + available_version = summary_dict.get("since", "?") + server_version = config.version + # FIXME anything strange with single quotes? + logger.debug(f"[--version--] '{server_version}'") + try: + is_available = version_parse(server_version) > version_parse( + available_version + ) + except Exception as e: + logger.exception(e) + is_available = None + + if is_available: + available_text = f"(Available on your redis-server: {server_version})" + elif is_available is False: + available_text = f"(Not available on your redis-server: {server_version})" + else: + available_text = "" + since_text = f"{available_version} {available_text}" + + summary = [ + ("", "\n"), + ("class:doccommand", " " + command_summary_name), + ("", "\n"), + ("class:dockey", " summary: "), + ("", summary_dict.get("summary", "No summary")), + ("", "\n"), + ("class:dockey", " complexity: "), + ("", summary_dict.get("complexity", "?")), + ("", "\n"), + ("class:dockey", " since: "), + ("", since_text), + ("", "\n"), + ("class:dockey", " group: "), + ("", summary_dict.get("group", "?")), + ("", "\n"), + ("class:dockey", " syntax: "), + ("", command_summary_name), # command + *compose_command_syntax(summary_dict, style_class=""), # command args + ("", "\n\n"), + ] + + to_render = FormattedText(summary + rendered_detail) + if config.raw: + return convert_formatted_text_to_bytes(to_render) + return to_render + + def do_peek(self, key): + """ + PEEK command implementation. + + It's a generator, will run different redis commands based on the key's + type, yields FormattedText once a command reached result. + + Redis current supported types: + string, list, set, zset, hash and stream. + """ + + def _string(key): + strlen = self.execute("strlen", key) + yield FormattedText([("class:dockey", "strlen: "), ("", str(strlen))]) + + value = self.execute("GET", key) + yield FormattedText( + [ + ("class:dockey", "value: "), + ("", renders.OutputRender.render_bulk_string(value)), + ] + ) + + def _list(key): + llen = self.execute("llen", key) + yield FormattedText([("class:dockey", "llen: "), ("", str(llen))]) + if llen <= 20: + contents = self.execute(f"LRANGE {key} 0 -1") + else: + first_10 = self.execute(f"LRANGE {key} 0 9") + last_10 = self.execute(f"LRANGE {key} -10 -1") + contents = first_10 + [f"{llen-20} elements was omitted ..."] + last_10 + yield FormattedText([("class:dockey", "elements: ")]) + yield renders.OutputRender.render_list(contents) + + def _set(key): + cardinality = self.execute("scard", key) + yield FormattedText( + [("class:dockey", "cardinality: "), ("", str(cardinality))] + ) + if cardinality <= 20: + contents = self.execute("smembers", key) + yield FormattedText([("class:dockey", "members: ")]) + yield renders.OutputRender.render_list(contents) + else: + _, contents = self.execute(f"sscan {key} 0 count 20") + first_n = len(contents) + yield FormattedText([("class:dockey", f"members (first {first_n}): ")]) + yield renders.OutputRender.render_members(contents) + # TODO update completers + + def _zset(key): + count = self.execute(f"zcount {key} -inf +inf") + yield FormattedText([("class:dockey", "zcount: "), ("", str(count))]) + if count <= 20: + contents = self.execute(f"zrange {key} 0 -1 withscores") + yield FormattedText([("class:dockey", "members: ")]) + yield renders.OutputRender.render_members(contents) + else: + _, contents = self.execute(f"zscan {key} 0 count 20") + first_n = len(contents) // 2 + yield FormattedText([("class:dockey", f"members (first {first_n}): ")]) + config.withscores = True + output = renders.OutputRender.render_members(contents) + config.withscores = False + yield output + + def _hash(key): + hlen = self.execute(f"hlen {key}") + yield FormattedText([("class:dockey", "hlen: "), ("", str(hlen))]) + if hlen <= 20: + contents = self.execute(f"hgetall {key}") + yield FormattedText([("class:dockey", "fields: ")]) + else: + _, contents = self.execute(f"hscan {key} 0 count 20") + first_n = len(contents) // 2 + yield FormattedText([("class:dockey", f"fields (first {first_n}): ")]) + yield renders.OutputRender.render_hash_pairs(contents) + + def _stream(key): + xinfo = self.execute("xinfo stream", key) + yield FormattedText([("class:dockey", "XINFO: ")]) + yield renders.OutputRender.render_list(xinfo) + + # in case the result is too long, we yield only once so the outputer + # can pager it. + peek_response = [] + key_type = nativestr(self.execute("type", key)) + if key_type == "none": + yield f"{key} doesn't exist." + return + + encoding = nativestr(self.execute("object encoding", key)) + + # use `memory usage` to get memory, this command available from redis4.0 + mem = "" + if config.version and version_parse(config.version) >= version_parse("4.0.0"): + memory_usage_value = str(self.execute("memory usage", key)) + mem = f" mem: {memory_usage_value} bytes" + + ttl = str(self.execute("ttl", key)) + + key_info = f"{key_type} ({encoding}){mem}, ttl: {ttl}" + + # FIXME raw write_result parse FormattedText + peek_response.append(FormattedText([("class:dockey", "key: "), ("", key_info)])) + + detail_action_fun = { + "string": _string, + "list": _list, + "set": _set, + "zset": _zset, + "hash": _hash, + "stream": _stream, + }[key_type] + detail = list(detail_action_fun(key)) + peek_response.extend(detail) + + # merge them into only one FormattedText + flat_formatted_text_pair = [] + for index, formatted_text in enumerate(peek_response): + for ft in formatted_text: + flat_formatted_text_pair.append(ft) + if index < len(peek_response) - 1: + flat_formatted_text_pair.append(renders.NEWLINE_TUPLE) + + if config.raw: + yield convert_formatted_text_to_bytes(flat_formatted_text_pair) + return + yield FormattedText(flat_formatted_text_pair) diff --git a/iredis/commands.py b/iredis/commands.py new file mode 100644 index 0000000..fcbe2a4 --- /dev/null +++ b/iredis/commands.py @@ -0,0 +1,150 @@ +import re +import csv +import json +import logging +import functools +from importlib_resources import read_text, open_text + +from .utils import timer, strip_quote_args +from .exceptions import InvalidArguments, AmbiguousCommand +from . import data as project_data + + +logger = logging.getLogger(__name__) + + +def _load_command_summary(): + commands_summary = json.loads(read_text(project_data, "commands.json")) + return commands_summary + + +def _load_command(): + """ + load command information from file. + :returns: + - original_commans: dict, command name : Command + - command_group: dict, group_name: command_names + """ + first_line = True + command2callback = {} + command2syntax = {} + groups = {} + with open_text(project_data, "command_syntax.csv") as command_syntax: + csvreader = csv.reader(command_syntax) + for line in csvreader: + if first_line: + first_line = False + continue + group, command, syntax, func_name = line + command2callback[command] = func_name + command2syntax[command] = syntax + groups.setdefault(group, []).append(command) + + return command2callback, command2syntax, groups + + +def _load_dangerous(): + """ + Load dangerous commands from csv file. + """ + first_line = True + dangerous_command = {} + with open_text(project_data, "dangerous_commands.csv") as dangerous_file: + csvreader = csv.reader(dangerous_file) + for line in csvreader: + if first_line: + first_line = False + continue + command, reason = line + dangerous_command[command] = reason + return dangerous_command + + +timer("[Loader] Start loading commands file...") +command2callback, command2syntax, groups = _load_command() +# all redis command strings, in UPPER case +# NOTE: Must sort by length, to match longest command first +all_commands = sorted( + list(command2callback.keys()) + ["HELP"], key=lambda x: len(x), reverse=True +) +# load commands information from redis-doc/commands.json +commands_summary = _load_command_summary() +# add iredis' commands' summary +commands_summary.update( + { + "HELP": { + "summary": "Show documents for a Redis command.", + "complexity": "O(1).", + "arguments": [{"name": "command", "type": "string"}], + "since": "1.0", + "group": "iredis", + }, + "CLEAR": { + "summary": "Clear the screen like bash clear.", + "complexity": "O(1).", + "since": "1.0", + "group": "iredis", + }, + "EXIT": { + "summary": "Exit iredis.", + "complexity": "O(1).", + "since": "1.0", + "group": "iredis", + }, + "PEEK": { + "summary": "Get the key's type and value.", + "arguments": [{"name": "key", "type": "key"}], + "complexity": "O(1).", + "since": "1.0", + "group": "iredis", + }, + } +) +timer("[Loader] Finished loading commands.") +dangerous_commands = _load_dangerous() + + +@functools.lru_cache(maxsize=2048) +def split_command_args(command): + """ + Split Redis command text into command and args. + + :param command: redis command string, with args + """ + global all_commands + + command = command.strip() + for command_name in all_commands: + # for command that is paritaly input, like `command in`, we should + # match with `command info`, otherwise, `command in` will result in + # `command` with `args` is ('in') which is an invalid case. + normalized_input_command = " ".join(command.split()).upper() + if ( + re.search("\s", command) + and command_name.startswith(normalized_input_command) + and command_name != normalized_input_command + ): + raise AmbiguousCommand("command is not finished") + # allow multiple space in user input command + command_allow_multi_spaces = "[ ]+".join(command_name.split()) + matcher = re.match(rf"({command_allow_multi_spaces})( |$)", command.upper()) + if matcher: + matched_command_len = len(matcher.group(1)) + input_command = command[:matched_command_len] + input_args = command[matcher.end() :] + break + else: + raise InvalidArguments(f"`{command}` is not a valid Redis Command") + + args = list(strip_quote_args(input_args)) + + return input_command, args + + +def split_unknown_args(command): + """ + Split user's input into command and args. + """ + command = command.strip() + input_command, *input_args = command.split(" ") + return input_command, list(strip_quote_args(" ".join(input_args))) diff --git a/iredis/completers.py b/iredis/completers.py new file mode 100644 index 0000000..e3ebb5a --- /dev/null +++ b/iredis/completers.py @@ -0,0 +1,386 @@ +import logging +from typing import Iterable + +import pendulum +from prompt_toolkit.completion import ( + CompleteEvent, + Completer, + Completion, + FuzzyWordCompleter, + WordCompleter, +) +from prompt_toolkit.contrib.regular_languages.completion import GrammarCompleter +from prompt_toolkit.document import Document + +from .commands import split_command_args, commands_summary, all_commands +from .config import config +from .exceptions import InvalidArguments, AmbiguousCommand +from .redis_grammar import CONST, command_grammar, get_command_grammar +from .utils import strip_quote_args, ensure_str + +logger = logging.getLogger(__name__) + + +class MostRecentlyUsedFirstWordMixin: + """ + A Mixin for WordCompleter, with a `touch()` method can make latest used + word appears first. And evict old completion word when `max_words` reached. + + Not thread safe. + """ + + def __init__(self, max_words, words, *args, **kwargs): + self.words = words + self.max_words = max_words + super().__init__(words, *args, **kwargs) + + def touch(self, word): + """ + Make sure word is in the first place of the completer + list. + """ + if word in self.words: + self.words.remove(word) + else: # not in words + if len(self.words) == self.max_words: # full + self.words.pop() + self.words.insert(0, word) + + def touch_words(self, words): + for word in words: + self.touch(word) + + +class MostRecentlyUsedFirstWordCompleter( + MostRecentlyUsedFirstWordMixin, FuzzyWordCompleter +): + pass + + +class IntegerTypeCompleter(MostRecentlyUsedFirstWordMixin, WordCompleter): + def __init__(self): + words = [] + for i in range(1, 64): + words.append(f"i{i}") # signed integer, 64 bit max + words.append(f"u{i}") # unsigned integer, 63 bit max + words.append("i64") + super().__init__(len(words), list(reversed(words))) + + +class TimestampCompleter(Completer): + """ + Completer for timestamp based on input. + + Features: + * Auto complete humanize time, like 3 -> 3 minutes ago, 3 hours ago. + * Auto guess datetime, complete by its timestamp. 2020-01-01 12:00 + -> 1577851200. + + The timezone is read from system. + """ + + def __init__(self, is_milliseconds, future_time, *args, **kwargs): + if is_milliseconds: + self.factor = 1000 + else: + self.factor = 1 + + self.future_time = future_time + super().__init__(*args, **kwargs) + + when_lower_than = { + "year": 20, + "month": 12, + "day": 31, + "hour": 100, + "minute": 1000, + "second": 1000_000, + } + + def _completion_humanize_time(self, document: Document) -> Iterable[Completion]: + text = document.text + if not text.isnumeric(): + return + current = int(text) + now = pendulum.now() + for unit, minimum in self.when_lower_than.items(): + if current <= minimum: + + if self.future_time: + dt = now.add(**{f"{unit}s": current}) + offset_text = "later" + else: + dt = now.subtract(**{f"{unit}s": current}) + offset_text = "ago" + + meta = f"{text} {unit}{'s' if current > 1 else ''} {offset_text} ({dt.format('YYYY-MM-DD HH:mm:ss')})" + yield Completion( + str(dt.int_timestamp * self.factor), + start_position=-len(document.text_before_cursor), + display_meta=meta, + ) + + def _completion_formatted_time(self, document: Document) -> Iterable[Completion]: + text = document.text + try: + dt = pendulum.parse(text) + except Exception: + return + yield Completion( + str(dt.int_timestamp * self.factor), + start_position=-len(document.text_before_cursor), + display_meta=str(dt), + ) + + def get_completions( + self, document: Document, complete_event: CompleteEvent + ) -> Iterable[Completion]: + completions = list(self._completion_humanize_time(document)) + list( + self._completion_formatted_time(document) + ) + + # here we yield bigger timestamp first. + for completion in sorted(completions, key=lambda a: a.text): + yield completion + + +class IRedisCompleter(Completer): + """ + Completer class that can dynamically returns any Completer. + + :param get_completer: Callable that returns a :class:`.Completer` instance. + """ + + def __init__(self, hint=False, completion_casing="upper"): + super().__init__() + self.completer_mapping = self.get_completer_mapping(hint, completion_casing) + self.current_completer = self.root_completer = GrammarCompleter( + command_grammar, self.completer_mapping + ) + + @property + def key_completer(self) -> MostRecentlyUsedFirstWordCompleter: + return self.completer_mapping["key"] + + @property + def member_completer(self) -> MostRecentlyUsedFirstWordCompleter: + return self.completer_mapping["member"] + + @property + def field_completer(self) -> MostRecentlyUsedFirstWordCompleter: + return self.completer_mapping["field"] + + @property + def group_completer(self) -> MostRecentlyUsedFirstWordCompleter: + return self.completer_mapping["group"] + + @property + def catetoryname_completer(self) -> MostRecentlyUsedFirstWordCompleter: + return self.completer_mapping["categoryname"] + + @property + def username_completer(self) -> MostRecentlyUsedFirstWordCompleter: + return self.completer_mapping["username"] + + def get_completer(self, input_text): + try: + command, _ = split_command_args(input_text) + # here will compile grammar for this command + grammar = get_command_grammar(command) + completer = GrammarCompleter( + compiled_grammar=grammar, completers=self.completer_mapping + ) + except (InvalidArguments, AmbiguousCommand): + completer = self.root_completer + + return completer + + def get_completions( + self, document: Document, complete_event: CompleteEvent + ) -> Iterable[Completion]: + input_text = document.text + self.current_completer = self.get_completer(input_text) + return self.current_completer.get_completions(document, complete_event) + + def update_completer_for_input(self, command): + completer = self.get_completer(command) + grammar = completer.compiled_grammar + m = grammar.match(command) + if not m: + # invalid command! + return + variables = m.variables() + + # auto update completion words, if it's LRU strategy. + for _token, _completer in self.completer_mapping.items(): + if not isinstance(_completer, MostRecentlyUsedFirstWordMixin): + continue + + # getall always returns a [] + tokens_in_command = variables.getall(_token) + for _token_in_command in tokens_in_command: + # prompt_toolkit didn't support multi tokens + # like DEL key1 key2 key3 + # so we have to split them manually + for single_token in strip_quote_args(_token_in_command): + _completer.touch(single_token) + + def update_completer_for_response(self, command_name, args, response): + command_name = " ".join(command_name.split()).upper() + logger.info( + f"Try update completer using response... command_name is {command_name}" + ) + if response is None: + return + + response = ensure_str(response) + if command_name in ("HKEYS",): + self.field_completer.touch_words(response) + logger.debug(f"[Completer] field completer updated with {response}.") + + if command_name in ("HGETALL",): + self.field_completer.touch_words(response[::2]) + logger.debug(f"[Completer] field completer updated with {response[::2]}.") + + if command_name in ("ZPOPMAX", "ZPOPMIN", "ZRANGE", "ZRANGE", "ZRANGEBYSCORE"): + if config.withscores: + self.member_completer.touch_words(response[::2]) + logger.debug( + f"[Completer] member completer updated with {response[::2]}." + ) + else: + self.member_completer.touch_words(response) + logger.debug(f"[Completer] member completer updated with {response}.") + + if command_name in ("KEYS",): + self.key_completer.touch_words(response) + logger.debug(f"[Completer] key completer updated with {response}.") + + if command_name in ("SCAN",): + self.key_completer.touch_words(response[1]) + logger.debug(f"[Completer] key completer updated with {response[1]}.") + + if command_name in ("SSCAN", "ZSCAN"): + self.member_completer.touch_words(response[1]) + logger.debug(f"[Completer] member completer updated with {response[1]}.") + + if command_name in ("HSCAN",): + self.field_completer.touch_words(response[1][::2]) + logger.debug( + f"[Completer] field completer updated with {response[1][::2]}." + ) + + # only update categoryname completer when `ACL CAT` without args. + if command_name == "ACL CAT" and not args: + self.catetoryname_completer.touch_words(response) + if command_name == "ACL USERS": + self.username_completer.touch_words(response) + + def _touch_members(self, items): + _step = 1 + + if config.withscores: + _step = 2 + + self.member_completer.touch_words(ensure_str(items)[::_step]) + + def _touch_hash_pairs(self, items): + self.field_completer.touch_words(ensure_str(items)[::2]) + + def _touch_keys(self, items): + self.key_completer.touch_words(ensure_str(items)) + + def __repr__(self) -> str: + return "DynamicCompleter(%r -> %r)" % ( + self.get_completer, + self.current_completer, + ) + + def get_completer_mapping(self, hint_on, completion_casing): + completer_mapping = {} + completer_mapping.update( + { + key: WordCompleter(tokens.split(" "), ignore_case=True) + for key, tokens in CONST.items() + } + ) + key_completer = MostRecentlyUsedFirstWordCompleter(config.completer_max, []) + member_completer = MostRecentlyUsedFirstWordCompleter(config.completer_max, []) + field_completer = MostRecentlyUsedFirstWordCompleter(config.completer_max, []) + group_completer = MostRecentlyUsedFirstWordCompleter(config.completer_max, []) + username_completer = MostRecentlyUsedFirstWordCompleter( + config.completer_max, [] + ) + categoryname_completer = MostRecentlyUsedFirstWordCompleter(100, []) + + timestamp_ms_ago_completer = TimestampCompleter( + is_milliseconds=True, future_time=False + ) + timestamp_ms_after_completer = TimestampCompleter( + is_milliseconds=True, future_time=True + ) + timestamp_after_completer = TimestampCompleter( + is_milliseconds=False, future_time=True + ) + integer_type_completer = IntegerTypeCompleter() + + completer_mapping.update( + { + # all key related completers share the same completer + "keys": key_completer, + "key": key_completer, + "destination": key_completer, + "newkey": key_completer, + # member + "member": member_completer, + "members": member_completer, + # zmember + # TODO separate sorted set and set + # hash fields + "field": field_completer, + "fields": field_completer, + # stream groups + "group": group_completer, + # stream id + "stream_id": timestamp_ms_ago_completer, + "timestampms": timestamp_ms_after_completer, + "timestamp": timestamp_after_completer, + "inttype": integer_type_completer, + "categoryname": categoryname_completer, + "username": username_completer, + } + ) + + # command completer + if hint_on: + command_hint = { + key: info["summary"] for key, info in commands_summary.items() + } + hint = { + command: command_hint.get(command.upper()) for command in all_commands + } + hint.update( + { + command.lower(): command_hint.get(command.upper()) + for command in all_commands + } + ) + else: + hint = {} + + upper_commands = all_commands[::-1] + lower_commands = [command.lower() for command in all_commands[::-1]] + auto_commands = upper_commands + lower_commands + + ignore_case = completion_casing != "auto" + + command_completions = { + "auto": auto_commands, + "upper": upper_commands, + "lower": lower_commands, + }.get(completion_casing) + + completer_mapping["command"] = WordCompleter( + command_completions, ignore_case=ignore_case, sentence=True, meta_dict=hint + ) + return completer_mapping diff --git a/iredis/config.py b/iredis/config.py new file mode 100644 index 0000000..ea27827 --- /dev/null +++ b/iredis/config.py @@ -0,0 +1,133 @@ +from importlib_resources import path +import os +import logging + +from configobj import ConfigObj, ConfigObjError +from . import data as project_data + +# TODO verbose logger to print to stdout +logger = logging.getLogger(__name__) + +system_config_file = "/etc/iredisrc" +pwd_config_file = os.path.join(os.getcwd(), ".iredisrc") + + +class Config: + """ + Global config, set once on start, then + become readonly, never change again. + + :param raw: weather write raw bytes to stdout without any + decoding. + :param decode: How to decode bytes response.(For display and + Completers) + default is None, means show literal bytes. But completers + will try use utf-8 decoding. + """ + + def __init__(self): + self.raw = None + self.completer_max = None + # show command hint? + self.newbie_mode = None + self.rainbow = None + self.retry_times = 2 + self.socket_keepalive = None + self.decode = None + self.no_info = None + self.bottom_bar = None + self.shell = None + self.enable_pager = None + self.pager = None + self.verify_ssl = None + + self.warning = True + + self.no_version_reason = None + self.log_location = None + self.history_location = None + self.completion_casing = None + self.alias_dsn = None + + # ===bad code=== + # below are not configs, it's global state, it's wrong to write this + # please do not add more global state. + # FIXME this should be removed. + # use client attributes instead. + # use kwargs in render functions. + + # for transaction render + self.queued_commands = [] + self.transaction = False + # display zset withscores? + self.withscores = False + self.version = "Unknown" + + self.prompt = None + + def __setter__(self, name, value): + # for every time start a transaction + # clear the queued commands first + if name == "transaction" and value is True: + self.queued_commands = [] + super().__setattr__(name, value) + + +config = Config() + + +def read_config_file(f): + """Read a config file.""" + + if isinstance(f, str): + f = os.path.expanduser(f) + + try: + config = ConfigObj(f, interpolation=False, encoding="utf8") + except ConfigObjError as e: + logger.error( + "Unable to parse line {0} of config file " "'{1}'.".format(e.line_number, f) + ) + logger.error("Using successfully parsed config values.") + return e.config + except (IOError, OSError) as e: + logger.error( + "You don't have permission to read " "config file '{0}'.".format(e.filename) + ) + return None + + return config + + +def load_config_files(iredisrc): + global config + + with path(project_data, "iredisrc") as p: + config_obj = ConfigObj(str(p)) + + for _file in [system_config_file, iredisrc, pwd_config_file]: + _config = read_config_file(_file) + if bool(_config) is True: + config_obj.merge(_config) + config_obj.filename = _config.filename + + config.raw = config_obj["main"].as_bool("raw") + config.completer_max = config_obj["main"].as_int("completer_max") + config.retry_times = config_obj["main"].as_int("retry_times") + config.newbie_mode = config_obj["main"].as_bool("newbie_mode") + config.rainbow = config_obj["main"].as_bool("rainbow") + config.socket_keepalive = config_obj["main"].as_bool("socket_keepalive") + config.no_info = config_obj["main"].as_bool("no_info") + config.bottom_bar = config_obj["main"].as_bool("bottom_bar") + config.warning = config_obj["main"].as_bool("warning") + config.decode = config_obj["main"]["decode"] + config.log_location = config_obj["main"]["log_location"] + config.completion_casing = config_obj["main"]["completion_casing"] + config.history_location = config_obj["main"]["history_location"] + config.alias_dsn = config_obj["alias_dsn"] + config.shell = config_obj["main"].as_bool("shell") + config.pager = config_obj["main"].get("pager") + config.enable_pager = config_obj["main"].as_bool("enable_pager") + config.prompt = config_obj["main"].get("prompt") + + return config_obj diff --git a/iredis/data/__init__.py b/iredis/data/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/iredis/data/__init__.py diff --git a/iredis/data/command_syntax.csv b/iredis/data/command_syntax.csv new file mode 100644 index 0000000..fbaf47b --- /dev/null +++ b/iredis/data/command_syntax.csv @@ -0,0 +1,278 @@ +Group,Command,Syntax,Callback +cluster,CLUSTER ADDSLOTS,command_slots,render_simple_string +cluster,CLUSTER BUMPEPOCH,command,render_simple_string +cluster,CLUSTER COUNT-FAILURE-REPORTS,command_node,render_int +cluster,CLUSTER COUNTKEYSINSLOT,command_slot,render_int +cluster,CLUSTER DELSLOTS,command_slots,render_simple_string +cluster,CLUSTER FAILOVER,command_failoverchoice,render_simple_string +cluster,CLUSTER FLUSHSLOTS,command,render_simple_string +cluster,CLUSTER FORGET,command_node,render_simple_string +cluster,CLUSTER GETKEYSINSLOT,command_slot_count,render_list +cluster,CLUSTER INFO,command,render_bulk_string_decode +cluster,CLUSTER KEYSLOT,command_key,render_int +cluster,CLUSTER MEET,command_ip_port,render_simple_string +cluster,CLUSTER MYID,command,render_bulk_string_decode +cluster,CLUSTER NODES,command,render_bulk_string_decode +cluster,CLUSTER REPLICAS,command_node,render_bulk_string_decode +cluster,CLUSTER REPLICATE,command_node,render_simple_string +cluster,CLUSTER RESET,command_resetchoice,render_simple_string +cluster,CLUSTER SAVECONFIG,command,render_simple_string +cluster,CLUSTER SET-CONFIG-EPOCH,command_epoch,render_simple_string +cluster,CLUSTER SETSLOT,command_slot_slotsubcmd_nodex,render_simple_string +cluster,CLUSTER SLAVES,command_node,render_bulk_string_decode +cluster,CLUSTER SLOTS,command,render_list +cluster,READONLY,command,render_simple_string +cluster,READWRITE,command,render_simple_string +connection,AUTH,command_password,render_simple_string +connection,ECHO,command_message,render_bulk_string +connection,HELLO,command_any,render_list +connection,PING,command_messagex,render_bulk_string +connection,QUIT,command,render_simple_string +connection,SELECT,command_index,render_simple_string +connection,CLIENT CACHING,command_yes,render_simple_string +connection,CLIENT GETREDIR,command,render_int +connection,CLIENT TRACKING,command_client_tracking,render_simple_string +connection,CLIENT TRACKINGINFO,command,render_list +connection,CLIENT LIST,command_client_list,render_bulk_string_decode +connection,CLIENT GETNAME,command,render_bulk_string +connection,CLIENT ID,command,render_int +connection,CLIENT INFO,command,render_bulk_string_decode +connection,CLIENT KILL,command_clientkill,render_string_or_int +connection,CLIENT PAUSE,command_pause,render_simple_string +connection,CLIENT UNPAUSE,command,render_simple_string +connection,CLIENT REPLY,command_switch,render_simple_string +connection,CLIENT SETNAME,command_value,render_simple_string +connection,CLIENT UNBLOCK,command_clientid_errorx,render_int +generic,COPY,command_copy,render_int +generic,DEL,command_keys,render_int +generic,DUMP,command_key,render_bulk_string +generic,EXISTS,command_keys,render_int +generic,EXPIRE,command_key_second,render_int +generic,EXPIREAT,command_key_timestamp,render_int +generic,EXPIRETIME,command_key,render_int +generic,KEYS,command_pattern,command_keys +generic,MIGRATE,command_migrate,render_simple_string +generic,MOVE,command_key_index,render_int +generic,OBJECT,command_object_key,render_string_or_int +generic,PERSIST,command_key,render_int +generic,PEXPIRE,command_key_millisecond,render_int +generic,PEXPIREAT,command_key_timestampms,render_int +generic,PTTL,command_key,render_int +generic,RANDOMKEY,command,render_bulk_string +generic,RENAME,command_key_newkey,render_simple_string +generic,RENAMENX,command_key_newkey,render_int +generic,RESTORE,command_restore,render_simple_string +generic,SCAN,command_cursor_match_pattern_count_type,command_scan +generic,SORT,command_any,render_list_or_string +generic,TOUCH,command_keys,render_int +generic,TTL,command_key,render_int +generic,TYPE,command_key,render_bulk_string +generic,UNLINK,command_keys,render_int +generic,WAIT,command_count_timeout,render_int +geo,GEOADD,command_key_longitude_latitude_members,render_int +geo,GEODIST,command_geodist,render_bulk_string +geo,GEOHASH,command_key_members,render_list +geo,GEOPOS,command_key_members,render_list +geo,GEORADIUS,command_any,render_list_or_string +geo,GEORADIUSBYMEMBER,command_any,render_list_or_string +geo,GEOSEARCH,command_key_any,render_list +geo,GEOSEARCHSTORE,command_key_key_any,render_list +hash,HDEL,command_key_fields,render_int +hash,HEXISTS,command_key_field,render_int +hash,HGET,command_key_field,render_bulk_string +hash,HGETALL,command_key,render_hash_pairs +hash,HINCRBY,command_key_field_delta,render_int +hash,HINCRBYFLOAT,command_key_field_float,render_bulk_string +hash,HKEYS,command_key,command_hkeys +hash,HLEN,command_key,render_int +hash,HMGET,command_key_fields,render_list +hash,HMSET,command_key_fieldvalues,render_bulk_string +hash,HRANDFIELD,command_key_count_withvalues,render_list_or_string +hash,HSCAN,command_key_cursor_match_pattern_count,command_hscan +hash,HSET,command_key_field_value,render_int +hash,HSETNX,command_key_field_value,render_int +hash,HSTRLEN,command_key_field,render_int +hash,HVALS,command_key,render_list +hyperloglog,PFADD,command_key_values,render_int +hyperloglog,PFCOUNT,command_keys,render_int +hyperloglog,PFMERGE,command_newkey_keys,render_simple_string +list,BLMOVE,command_key_key_lr_lr_timeout, render_bulk_string +list,BLPOP,command_keys_timeout,render_list_or_string +list,BRPOP,command_keys_timeout,render_list_or_string +list,BRPOPLPUSH,command_key_newkey_timeout,render_bulk_string +list,LINDEX,command_key_position,render_bulk_string +list,LINSERT,command_key_positionchoice_pivot_value,render_int +list,LLEN,command_key,render_int +list,LPOS,command_lpos,render_list_or_string +list,LPOP,command_key,render_list_or_string +list,LPUSH,command_key_values,render_int +list,LPUSHX,command_key_values,render_int +list,LRANGE,command_key_start_end,render_list +list,LREM,command_key_position_value,render_int +list,LSET,command_key_position_value,render_simple_string +list,LTRIM,command_key_start_end,render_simple_string +list,RPOP,command_key,render_list_or_string +list,RPOPLPUSH,command_key_newkey,render_bulk_string +list,RPUSH,command_key_values,render_int +list,RPUSHX,command_key_value,render_int +pubsub,PSUBSCRIBE,command_channels,render_subscribe +pubsub,PUBLISH,command_channel_message,render_int +pubsub,PUBSUB,command_pubsubcmd_channels,render_list_or_string +pubsub,PUNSUBSCRIBE,command_channels,render_subscribe +pubsub,SUBSCRIBE,command_channels,render_subscribe +pubsub,UNSUBSCRIBE,command_channels,render_subscribe +scripting,EVAL,command_lua_any,render_list_or_string +scripting,EVAL_RO,command_lua_any,render_list_or_string +scripting,EVALSHA,command_any,render_list_or_string +scripting,EVALSHA_RO,command_any,render_list_or_string +scripting,SCRIPT DEBUG,command_scriptdebug,render_simple_string +scripting,SCRIPT EXISTS,command_any,render_list +scripting,SCRIPT FLUSH,command,render_simple_string +scripting,SCRIPT KILL,command,render_simple_string +scripting,SCRIPT LOAD,command_lua_any,render_bulk_string_decode +server,ACL CAT,command_categorynamex,render_list +server,ACL DELUSER,command_usernames,render_int +server,ACL GENPASS,command_countx,render_bulk_string +server,ACL GETUSER,command_username,render_list +server,ACL HELP,command,render_help +server,ACL LIST,command,render_list +server,ACL LOAD,command,render_simple_string +server,ACL LOG,command_count_or_resetx,render_list_or_string +server,ACL SAVE,command,render_simple_string +server,ACL SETUSER,command_username_rules,render_simple_string +server,ACL USERS,command,render_list +server,ACL WHOAMI,command,render_bulk_string +server,SWAPDB,command_index_index,render_simple_string +server,BGREWRITEAOF,command,render_simple_string +server,BGSAVE,command_schedulex,render_simple_string +server,COMMAND,command,render_list +server,COMMAND COUNT,command,render_int +server,COMMAND GETKEYS,command_any,render_list +server,COMMAND INFO,command_commandname,render_list +server,CONFIG GET,command_parameter,render_nested_pair +server,CONFIG RESETSTAT,command,render_simple_string +server,CONFIG REWRITE,command,render_simple_string +server,CONFIG SET,command_parameter_value,render_simple_string +server,DBSIZE,command,render_int +server,DEBUG OBJECT,command_key,render_simple_string +server,DEBUG SEGFAULT,command,render_simple_string +server,FAILOVER,command_failover,render_simple_string +server,FLUSHALL,command_asyncx,render_simple_string +server,FLUSHDB,command_asyncx,render_simple_string +server,INFO,command_sectionx,render_bulk_string_decode +server,LOLWUT,command_version,render_bytes +server,LASTSAVE,command,render_unixtime +server,LATENCY DOCTOR,command,render_bulk_string_decode +server,LATENCY GRAPH,command_graphevent,render_bulk_string_decode +server,LATENCY HELP,command,render_help +server,LATENCY HISTORY,command_graphevent,render_list +server,LATENCY LATEST,command,render_list +server,LATENCY RESET,command_graphevents,render_int +server,MEMORY DOCTOR,command,render_bulk_string_decode +server,MEMORY HELP,command,render_help +server,MEMORY MALLOC-STATS,command,render_bulk_string_decode +server,MEMORY PURGE,command,render_simple_string +server,MEMORY STATS,command,render_nested_pair +server,MEMORY USAGE,command_key_samples_count,render_int +server,MODULE LIST,command,render_list +server,MODULE LOAD,command_any,render_simple_string +server,MODULE UNLOAD,command_any,render_simple_string +server,MONITOR,command,render_simple_string +server,PSYNC,command_replicationid_offset,render_bulk_string_decode +server,REPLICAOF,command_any,render_simple_string +server,ROLE,command,render_list +server,SAVE,command,render_simple_string +server,SHUTDOWN,command_shutdown,render_simple_string +server,SLAVEOF,command_any,render_simple_string +server,SLOWLOG,command_slowlog,render_slowlog +server,SYNC,command,render_bulk_string +server,TIME,command,render_time +set,SADD,command_key_members,render_int +set,SCARD,command_key,render_int +set,SDIFF,command_keys,render_list +set,SDIFFSTORE,command_destination_keys,render_int +set,SINTER,command_keys,render_list +set,SINTERSTORE,command_destination_keys,render_int +set,SISMEMBER,command_key_member,render_int +set,SMEMBERS,command_key,render_list +set,SMOVE,command_key_newkey_member,render_int +set,SPOP,command_key_count_x,render_list_or_string +set,SRANDMEMBER,command_key_count_x,render_list_or_string +set,SREM,command_key_members,render_int +set,SSCAN,command_key_cursor_match_pattern_count,command_sscan +set,SUNION,command_keys,render_list +set,SUNIONSTORE,command_destination_keys,render_int +sorted_set,BZPOPMAX,command_keys_timeout,render_list_or_string +sorted_set,BZPOPMIN,command_keys_timeout,render_list_or_string +sorted_set,ZADD,command_key_condition_changed_incr_score_members,render_string_or_int +sorted_set,ZCARD,command_key,render_int +sorted_set,ZCOUNT,command_key_min_max,render_int +sorted_set,ZINCRBY,command_key_float_member,render_bulk_string +sorted_set,ZINTERSTORE,command_any,render_int +sorted_set,ZLEXCOUNT,command_key_lexmin_lexmax,render_int +sorted_set,ZPOPMAX,command_key_count_x,render_members +sorted_set,ZPOPMIN,command_key_count_x,render_members +sorted_set,ZRANGE,command_key_start_end_withscores_x,render_members +sorted_set,ZRANGEBYLEX,command_key_lexmin_lexmax_limit_offset_count,render_list +sorted_set,ZRANGEBYSCORE,command_key_min_max_withscore_x_limit_offset_count_x,render_members +sorted_set,ZRANK,command_key_member,render_int +sorted_set,ZREM,command_key_members,render_int +sorted_set,ZREMRANGEBYLEX,command_key_lexmin_lexmax,render_int +sorted_set,ZREMRANGEBYRANK,command_key_start_end,render_int +sorted_set,ZREMRANGEBYSCORE,command_key_min_max,render_int +sorted_set,ZREVRANGE,command_key_start_end_withscores_x,render_list +sorted_set,ZREVRANGEBYLEX,command_key_lexmin_lexmax_limit_offset_count,render_list +sorted_set,ZREVRANGEBYSCORE,command_key_min_max_withscore_x_limit_offset_count_x,render_list +sorted_set,ZREVRANK,command_key_member,render_int +sorted_set,ZSCAN,command_key_cursor_match_pattern_count,command_sscan +sorted_set,ZSCORE,command_key_member,render_bulk_string +sorted_set,ZUNIONSTORE,command_any,render_int +stream,XACK,command_key_group_ids,render_int +stream,XADD,command_xadd,render_bulk_string +stream,XCLAIM,command_xclaim,render_list +stream,XDEL,command_key_ids,render_int +stream,XGROUP,command_xgroup,render_string_or_int +stream,XINFO,command_xinfo,render_list +stream,XLEN,command_key,render_int +stream,XPENDING,command_xpending,render_list +stream,XRANGE,command_key_start_end_countx,render_list +stream,XREAD,command_xread,render_list +stream,XREADGROUP,command_xreadgroup,render_list +stream,XREVRANGE,command_key_start_end_countx,render_list +stream,XTRIM,command_key_maxlen,render_int +string,APPEND,command_key_value,render_int +bitmap,BITCOUNT,command_key_start_end_x,render_int +bitmap,BITFIELD,command_bitfield,render_list +bitmap,BITOP,command_operation_key_keys,render_int +bitmap,BITPOS,command_key_bit_start_end,render_int +string,DECR,command_key,render_int +string,DECRBY,command_key_delta,render_int +string,GET,command_key,render_bulk_string +string,GETEX,command_key_expire,render_bulk_string +string,GETBIT,command_key_offset,render_int +string,GETDEL,command_key,render_bulk_string +string,GETRANGE,command_key_start_end,render_bulk_string +string,GETSET,command_key_value,render_bulk_string +string,INCR,command_key,render_int +string,INCRBY,command_key_delta,render_int +string,INCRBYFLOAT,command_key_float,render_bulk_string +string,MGET,command_keys,render_list +string,MSET,command_key_valuess,render_simple_string +string,MSETNX,command_key_valuess,render_int +string,PSETEX,command_key_millisecond_value,render_bulk_string +string,SET,command_set,render_simple_string +string,SETBIT,command_key_offset_bit,render_int +string,SETEX,command_key_second_value,render_bulk_string +string,SETNX,command_key_value,render_int +string,SETRANGE,command_key_offset_value,render_int +string,STRALGO,command_stralgo,render_list_or_string +string,STRLEN,command_key,render_int +transactions,DISCARD,command,render_simple_string +transactions,EXEC,command,render_list_or_string +transactions,MULTI,command,render_simple_string +transactions,UNWATCH,command,render_simple_string +transactions,WATCH,command_keys,render_simple_string +iredis,HELP,command_command, +iredis,PEEK,command_key, +iredis,CLEAR,command, +iredis,EXIT,command, diff --git a/iredis/data/commands.json b/iredis/data/commands.json new file mode 100644 index 0000000..978e128 --- /dev/null +++ b/iredis/data/commands.json @@ -0,0 +1,17102 @@ +{ + "ACL": { + "summary": "A container for Access List Control commands ", + "since": "6.0.0", + "group": "server", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "ACL CAT": { + "summary": "List the ACL categories or the commands inside a category", + "since": "6.0.0", + "group": "server", + "complexity": "O(1) since the categories and commands are a fixed set.", + "acl_categories": [ + "@slow" + ], + "arity": -2, + "arguments": [ + { + "name": "categoryname", + "type": "string", + "optional": true + } + ], + "command_flags": [ + "noscript", + "loading", + "stale" + ] + }, + "ACL DELUSER": { + "summary": "Remove the specified ACL users and the associated rules", + "since": "6.0.0", + "group": "server", + "complexity": "O(1) amortized time considering the typical user.", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -3, + "arguments": [ + { + "name": "username", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "ACL DRYRUN": { + "summary": "Returns whether the user can execute the given command without executing the command.", + "since": "7.0.0", + "group": "server", + "complexity": "O(1).", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -4, + "arguments": [ + { + "name": "username", + "type": "string" + }, + { + "name": "command", + "type": "string" + }, + { + "name": "arg", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "ACL GENPASS": { + "summary": "Generate a pseudorandom secure password to use for ACL users", + "since": "6.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": -2, + "arguments": [ + { + "name": "bits", + "type": "integer", + "optional": true + } + ], + "command_flags": [ + "noscript", + "loading", + "stale" + ] + }, + "ACL GETUSER": { + "summary": "Get the rules for a specific ACL user", + "since": "6.0.0", + "group": "server", + "complexity": "O(N). Where N is the number of password, command and pattern rules that the user has.", + "history": [ + [ + "6.2.0", + "Added Pub/Sub channel patterns." + ], + [ + "7.0.0", + "Added selectors and changed the format of key and channel patterns from a list to their rule representation." + ] + ], + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 3, + "arguments": [ + { + "name": "username", + "type": "string" + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "ACL HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "6.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "ACL LIST": { + "summary": "List the current ACL rules in ACL config file format", + "since": "6.0.0", + "group": "server", + "complexity": "O(N). Where N is the number of configured users.", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "ACL LOAD": { + "summary": "Reload the ACLs from the configured ACL file", + "since": "6.0.0", + "group": "server", + "complexity": "O(N). Where N is the number of configured users.", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "ACL LOG": { + "summary": "List latest events denied because of ACLs in place", + "since": "6.0.0", + "group": "server", + "complexity": "O(N) with N being the number of entries shown.", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -2, + "arguments": [ + { + "name": "operation", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "count", + "type": "integer" + }, + { + "name": "reset", + "type": "pure-token", + "token": "RESET" + } + ] + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "ACL SAVE": { + "summary": "Save the current ACL rules in the configured ACL file", + "since": "6.0.0", + "group": "server", + "complexity": "O(N). Where N is the number of configured users.", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "ACL SETUSER": { + "summary": "Modify or create the rules for a specific ACL user", + "since": "6.0.0", + "group": "server", + "complexity": "O(N). Where N is the number of rules provided.", + "history": [ + [ + "6.2.0", + "Added Pub/Sub channel patterns." + ], + [ + "7.0.0", + "Added selectors and key based permissions." + ] + ], + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -3, + "arguments": [ + { + "name": "username", + "type": "string" + }, + { + "name": "rule", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "ACL USERS": { + "summary": "List the username of all the configured ACL rules", + "since": "6.0.0", + "group": "server", + "complexity": "O(N). Where N is the number of configured users.", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "ACL WHOAMI": { + "summary": "Return the name of the user associated to the current connection", + "since": "6.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "noscript", + "loading", + "stale" + ] + }, + "APPEND": { + "summary": "Append a value to a key", + "since": "2.0.0", + "group": "string", + "complexity": "O(1). The amortized time complexity is O(1) assuming the appended value is small and the already present value is of any size, since the dynamic string library used by Redis will double the free space available on every reallocation.", + "acl_categories": [ + "@write", + "@string", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "value", + "type": "string" + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "ASKING": { + "summary": "Sent by cluster clients after an -ASK redirect", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@fast", + "@connection" + ], + "arity": 1, + "command_flags": [ + "fast" + ] + }, + "AUTH": { + "summary": "Authenticate to the server", + "since": "1.0.0", + "group": "connection", + "complexity": "O(N) where N is the number of passwords defined for the user", + "history": [ + [ + "6.0.0", + "Added ACL style (username and password)." + ] + ], + "acl_categories": [ + "@fast", + "@connection" + ], + "arity": -2, + "arguments": [ + { + "name": "username", + "type": "string", + "since": "6.0.0", + "optional": true + }, + { + "name": "password", + "type": "string" + } + ], + "command_flags": [ + "noscript", + "loading", + "stale", + "fast", + "no_auth", + "allow_busy" + ] + }, + "BGREWRITEAOF": { + "summary": "Asynchronously rewrite the append-only file", + "since": "1.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 1, + "command_flags": [ + "admin", + "noscript", + "no_async_loading" + ] + }, + "BGSAVE": { + "summary": "Asynchronously save the dataset to disk", + "since": "1.0.0", + "group": "server", + "complexity": "O(1)", + "history": [ + [ + "3.2.2", + "Added the `SCHEDULE` option." + ] + ], + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -1, + "arguments": [ + { + "name": "schedule", + "type": "pure-token", + "token": "SCHEDULE", + "since": "3.2.2", + "optional": true + } + ], + "command_flags": [ + "admin", + "noscript", + "no_async_loading" + ] + }, + "BITCOUNT": { + "summary": "Count set bits in a string", + "since": "2.6.0", + "group": "bitmap", + "complexity": "O(N)", + "history": [ + [ + "7.0.0", + "Added the `BYTE|BIT` option." + ] + ], + "acl_categories": [ + "@read", + "@bitmap", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "index", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "start", + "type": "integer" + }, + { + "name": "end", + "type": "integer" + }, + { + "name": "index_unit", + "type": "oneof", + "since": "7.0.0", + "optional": true, + "arguments": [ + { + "name": "byte", + "type": "pure-token", + "token": "BYTE" + }, + { + "name": "bit", + "type": "pure-token", + "token": "BIT" + } + ] + } + ] + } + ], + "command_flags": [ + "readonly" + ] + }, + "BITFIELD": { + "summary": "Perform arbitrary bitfield integer operations on strings", + "since": "3.2.0", + "group": "bitmap", + "complexity": "O(1) for each subcommand specified", + "acl_categories": [ + "@write", + "@bitmap", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "notes": "This command allows both access and modification of the key", + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true, + "variable_flags": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "operation", + "type": "oneof", + "multiple": true, + "arguments": [ + { + "name": "encoding_offset", + "type": "block", + "token": "GET", + "arguments": [ + { + "name": "encoding", + "type": "string" + }, + { + "name": "offset", + "type": "integer" + } + ] + }, + { + "name": "write", + "type": "block", + "arguments": [ + { + "name": "wrap_sat_fail", + "type": "oneof", + "token": "OVERFLOW", + "optional": true, + "arguments": [ + { + "name": "wrap", + "type": "pure-token", + "token": "WRAP" + }, + { + "name": "sat", + "type": "pure-token", + "token": "SAT" + }, + { + "name": "fail", + "type": "pure-token", + "token": "FAIL" + } + ] + }, + { + "name": "write_operation", + "type": "oneof", + "arguments": [ + { + "name": "encoding_offset_value", + "type": "block", + "token": "SET", + "arguments": [ + { + "name": "encoding", + "type": "string" + }, + { + "name": "offset", + "type": "integer" + }, + { + "name": "value", + "type": "integer" + } + ] + }, + { + "name": "encoding_offset_increment", + "type": "block", + "token": "INCRBY", + "arguments": [ + { + "name": "encoding", + "type": "string" + }, + { + "name": "offset", + "type": "integer" + }, + { + "name": "increment", + "type": "integer" + } + ] + } + ] + } + ] + } + ] + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "BITFIELD_RO": { + "summary": "Perform arbitrary bitfield integer operations on strings. Read-only variant of BITFIELD", + "since": "6.0.0", + "group": "bitmap", + "complexity": "O(1) for each subcommand specified", + "acl_categories": [ + "@read", + "@bitmap", + "@fast" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "encoding_offset", + "type": "block", + "token": "GET", + "multiple": true, + "multiple_token": true, + "arguments": [ + { + "name": "encoding", + "type": "string" + }, + { + "name": "offset", + "type": "integer" + } + ] + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "BITOP": { + "summary": "Perform bitwise operations between strings", + "since": "2.6.0", + "group": "bitmap", + "complexity": "O(N)", + "acl_categories": [ + "@write", + "@bitmap", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 3 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "operation", + "type": "string" + }, + { + "name": "destkey", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "key", + "type": "key", + "key_spec_index": 1, + "multiple": true + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "BITPOS": { + "summary": "Find first bit set or clear in a string", + "since": "2.8.7", + "group": "bitmap", + "complexity": "O(N)", + "history": [ + [ + "7.0.0", + "Added the `BYTE|BIT` option." + ] + ], + "acl_categories": [ + "@read", + "@bitmap", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "bit", + "type": "integer" + }, + { + "name": "index", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "start", + "type": "integer" + }, + { + "name": "end_index", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "end", + "type": "integer" + }, + { + "name": "index_unit", + "type": "oneof", + "since": "7.0.0", + "optional": true, + "arguments": [ + { + "name": "byte", + "type": "pure-token", + "token": "BYTE" + }, + { + "name": "bit", + "type": "pure-token", + "token": "BIT" + } + ] + } + ] + } + ] + } + ], + "command_flags": [ + "readonly" + ] + }, + "BLMOVE": { + "summary": "Pop an element from a list, push it to another list and return it; or block until one is available", + "since": "6.2.0", + "group": "list", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@list", + "@slow", + "@blocking" + ], + "arity": 6, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "source", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "destination", + "type": "key", + "key_spec_index": 1 + }, + { + "name": "wherefrom", + "type": "oneof", + "arguments": [ + { + "name": "left", + "type": "pure-token", + "token": "LEFT" + }, + { + "name": "right", + "type": "pure-token", + "token": "RIGHT" + } + ] + }, + { + "name": "whereto", + "type": "oneof", + "arguments": [ + { + "name": "left", + "type": "pure-token", + "token": "LEFT" + }, + { + "name": "right", + "type": "pure-token", + "token": "RIGHT" + } + ] + }, + { + "name": "timeout", + "type": "double" + } + ], + "command_flags": [ + "write", + "denyoom", + "noscript", + "blocking" + ] + }, + "BLMPOP": { + "summary": "Pop elements from a list, or block until one is available", + "since": "7.0.0", + "group": "list", + "complexity": "O(N+M) where N is the number of provided keys and M is the number of elements returned.", + "acl_categories": [ + "@write", + "@list", + "@slow", + "@blocking" + ], + "arity": -5, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "timeout", + "type": "double" + }, + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "where", + "type": "oneof", + "arguments": [ + { + "name": "left", + "type": "pure-token", + "token": "LEFT" + }, + { + "name": "right", + "type": "pure-token", + "token": "RIGHT" + } + ] + }, + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + } + ], + "command_flags": [ + "write", + "blocking", + "movablekeys" + ] + }, + "BLPOP": { + "summary": "Remove and get the first element in a list, or block until one is available", + "since": "2.0.0", + "group": "list", + "complexity": "O(N) where N is the number of provided keys.", + "history": [ + [ + "6.0.0", + "`timeout` is interpreted as a double instead of an integer." + ] + ], + "acl_categories": [ + "@write", + "@list", + "@slow", + "@blocking" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -2, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "timeout", + "type": "double" + } + ], + "command_flags": [ + "write", + "noscript", + "blocking" + ] + }, + "BRPOP": { + "summary": "Remove and get the last element in a list, or block until one is available", + "since": "2.0.0", + "group": "list", + "complexity": "O(N) where N is the number of provided keys.", + "history": [ + [ + "6.0.0", + "`timeout` is interpreted as a double instead of an integer." + ] + ], + "acl_categories": [ + "@write", + "@list", + "@slow", + "@blocking" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -2, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "timeout", + "type": "double" + } + ], + "command_flags": [ + "write", + "noscript", + "blocking" + ] + }, + "BRPOPLPUSH": { + "summary": "Pop an element from a list, push it to another list and return it; or block until one is available", + "since": "2.2.0", + "group": "list", + "complexity": "O(1)", + "deprecated_since": "6.2.0", + "replaced_by": "`BLMOVE` with the `RIGHT` and `LEFT` arguments", + "history": [ + [ + "6.0.0", + "`timeout` is interpreted as a double instead of an integer." + ] + ], + "acl_categories": [ + "@write", + "@list", + "@slow", + "@blocking" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "source", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "destination", + "type": "key", + "key_spec_index": 1 + }, + { + "name": "timeout", + "type": "double" + } + ], + "command_flags": [ + "write", + "denyoom", + "noscript", + "blocking" + ], + "doc_flags": [ + "deprecated" + ] + }, + "BZMPOP": { + "summary": "Remove and return members with scores in a sorted set or block until one is available", + "since": "7.0.0", + "group": "sorted-set", + "complexity": "O(K) + O(N*log(M)) where K is the number of provided keys, N being the number of elements in the sorted set, and M being the number of elements popped.", + "acl_categories": [ + "@write", + "@sortedset", + "@slow", + "@blocking" + ], + "arity": -5, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "timeout", + "type": "double" + }, + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "where", + "type": "oneof", + "arguments": [ + { + "name": "min", + "type": "pure-token", + "token": "MIN" + }, + { + "name": "max", + "type": "pure-token", + "token": "MAX" + } + ] + }, + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + } + ], + "command_flags": [ + "write", + "blocking", + "movablekeys" + ] + }, + "BZPOPMAX": { + "summary": "Remove and return the member with the highest score from one or more sorted sets, or block until one is available", + "since": "5.0.0", + "group": "sorted-set", + "complexity": "O(log(N)) with N being the number of elements in the sorted set.", + "history": [ + [ + "6.0.0", + "`timeout` is interpreted as a double instead of an integer." + ] + ], + "acl_categories": [ + "@write", + "@sortedset", + "@fast", + "@blocking" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -2, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "timeout", + "type": "double" + } + ], + "command_flags": [ + "write", + "noscript", + "blocking", + "fast" + ] + }, + "BZPOPMIN": { + "summary": "Remove and return the member with the lowest score from one or more sorted sets, or block until one is available", + "since": "5.0.0", + "group": "sorted-set", + "complexity": "O(log(N)) with N being the number of elements in the sorted set.", + "history": [ + [ + "6.0.0", + "`timeout` is interpreted as a double instead of an integer." + ] + ], + "acl_categories": [ + "@write", + "@sortedset", + "@fast", + "@blocking" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -2, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "timeout", + "type": "double" + } + ], + "command_flags": [ + "write", + "noscript", + "blocking", + "fast" + ] + }, + "CLIENT": { + "summary": "A container for client connection commands", + "since": "2.4.0", + "group": "connection", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "CLIENT CACHING": { + "summary": "Instruct the server about tracking or not keys in the next request", + "since": "6.0.0", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": 3, + "arguments": [ + { + "name": "mode", + "type": "oneof", + "arguments": [ + { + "name": "yes", + "type": "pure-token", + "token": "YES" + }, + { + "name": "no", + "type": "pure-token", + "token": "NO" + } + ] + } + ], + "command_flags": [ + "noscript", + "loading", + "stale" + ] + }, + "CLIENT GETNAME": { + "summary": "Get the current connection name", + "since": "2.6.9", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": 2, + "command_flags": [ + "noscript", + "loading", + "stale" + ] + }, + "CLIENT GETREDIR": { + "summary": "Get tracking notifications redirection client ID if any", + "since": "6.0.0", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": 2, + "command_flags": [ + "noscript", + "loading", + "stale" + ] + }, + "CLIENT HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "5.0.0", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "CLIENT ID": { + "summary": "Returns the client ID for the current connection", + "since": "5.0.0", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": 2, + "command_flags": [ + "noscript", + "loading", + "stale" + ] + }, + "CLIENT INFO": { + "summary": "Returns information about the current client connection.", + "since": "6.2.0", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": 2, + "command_flags": [ + "noscript", + "loading", + "stale" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLIENT KILL": { + "summary": "Kill the connection of a client", + "since": "2.4.0", + "group": "connection", + "complexity": "O(N) where N is the number of client connections", + "history": [ + [ + "2.8.12", + "Added new filter format." + ], + [ + "2.8.12", + "`ID` option." + ], + [ + "3.2.0", + "Added `master` type in for `TYPE` option." + ], + [ + "5.0.0", + "Replaced `slave` `TYPE` with `replica`. `slave` still supported for backward compatibility." + ], + [ + "6.2.0", + "`LADDR` option." + ] + ], + "acl_categories": [ + "@admin", + "@slow", + "@dangerous", + "@connection" + ], + "arity": -3, + "arguments": [ + { + "name": "ip:port", + "type": "string", + "optional": true + }, + { + "name": "client-id", + "type": "integer", + "token": "ID", + "since": "2.8.12", + "optional": true + }, + { + "name": "normal_master_slave_pubsub", + "type": "oneof", + "token": "TYPE", + "since": "2.8.12", + "optional": true, + "arguments": [ + { + "name": "normal", + "type": "pure-token", + "token": "NORMAL" + }, + { + "name": "master", + "type": "pure-token", + "token": "MASTER", + "since": "3.2.0" + }, + { + "name": "slave", + "type": "pure-token", + "token": "SLAVE" + }, + { + "name": "replica", + "type": "pure-token", + "token": "REPLICA", + "since": "5.0.0" + }, + { + "name": "pubsub", + "type": "pure-token", + "token": "PUBSUB" + } + ] + }, + { + "name": "username", + "type": "string", + "token": "USER", + "optional": true + }, + { + "name": "ip:port", + "type": "string", + "token": "ADDR", + "optional": true + }, + { + "name": "ip:port", + "type": "string", + "token": "LADDR", + "since": "6.2.0", + "optional": true + }, + { + "name": "yes/no", + "type": "string", + "token": "SKIPME", + "optional": true + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "CLIENT LIST": { + "summary": "Get the list of client connections", + "since": "2.4.0", + "group": "connection", + "complexity": "O(N) where N is the number of client connections", + "history": [ + [ + "2.8.12", + "Added unique client `id` field." + ], + [ + "5.0.0", + "Added optional `TYPE` filter." + ], + [ + "6.2.0", + "Added `laddr` field and the optional `ID` filter." + ] + ], + "acl_categories": [ + "@admin", + "@slow", + "@dangerous", + "@connection" + ], + "arity": -2, + "arguments": [ + { + "name": "normal_master_replica_pubsub", + "type": "oneof", + "token": "TYPE", + "since": "5.0.0", + "optional": true, + "arguments": [ + { + "name": "normal", + "type": "pure-token", + "token": "NORMAL" + }, + { + "name": "master", + "type": "pure-token", + "token": "MASTER" + }, + { + "name": "replica", + "type": "pure-token", + "token": "REPLICA" + }, + { + "name": "pubsub", + "type": "pure-token", + "token": "PUBSUB" + } + ] + }, + { + "name": "id", + "type": "block", + "token": "ID", + "since": "6.2.0", + "optional": true, + "arguments": [ + { + "name": "client-id", + "type": "integer", + "multiple": true + } + ] + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLIENT NO-EVICT": { + "summary": "Set client eviction mode for the current connection", + "since": "7.0.0", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous", + "@connection" + ], + "arity": 3, + "arguments": [ + { + "name": "enabled", + "type": "oneof", + "arguments": [ + { + "name": "on", + "type": "pure-token", + "token": "ON" + }, + { + "name": "off", + "type": "pure-token", + "token": "OFF" + } + ] + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "CLIENT PAUSE": { + "summary": "Stop processing commands from clients for some time", + "since": "2.9.50", + "group": "connection", + "complexity": "O(1)", + "history": [ + [ + "6.2.0", + "`CLIENT PAUSE WRITE` mode added along with the `mode` option." + ] + ], + "acl_categories": [ + "@admin", + "@slow", + "@dangerous", + "@connection" + ], + "arity": -3, + "arguments": [ + { + "name": "timeout", + "type": "integer" + }, + { + "name": "mode", + "type": "oneof", + "since": "6.2.0", + "optional": true, + "arguments": [ + { + "name": "write", + "type": "pure-token", + "token": "WRITE" + }, + { + "name": "all", + "type": "pure-token", + "token": "ALL" + } + ] + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "CLIENT REPLY": { + "summary": "Instruct the server whether to reply to commands", + "since": "3.2.0", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": 3, + "arguments": [ + { + "name": "on_off_skip", + "type": "oneof", + "arguments": [ + { + "name": "on", + "type": "pure-token", + "token": "ON" + }, + { + "name": "off", + "type": "pure-token", + "token": "OFF" + }, + { + "name": "skip", + "type": "pure-token", + "token": "SKIP" + } + ] + } + ], + "command_flags": [ + "noscript", + "loading", + "stale" + ] + }, + "CLIENT SETNAME": { + "summary": "Set the current connection name", + "since": "2.6.9", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": 3, + "arguments": [ + { + "name": "connection-name", + "type": "string" + } + ], + "command_flags": [ + "noscript", + "loading", + "stale" + ] + }, + "CLIENT TRACKING": { + "summary": "Enable or disable server assisted client side caching support", + "since": "6.0.0", + "group": "connection", + "complexity": "O(1). Some options may introduce additional complexity.", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": -3, + "arguments": [ + { + "name": "status", + "type": "oneof", + "arguments": [ + { + "name": "on", + "type": "pure-token", + "token": "ON" + }, + { + "name": "off", + "type": "pure-token", + "token": "OFF" + } + ] + }, + { + "name": "client-id", + "type": "integer", + "token": "REDIRECT", + "optional": true + }, + { + "name": "prefix", + "type": "string", + "token": "PREFIX", + "optional": true, + "multiple": true, + "multiple_token": true + }, + { + "name": "bcast", + "type": "pure-token", + "token": "BCAST", + "optional": true + }, + { + "name": "optin", + "type": "pure-token", + "token": "OPTIN", + "optional": true + }, + { + "name": "optout", + "type": "pure-token", + "token": "OPTOUT", + "optional": true + }, + { + "name": "noloop", + "type": "pure-token", + "token": "NOLOOP", + "optional": true + } + ], + "command_flags": [ + "noscript", + "loading", + "stale" + ] + }, + "CLIENT TRACKINGINFO": { + "summary": "Return information about server assisted client side caching for the current connection", + "since": "6.2.0", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": 2, + "command_flags": [ + "noscript", + "loading", + "stale" + ] + }, + "CLIENT UNBLOCK": { + "summary": "Unblock a client blocked in a blocking command from a different connection", + "since": "5.0.0", + "group": "connection", + "complexity": "O(log N) where N is the number of client connections", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous", + "@connection" + ], + "arity": -3, + "arguments": [ + { + "name": "client-id", + "type": "integer" + }, + { + "name": "timeout_error", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "timeout", + "type": "pure-token", + "token": "TIMEOUT" + }, + { + "name": "error", + "type": "pure-token", + "token": "ERROR" + } + ] + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "CLIENT UNPAUSE": { + "summary": "Resume processing of clients that were paused", + "since": "6.2.0", + "group": "connection", + "complexity": "O(N) Where N is the number of paused clients", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous", + "@connection" + ], + "arity": 2, + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "CLUSTER": { + "summary": "A container for cluster commands", + "since": "3.0.0", + "group": "cluster", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "CLUSTER ADDSLOTS": { + "summary": "Assign new hash slots to receiving node", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(N) where N is the total number of hash slot arguments", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -3, + "arguments": [ + { + "name": "slot", + "type": "integer", + "multiple": true + } + ], + "command_flags": [ + "admin", + "stale", + "no_async_loading" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER ADDSLOTSRANGE": { + "summary": "Assign new hash slots to receiving node", + "since": "7.0.0", + "group": "cluster", + "complexity": "O(N) where N is the total number of the slots between the start slot and end slot arguments.", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -4, + "arguments": [ + { + "name": "start-slot_end-slot", + "type": "block", + "multiple": true, + "arguments": [ + { + "name": "start-slot", + "type": "integer" + }, + { + "name": "end-slot", + "type": "integer" + } + ] + } + ], + "command_flags": [ + "admin", + "stale", + "no_async_loading" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER BUMPEPOCH": { + "summary": "Advance the cluster config epoch", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "stale", + "no_async_loading" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER COUNT-FAILURE-REPORTS": { + "summary": "Return the number of failure reports active for a given node", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(N) where N is the number of failure reports", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 3, + "arguments": [ + { + "name": "node-id", + "type": "string" + } + ], + "command_flags": [ + "admin", + "stale" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER COUNTKEYSINSLOT": { + "summary": "Return the number of local keys in the specified hash slot", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 3, + "arguments": [ + { + "name": "slot", + "type": "integer" + } + ], + "command_flags": [ + "stale" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER DELSLOTS": { + "summary": "Set hash slots as unbound in receiving node", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(N) where N is the total number of hash slot arguments", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -3, + "arguments": [ + { + "name": "slot", + "type": "integer", + "multiple": true + } + ], + "command_flags": [ + "admin", + "stale", + "no_async_loading" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER DELSLOTSRANGE": { + "summary": "Set hash slots as unbound in receiving node", + "since": "7.0.0", + "group": "cluster", + "complexity": "O(N) where N is the total number of the slots between the start slot and end slot arguments.", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -4, + "arguments": [ + { + "name": "start-slot_end-slot", + "type": "block", + "multiple": true, + "arguments": [ + { + "name": "start-slot", + "type": "integer" + }, + { + "name": "end-slot", + "type": "integer" + } + ] + } + ], + "command_flags": [ + "admin", + "stale", + "no_async_loading" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER FAILOVER": { + "summary": "Forces a replica to perform a manual failover of its master.", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -2, + "arguments": [ + { + "name": "options", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "force", + "type": "pure-token", + "token": "FORCE" + }, + { + "name": "takeover", + "type": "pure-token", + "token": "TAKEOVER" + } + ] + } + ], + "command_flags": [ + "admin", + "stale", + "no_async_loading" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER FLUSHSLOTS": { + "summary": "Delete a node's own slots information", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "stale", + "no_async_loading" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER FORGET": { + "summary": "Remove a node from the nodes table", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 3, + "arguments": [ + { + "name": "node-id", + "type": "string" + } + ], + "command_flags": [ + "admin", + "stale", + "no_async_loading" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER GETKEYSINSLOT": { + "summary": "Return local key names in the specified hash slot", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(log(N)) where N is the number of requested keys", + "acl_categories": [ + "@slow" + ], + "arity": 4, + "arguments": [ + { + "name": "slot", + "type": "integer" + }, + { + "name": "count", + "type": "integer" + } + ], + "command_flags": [ + "stale" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "5.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "CLUSTER INFO": { + "summary": "Provides info about Redis Cluster node state", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "stale" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER KEYSLOT": { + "summary": "Returns the hash slot of the specified key", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(N) where N is the number of bytes in the key", + "acl_categories": [ + "@slow" + ], + "arity": 3, + "arguments": [ + { + "name": "key", + "type": "string" + } + ], + "command_flags": [ + "stale" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER LINKS": { + "summary": "Returns a list of all TCP links to and from peer nodes in cluster", + "since": "7.0.0", + "group": "cluster", + "complexity": "O(N) where N is the total number of Cluster nodes", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "stale" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER MEET": { + "summary": "Force a node cluster to handshake with another node", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "history": [ + [ + "4.0.0", + "Added the optional `cluster_bus_port` argument." + ] + ], + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -4, + "arguments": [ + { + "name": "ip", + "type": "string" + }, + { + "name": "port", + "type": "integer" + }, + { + "name": "cluster_bus_port", + "type": "integer", + "since": "4.0.0", + "optional": true + } + ], + "command_flags": [ + "admin", + "stale", + "no_async_loading" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER MYID": { + "summary": "Return the node id", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "stale" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER NODES": { + "summary": "Get Cluster config for the node", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(N) where N is the total number of Cluster nodes", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "stale" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER REPLICAS": { + "summary": "List replica nodes of the specified master node", + "since": "5.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 3, + "arguments": [ + { + "name": "node-id", + "type": "string" + } + ], + "command_flags": [ + "admin", + "stale" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER REPLICATE": { + "summary": "Reconfigure a node as a replica of the specified master node", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 3, + "arguments": [ + { + "name": "node-id", + "type": "string" + } + ], + "command_flags": [ + "admin", + "stale", + "no_async_loading" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER RESET": { + "summary": "Reset a Redis Cluster node", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(N) where N is the number of known nodes. The command may execute a FLUSHALL as a side effect.", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -2, + "arguments": [ + { + "name": "hard_soft", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "hard", + "type": "pure-token", + "token": "HARD" + }, + { + "name": "soft", + "type": "pure-token", + "token": "SOFT" + } + ] + } + ], + "command_flags": [ + "admin", + "noscript", + "stale" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER SAVECONFIG": { + "summary": "Forces the node to save cluster state on disk", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "stale", + "no_async_loading" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER SET-CONFIG-EPOCH": { + "summary": "Set the configuration epoch in a new node", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 3, + "arguments": [ + { + "name": "config-epoch", + "type": "integer" + } + ], + "command_flags": [ + "admin", + "stale", + "no_async_loading" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER SETSLOT": { + "summary": "Bind a hash slot to a specific node", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -4, + "arguments": [ + { + "name": "slot", + "type": "integer" + }, + { + "name": "subcommand", + "type": "oneof", + "arguments": [ + { + "name": "node-id", + "type": "string", + "token": "IMPORTING" + }, + { + "name": "node-id", + "type": "string", + "token": "MIGRATING" + }, + { + "name": "node-id", + "type": "string", + "token": "NODE" + }, + { + "name": "stable", + "type": "pure-token", + "token": "STABLE" + } + ] + } + ], + "command_flags": [ + "admin", + "stale", + "no_async_loading" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER SHARDS": { + "summary": "Get array of cluster slots to node mappings", + "since": "7.0.0", + "group": "cluster", + "complexity": "O(N) where N is the total number of cluster nodes", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "stale" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER SLAVES": { + "summary": "List replica nodes of the specified master node", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "deprecated_since": "5.0.0", + "replaced_by": "`CLUSTER REPLICAS`", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 3, + "arguments": [ + { + "name": "node-id", + "type": "string" + } + ], + "command_flags": [ + "admin", + "stale" + ], + "doc_flags": [ + "deprecated" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "CLUSTER SLOTS": { + "summary": "Get array of Cluster slot to node mappings", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(N) where N is the total number of Cluster nodes", + "deprecated_since": "7.0.0", + "replaced_by": "`CLUSTER SHARDS`", + "history": [ + [ + "4.0.0", + "Added node IDs." + ], + [ + "7.0.0", + "Added additional networking metadata field." + ] + ], + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "stale" + ], + "doc_flags": [ + "deprecated" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "COMMAND": { + "summary": "Get array of Redis command details", + "since": "2.8.13", + "group": "server", + "complexity": "O(N) where N is the total number of Redis commands", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": -1, + "command_flags": [ + "loading", + "stale" + ], + "hints": [ + "nondeterministic_output_order" + ] + }, + "COMMAND COUNT": { + "summary": "Get total number of Redis commands", + "since": "2.8.13", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "COMMAND DOCS": { + "summary": "Get array of specific Redis command documentation", + "since": "7.0.0", + "group": "server", + "complexity": "O(N) where N is the number of commands to look up", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": -2, + "arguments": [ + { + "name": "command-name", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "loading", + "stale" + ], + "hints": [ + "nondeterministic_output_order" + ] + }, + "COMMAND GETKEYS": { + "summary": "Extract keys given a full Redis command", + "since": "2.8.13", + "group": "server", + "complexity": "O(N) where N is the number of arguments to the command", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": -4, + "command_flags": [ + "loading", + "stale" + ] + }, + "COMMAND GETKEYSANDFLAGS": { + "summary": "Extract keys and access flags given a full Redis command", + "since": "7.0.0", + "group": "server", + "complexity": "O(N) where N is the number of arguments to the command", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": -4, + "command_flags": [ + "loading", + "stale" + ] + }, + "COMMAND HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "5.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "COMMAND INFO": { + "summary": "Get array of specific Redis command details, or all when no argument is given.", + "since": "2.8.13", + "group": "server", + "complexity": "O(N) where N is the number of commands to look up", + "history": [ + [ + "7.0.0", + "Allowed to be called with no argument to get info on all commands." + ] + ], + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": -2, + "arguments": [ + { + "name": "command-name", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "loading", + "stale" + ], + "hints": [ + "nondeterministic_output_order" + ] + }, + "COMMAND LIST": { + "summary": "Get an array of Redis command names", + "since": "7.0.0", + "group": "server", + "complexity": "O(N) where N is the total number of Redis commands", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": -2, + "arguments": [ + { + "name": "filterby", + "type": "oneof", + "token": "FILTERBY", + "optional": true, + "arguments": [ + { + "name": "module-name", + "type": "string", + "token": "MODULE" + }, + { + "name": "category", + "type": "string", + "token": "ACLCAT" + }, + { + "name": "pattern", + "type": "pattern", + "token": "PATTERN" + } + ] + } + ], + "command_flags": [ + "loading", + "stale" + ], + "hints": [ + "nondeterministic_output_order" + ] + }, + "CONFIG": { + "summary": "A container for server configuration commands", + "since": "2.0.0", + "group": "server", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "CONFIG GET": { + "summary": "Get the values of configuration parameters", + "since": "2.0.0", + "group": "server", + "complexity": "O(N) when N is the number of configuration parameters provided", + "history": [ + [ + "7.0.0", + "Added the ability to pass multiple pattern parameters in one call" + ] + ], + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -3, + "arguments": [ + { + "name": "parameter", + "type": "block", + "multiple": true, + "arguments": [ + { + "name": "parameter", + "type": "string" + } + ] + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "CONFIG HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "5.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "CONFIG RESETSTAT": { + "summary": "Reset the stats returned by INFO", + "since": "2.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "CONFIG REWRITE": { + "summary": "Rewrite the configuration file with the in memory configuration", + "since": "2.8.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "CONFIG SET": { + "summary": "Set configuration parameters to the given values", + "since": "2.0.0", + "group": "server", + "complexity": "O(N) when N is the number of configuration parameters provided", + "history": [ + [ + "7.0.0", + "Added the ability to set multiple parameters in one call." + ] + ], + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -4, + "arguments": [ + { + "name": "parameter_value", + "type": "block", + "multiple": true, + "arguments": [ + { + "name": "parameter", + "type": "string" + }, + { + "name": "value", + "type": "string" + } + ] + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ], + "hints": [ + "request_policy:all_nodes", + "response_policy:all_succeeded" + ] + }, + "COPY": { + "summary": "Copy a key", + "since": "6.2.0", + "group": "generic", + "complexity": "O(N) worst case for collections, where N is the number of nested items. O(1) for string values.", + "acl_categories": [ + "@keyspace", + "@write", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + } + ], + "arguments": [ + { + "name": "source", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "destination", + "type": "key", + "key_spec_index": 1 + }, + { + "name": "destination-db", + "type": "integer", + "token": "DB", + "optional": true + }, + { + "name": "replace", + "type": "pure-token", + "token": "REPLACE", + "optional": true + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "DBSIZE": { + "summary": "Return the number of keys in the selected database", + "since": "1.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@keyspace", + "@read", + "@fast" + ], + "arity": 1, + "command_flags": [ + "readonly", + "fast" + ], + "hints": [ + "request_policy:all_shards", + "response_policy:agg_sum" + ] + }, + "DEBUG": { + "summary": "A container for debugging commands", + "since": "1.0.0", + "group": "server", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -2, + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ], + "doc_flags": [ + "syscmd" + ] + }, + "DECR": { + "summary": "Decrement the integer value of a key by one", + "since": "1.0.0", + "group": "string", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@string", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "DECRBY": { + "summary": "Decrement the integer value of a key by the given number", + "since": "1.0.0", + "group": "string", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@string", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "decrement", + "type": "integer" + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "DEL": { + "summary": "Delete a key", + "since": "1.0.0", + "group": "generic", + "complexity": "O(N) where N is the number of keys that will be removed. When a key to remove holds a value other than a string, the individual complexity for this key is O(M) where M is the number of elements in the list, set, sorted set or hash. Removing a single key that holds a string value is O(1).", + "acl_categories": [ + "@keyspace", + "@write", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RM": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + } + ], + "command_flags": [ + "write" + ], + "hints": [ + "request_policy:multi_shard", + "response_policy:agg_sum" + ] + }, + "DISCARD": { + "summary": "Discard all commands issued after MULTI", + "since": "2.0.0", + "group": "transactions", + "complexity": "O(N), when N is the number of queued commands", + "acl_categories": [ + "@fast", + "@transaction" + ], + "arity": 1, + "command_flags": [ + "noscript", + "loading", + "stale", + "fast", + "allow_busy" + ] + }, + "DUMP": { + "summary": "Return a serialized version of the value stored at the specified key.", + "since": "2.6.0", + "group": "generic", + "complexity": "O(1) to access the key and additional O(N*M) to serialize it, where N is the number of Redis objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1*M) where M is small, so simply O(1).", + "acl_categories": [ + "@keyspace", + "@read", + "@slow" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "ECHO": { + "summary": "Echo the given string", + "since": "1.0.0", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@fast", + "@connection" + ], + "arity": 2, + "arguments": [ + { + "name": "message", + "type": "string" + } + ], + "command_flags": [ + "loading", + "stale", + "fast" + ] + }, + "EVAL": { + "summary": "Execute a Lua script server side", + "since": "2.6.0", + "group": "scripting", + "complexity": "Depends on the script that is executed.", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": -3, + "key_specs": [ + { + "notes": "We cannot tell how the keys will be used so we assume the worst, RW and UPDATE", + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "script", + "type": "string" + }, + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "optional": true, + "multiple": true + }, + { + "name": "arg", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "noscript", + "stale", + "skip_monitor", + "no_mandatory_keys", + "movablekeys" + ] + }, + "EVALSHA": { + "summary": "Execute a Lua script server side", + "since": "2.6.0", + "group": "scripting", + "complexity": "Depends on the script that is executed.", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "sha1", + "type": "string" + }, + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "optional": true, + "multiple": true + }, + { + "name": "arg", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "noscript", + "stale", + "skip_monitor", + "no_mandatory_keys", + "movablekeys" + ] + }, + "EVALSHA_RO": { + "summary": "Execute a read-only Lua script server side", + "since": "7.0.0", + "group": "scripting", + "complexity": "Depends on the script that is executed.", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "sha1", + "type": "string" + }, + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "arg", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "readonly", + "noscript", + "stale", + "skip_monitor", + "no_mandatory_keys", + "movablekeys" + ] + }, + "EVAL_RO": { + "summary": "Execute a read-only Lua script server side", + "since": "7.0.0", + "group": "scripting", + "complexity": "Depends on the script that is executed.", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": -3, + "key_specs": [ + { + "notes": "We cannot tell how the keys will be used so we assume the worst, RO and ACCESS", + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "script", + "type": "string" + }, + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "arg", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "readonly", + "noscript", + "stale", + "skip_monitor", + "no_mandatory_keys", + "movablekeys" + ] + }, + "EXEC": { + "summary": "Execute all commands issued after MULTI", + "since": "1.2.0", + "group": "transactions", + "complexity": "Depends on commands in the transaction", + "acl_categories": [ + "@slow", + "@transaction" + ], + "arity": 1, + "command_flags": [ + "noscript", + "loading", + "stale", + "skip_slowlog" + ] + }, + "EXISTS": { + "summary": "Determine if a key exists", + "since": "1.0.0", + "group": "generic", + "complexity": "O(N) where N is the number of keys to check.", + "history": [ + [ + "3.0.3", + "Accepts multiple `key` arguments." + ] + ], + "acl_categories": [ + "@keyspace", + "@read", + "@fast" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + } + ], + "command_flags": [ + "readonly", + "fast" + ], + "hints": [ + "request_policy:multi_shard", + "response_policy:agg_sum" + ] + }, + "EXPIRE": { + "summary": "Set a key's time to live in seconds", + "since": "1.0.0", + "group": "generic", + "complexity": "O(1)", + "history": [ + [ + "7.0.0", + "Added options: `NX`, `XX`, `GT` and `LT`." + ] + ], + "acl_categories": [ + "@keyspace", + "@write", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "seconds", + "type": "integer" + }, + { + "name": "condition", + "type": "oneof", + "since": "7.0.0", + "optional": true, + "arguments": [ + { + "name": "nx", + "type": "pure-token", + "token": "NX" + }, + { + "name": "xx", + "type": "pure-token", + "token": "XX" + }, + { + "name": "gt", + "type": "pure-token", + "token": "GT" + }, + { + "name": "lt", + "type": "pure-token", + "token": "LT" + } + ] + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "EXPIREAT": { + "summary": "Set the expiration for a key as a UNIX timestamp", + "since": "1.2.0", + "group": "generic", + "complexity": "O(1)", + "history": [ + [ + "7.0.0", + "Added options: `NX`, `XX`, `GT` and `LT`." + ] + ], + "acl_categories": [ + "@keyspace", + "@write", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "unix-time-seconds", + "type": "unix-time" + }, + { + "name": "condition", + "type": "oneof", + "since": "7.0.0", + "optional": true, + "arguments": [ + { + "name": "nx", + "type": "pure-token", + "token": "NX" + }, + { + "name": "xx", + "type": "pure-token", + "token": "XX" + }, + { + "name": "gt", + "type": "pure-token", + "token": "GT" + }, + { + "name": "lt", + "type": "pure-token", + "token": "LT" + } + ] + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "EXPIRETIME": { + "summary": "Get the expiration Unix timestamp for a key", + "since": "7.0.0", + "group": "generic", + "complexity": "O(1)", + "acl_categories": [ + "@keyspace", + "@read", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "FAILOVER": { + "summary": "Start a coordinated failover between this server and one of its replicas.", + "since": "6.2.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -1, + "arguments": [ + { + "name": "target", + "type": "block", + "token": "TO", + "optional": true, + "arguments": [ + { + "name": "host", + "type": "string" + }, + { + "name": "port", + "type": "integer" + }, + { + "name": "force", + "type": "pure-token", + "token": "FORCE", + "optional": true + } + ] + }, + { + "name": "abort", + "type": "pure-token", + "token": "ABORT", + "optional": true + }, + { + "name": "milliseconds", + "type": "integer", + "token": "TIMEOUT", + "optional": true + } + ], + "command_flags": [ + "admin", + "noscript", + "stale" + ] + }, + "FCALL": { + "summary": "Invoke a function", + "since": "7.0.0", + "group": "scripting", + "complexity": "Depends on the function that is executed.", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": -3, + "key_specs": [ + { + "notes": "We cannot tell how the keys will be used so we assume the worst, RW and UPDATE", + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "function", + "type": "string" + }, + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "arg", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "noscript", + "stale", + "skip_monitor", + "no_mandatory_keys", + "movablekeys" + ] + }, + "FCALL_RO": { + "summary": "Invoke a read-only function", + "since": "7.0.0", + "group": "scripting", + "complexity": "Depends on the function that is executed.", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": -3, + "key_specs": [ + { + "notes": "We cannot tell how the keys will be used so we assume the worst, RO and ACCESS", + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "function", + "type": "string" + }, + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "arg", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "readonly", + "noscript", + "stale", + "skip_monitor", + "no_mandatory_keys", + "movablekeys" + ] + }, + "FLUSHALL": { + "summary": "Remove all keys from all databases", + "since": "1.0.0", + "group": "server", + "complexity": "O(N) where N is the total number of keys in all databases", + "history": [ + [ + "4.0.0", + "Added the `ASYNC` flushing mode modifier." + ], + [ + "6.2.0", + "Added the `SYNC` flushing mode modifier." + ] + ], + "acl_categories": [ + "@keyspace", + "@write", + "@slow", + "@dangerous" + ], + "arity": -1, + "arguments": [ + { + "name": "async", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "async", + "type": "pure-token", + "token": "ASYNC", + "since": "4.0.0" + }, + { + "name": "sync", + "type": "pure-token", + "token": "SYNC", + "since": "6.2.0" + } + ] + } + ], + "command_flags": [ + "write" + ], + "hints": [ + "request_policy:all_shards", + "response_policy:all_succeeded" + ] + }, + "FLUSHDB": { + "summary": "Remove all keys from the current database", + "since": "1.0.0", + "group": "server", + "complexity": "O(N) where N is the number of keys in the selected database", + "history": [ + [ + "4.0.0", + "Added the `ASYNC` flushing mode modifier." + ], + [ + "6.2.0", + "Added the `SYNC` flushing mode modifier." + ] + ], + "acl_categories": [ + "@keyspace", + "@write", + "@slow", + "@dangerous" + ], + "arity": -1, + "arguments": [ + { + "name": "async", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "async", + "type": "pure-token", + "token": "ASYNC", + "since": "4.0.0" + }, + { + "name": "sync", + "type": "pure-token", + "token": "SYNC", + "since": "6.2.0" + } + ] + } + ], + "command_flags": [ + "write" + ], + "hints": [ + "request_policy:all_shards", + "response_policy:all_succeeded" + ] + }, + "FUNCTION": { + "summary": "A container for function commands", + "since": "7.0.0", + "group": "scripting", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "FUNCTION DELETE": { + "summary": "Delete a function by name", + "since": "7.0.0", + "group": "scripting", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@slow", + "@scripting" + ], + "arity": 3, + "arguments": [ + { + "name": "library-name", + "type": "string" + } + ], + "command_flags": [ + "write", + "noscript" + ], + "hints": [ + "request_policy:all_shards", + "response_policy:all_succeeded" + ] + }, + "FUNCTION DUMP": { + "summary": "Dump all functions into a serialized binary payload", + "since": "7.0.0", + "group": "scripting", + "complexity": "O(N) where N is the number of functions", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": 2, + "command_flags": [ + "noscript" + ] + }, + "FUNCTION FLUSH": { + "summary": "Deleting all functions", + "since": "7.0.0", + "group": "scripting", + "complexity": "O(N) where N is the number of functions deleted", + "acl_categories": [ + "@write", + "@slow", + "@scripting" + ], + "arity": -2, + "arguments": [ + { + "name": "async", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "async", + "type": "pure-token", + "token": "ASYNC" + }, + { + "name": "sync", + "type": "pure-token", + "token": "SYNC" + } + ] + } + ], + "command_flags": [ + "write", + "noscript" + ], + "hints": [ + "request_policy:all_shards", + "response_policy:all_succeeded" + ] + }, + "FUNCTION HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "7.0.0", + "group": "scripting", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "FUNCTION KILL": { + "summary": "Kill the function currently in execution.", + "since": "7.0.0", + "group": "scripting", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": 2, + "command_flags": [ + "noscript", + "allow_busy" + ], + "hints": [ + "request_policy:all_shards", + "response_policy:one_succeeded" + ] + }, + "FUNCTION LIST": { + "summary": "List information about all the functions", + "since": "7.0.0", + "group": "scripting", + "complexity": "O(N) where N is the number of functions", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": -2, + "arguments": [ + { + "name": "library-name-pattern", + "type": "string", + "token": "LIBRARYNAME", + "optional": true + }, + { + "name": "withcode", + "type": "pure-token", + "token": "WITHCODE", + "optional": true + } + ], + "command_flags": [ + "noscript" + ], + "hints": [ + "nondeterministic_output_order" + ] + }, + "FUNCTION LOAD": { + "summary": "Create a function with the given arguments (name, code, description)", + "since": "7.0.0", + "group": "scripting", + "complexity": "O(1) (considering compilation time is redundant)", + "acl_categories": [ + "@write", + "@slow", + "@scripting" + ], + "arity": -3, + "arguments": [ + { + "name": "replace", + "type": "pure-token", + "token": "REPLACE", + "optional": true + }, + { + "name": "function-code", + "type": "string" + } + ], + "command_flags": [ + "write", + "denyoom", + "noscript" + ], + "hints": [ + "request_policy:all_shards", + "response_policy:all_succeeded" + ] + }, + "FUNCTION RESTORE": { + "summary": "Restore all the functions on the given payload", + "since": "7.0.0", + "group": "scripting", + "complexity": "O(N) where N is the number of functions on the payload", + "acl_categories": [ + "@write", + "@slow", + "@scripting" + ], + "arity": -3, + "arguments": [ + { + "name": "serialized-value", + "type": "string" + }, + { + "name": "policy", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "flush", + "type": "pure-token", + "token": "FLUSH" + }, + { + "name": "append", + "type": "pure-token", + "token": "APPEND" + }, + { + "name": "replace", + "type": "pure-token", + "token": "REPLACE" + } + ] + } + ], + "command_flags": [ + "write", + "denyoom", + "noscript" + ], + "hints": [ + "request_policy:all_shards", + "response_policy:all_succeeded" + ] + }, + "FUNCTION STATS": { + "summary": "Return information about the function currently running (name, description, duration)", + "since": "7.0.0", + "group": "scripting", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": 2, + "command_flags": [ + "noscript", + "allow_busy" + ], + "hints": [ + "nondeterministic_output", + "request_policy:all_shards", + "response_policy:special" + ] + }, + "GEOADD": { + "summary": "Add one or more geospatial items in the geospatial index represented using a sorted set", + "since": "3.2.0", + "group": "geo", + "complexity": "O(log(N)) for each item added, where N is the number of elements in the sorted set.", + "history": [ + [ + "6.2.0", + "Added the `CH`, `NX` and `XX` options." + ] + ], + "acl_categories": [ + "@write", + "@geo", + "@slow" + ], + "arity": -5, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "condition", + "type": "oneof", + "since": "6.2.0", + "optional": true, + "arguments": [ + { + "name": "nx", + "type": "pure-token", + "token": "NX" + }, + { + "name": "xx", + "type": "pure-token", + "token": "XX" + } + ] + }, + { + "name": "change", + "type": "pure-token", + "token": "CH", + "since": "6.2.0", + "optional": true + }, + { + "name": "longitude_latitude_member", + "type": "block", + "multiple": true, + "arguments": [ + { + "name": "longitude", + "type": "double" + }, + { + "name": "latitude", + "type": "double" + }, + { + "name": "member", + "type": "string" + } + ] + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "GEODIST": { + "summary": "Returns the distance between two members of a geospatial index", + "since": "3.2.0", + "group": "geo", + "complexity": "O(log(N))", + "acl_categories": [ + "@read", + "@geo", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member1", + "type": "string" + }, + { + "name": "member2", + "type": "string" + }, + { + "name": "unit", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "m", + "type": "pure-token", + "token": "M" + }, + { + "name": "km", + "type": "pure-token", + "token": "KM" + }, + { + "name": "ft", + "type": "pure-token", + "token": "FT" + }, + { + "name": "mi", + "type": "pure-token", + "token": "MI" + } + ] + } + ], + "command_flags": [ + "readonly" + ] + }, + "GEOHASH": { + "summary": "Returns members of a geospatial index as standard geohash strings", + "since": "3.2.0", + "group": "geo", + "complexity": "O(log(N)) for each member requested, where N is the number of elements in the sorted set.", + "acl_categories": [ + "@read", + "@geo", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "readonly" + ] + }, + "GEOPOS": { + "summary": "Returns longitude and latitude of members of a geospatial index", + "since": "3.2.0", + "group": "geo", + "complexity": "O(N) where N is the number of members requested.", + "acl_categories": [ + "@read", + "@geo", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "readonly" + ] + }, + "GEORADIUS": { + "summary": "Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point", + "since": "3.2.0", + "group": "geo", + "complexity": "O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.", + "deprecated_since": "6.2.0", + "replaced_by": "`GEOSEARCH` and `GEOSEARCHSTORE` with the `BYRADIUS` argument", + "history": [ + [ + "6.2.0", + "Added the `ANY` option for `COUNT`." + ] + ], + "acl_categories": [ + "@write", + "@geo", + "@slow" + ], + "arity": -6, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + }, + { + "begin_search": { + "type": "keyword", + "spec": { + "keyword": "STORE", + "startfrom": 6 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + }, + { + "begin_search": { + "type": "keyword", + "spec": { + "keyword": "STOREDIST", + "startfrom": 6 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "longitude", + "type": "double" + }, + { + "name": "latitude", + "type": "double" + }, + { + "name": "radius", + "type": "double" + }, + { + "name": "unit", + "type": "oneof", + "arguments": [ + { + "name": "m", + "type": "pure-token", + "token": "M" + }, + { + "name": "km", + "type": "pure-token", + "token": "KM" + }, + { + "name": "ft", + "type": "pure-token", + "token": "FT" + }, + { + "name": "mi", + "type": "pure-token", + "token": "MI" + } + ] + }, + { + "name": "withcoord", + "type": "pure-token", + "token": "WITHCOORD", + "optional": true + }, + { + "name": "withdist", + "type": "pure-token", + "token": "WITHDIST", + "optional": true + }, + { + "name": "withhash", + "type": "pure-token", + "token": "WITHHASH", + "optional": true + }, + { + "name": "count", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "count", + "type": "integer", + "token": "COUNT" + }, + { + "name": "any", + "type": "pure-token", + "token": "ANY", + "since": "6.2.0", + "optional": true + } + ] + }, + { + "name": "order", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "asc", + "type": "pure-token", + "token": "ASC" + }, + { + "name": "desc", + "type": "pure-token", + "token": "DESC" + } + ] + }, + { + "name": "key", + "type": "key", + "key_spec_index": 1, + "token": "STORE", + "optional": true + }, + { + "name": "key", + "type": "key", + "key_spec_index": 2, + "token": "STOREDIST", + "optional": true + } + ], + "command_flags": [ + "write", + "denyoom", + "movablekeys" + ], + "doc_flags": [ + "deprecated" + ] + }, + "GEORADIUSBYMEMBER": { + "summary": "Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member", + "since": "3.2.0", + "group": "geo", + "complexity": "O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.", + "deprecated_since": "6.2.0", + "replaced_by": "`GEOSEARCH` and `GEOSEARCHSTORE` with the `BYRADIUS` and `FROMMEMBER` arguments", + "acl_categories": [ + "@write", + "@geo", + "@slow" + ], + "arity": -5, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + }, + { + "begin_search": { + "type": "keyword", + "spec": { + "keyword": "STORE", + "startfrom": 5 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + }, + { + "begin_search": { + "type": "keyword", + "spec": { + "keyword": "STOREDIST", + "startfrom": 5 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member", + "type": "string" + }, + { + "name": "radius", + "type": "double" + }, + { + "name": "unit", + "type": "oneof", + "arguments": [ + { + "name": "m", + "type": "pure-token", + "token": "M" + }, + { + "name": "km", + "type": "pure-token", + "token": "KM" + }, + { + "name": "ft", + "type": "pure-token", + "token": "FT" + }, + { + "name": "mi", + "type": "pure-token", + "token": "MI" + } + ] + }, + { + "name": "withcoord", + "type": "pure-token", + "token": "WITHCOORD", + "optional": true + }, + { + "name": "withdist", + "type": "pure-token", + "token": "WITHDIST", + "optional": true + }, + { + "name": "withhash", + "type": "pure-token", + "token": "WITHHASH", + "optional": true + }, + { + "name": "count", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "count", + "type": "integer", + "token": "COUNT" + }, + { + "name": "any", + "type": "pure-token", + "token": "ANY", + "optional": true + } + ] + }, + { + "name": "order", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "asc", + "type": "pure-token", + "token": "ASC" + }, + { + "name": "desc", + "type": "pure-token", + "token": "DESC" + } + ] + }, + { + "name": "key", + "type": "key", + "key_spec_index": 1, + "token": "STORE", + "optional": true + }, + { + "name": "key", + "type": "key", + "key_spec_index": 2, + "token": "STOREDIST", + "optional": true + } + ], + "command_flags": [ + "write", + "denyoom", + "movablekeys" + ], + "doc_flags": [ + "deprecated" + ] + }, + "GEORADIUSBYMEMBER_RO": { + "summary": "A read-only variant for GEORADIUSBYMEMBER", + "since": "3.2.10", + "group": "geo", + "complexity": "O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.", + "deprecated_since": "6.2.0", + "replaced_by": "`GEOSEARCH` with the `BYRADIUS` and `FROMMEMBER` arguments", + "acl_categories": [ + "@read", + "@geo", + "@slow" + ], + "arity": -5, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member", + "type": "string" + }, + { + "name": "radius", + "type": "double" + }, + { + "name": "unit", + "type": "oneof", + "arguments": [ + { + "name": "m", + "type": "pure-token", + "token": "M" + }, + { + "name": "km", + "type": "pure-token", + "token": "KM" + }, + { + "name": "ft", + "type": "pure-token", + "token": "FT" + }, + { + "name": "mi", + "type": "pure-token", + "token": "MI" + } + ] + }, + { + "name": "withcoord", + "type": "pure-token", + "token": "WITHCOORD", + "optional": true + }, + { + "name": "withdist", + "type": "pure-token", + "token": "WITHDIST", + "optional": true + }, + { + "name": "withhash", + "type": "pure-token", + "token": "WITHHASH", + "optional": true + }, + { + "name": "count", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "count", + "type": "integer", + "token": "COUNT" + }, + { + "name": "any", + "type": "pure-token", + "token": "ANY", + "optional": true + } + ] + }, + { + "name": "order", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "asc", + "type": "pure-token", + "token": "ASC" + }, + { + "name": "desc", + "type": "pure-token", + "token": "DESC" + } + ] + } + ], + "command_flags": [ + "readonly" + ], + "doc_flags": [ + "deprecated" + ] + }, + "GEORADIUS_RO": { + "summary": "A read-only variant for GEORADIUS", + "since": "3.2.10", + "group": "geo", + "complexity": "O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.", + "deprecated_since": "6.2.0", + "replaced_by": "`GEOSEARCH` with the `BYRADIUS` argument", + "history": [ + [ + "6.2.0", + "Added the `ANY` option for `COUNT`." + ] + ], + "acl_categories": [ + "@read", + "@geo", + "@slow" + ], + "arity": -6, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "longitude", + "type": "double" + }, + { + "name": "latitude", + "type": "double" + }, + { + "name": "radius", + "type": "double" + }, + { + "name": "unit", + "type": "oneof", + "arguments": [ + { + "name": "m", + "type": "pure-token", + "token": "M" + }, + { + "name": "km", + "type": "pure-token", + "token": "KM" + }, + { + "name": "ft", + "type": "pure-token", + "token": "FT" + }, + { + "name": "mi", + "type": "pure-token", + "token": "MI" + } + ] + }, + { + "name": "withcoord", + "type": "pure-token", + "token": "WITHCOORD", + "optional": true + }, + { + "name": "withdist", + "type": "pure-token", + "token": "WITHDIST", + "optional": true + }, + { + "name": "withhash", + "type": "pure-token", + "token": "WITHHASH", + "optional": true + }, + { + "name": "count", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "count", + "type": "integer", + "token": "COUNT" + }, + { + "name": "any", + "type": "pure-token", + "token": "ANY", + "since": "6.2.0", + "optional": true + } + ] + }, + { + "name": "order", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "asc", + "type": "pure-token", + "token": "ASC" + }, + { + "name": "desc", + "type": "pure-token", + "token": "DESC" + } + ] + } + ], + "command_flags": [ + "readonly" + ], + "doc_flags": [ + "deprecated" + ] + }, + "GEOSEARCH": { + "summary": "Query a sorted set representing a geospatial index to fetch members inside an area of a box or a circle.", + "since": "6.2.0", + "group": "geo", + "complexity": "O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape", + "acl_categories": [ + "@read", + "@geo", + "@slow" + ], + "arity": -7, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "from", + "type": "oneof", + "arguments": [ + { + "name": "member", + "type": "string", + "token": "FROMMEMBER" + }, + { + "name": "longitude_latitude", + "type": "block", + "token": "FROMLONLAT", + "arguments": [ + { + "name": "longitude", + "type": "double" + }, + { + "name": "latitude", + "type": "double" + } + ] + } + ] + }, + { + "name": "by", + "type": "oneof", + "arguments": [ + { + "name": "circle", + "type": "block", + "arguments": [ + { + "name": "radius", + "type": "double", + "token": "BYRADIUS" + }, + { + "name": "unit", + "type": "oneof", + "arguments": [ + { + "name": "m", + "type": "pure-token", + "token": "M" + }, + { + "name": "km", + "type": "pure-token", + "token": "KM" + }, + { + "name": "ft", + "type": "pure-token", + "token": "FT" + }, + { + "name": "mi", + "type": "pure-token", + "token": "MI" + } + ] + } + ] + }, + { + "name": "box", + "type": "block", + "arguments": [ + { + "name": "width", + "type": "double", + "token": "BYBOX" + }, + { + "name": "height", + "type": "double" + }, + { + "name": "unit", + "type": "oneof", + "arguments": [ + { + "name": "m", + "type": "pure-token", + "token": "M" + }, + { + "name": "km", + "type": "pure-token", + "token": "KM" + }, + { + "name": "ft", + "type": "pure-token", + "token": "FT" + }, + { + "name": "mi", + "type": "pure-token", + "token": "MI" + } + ] + } + ] + } + ] + }, + { + "name": "order", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "asc", + "type": "pure-token", + "token": "ASC" + }, + { + "name": "desc", + "type": "pure-token", + "token": "DESC" + } + ] + }, + { + "name": "count", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "count", + "type": "integer", + "token": "COUNT" + }, + { + "name": "any", + "type": "pure-token", + "token": "ANY", + "optional": true + } + ] + }, + { + "name": "withcoord", + "type": "pure-token", + "token": "WITHCOORD", + "optional": true + }, + { + "name": "withdist", + "type": "pure-token", + "token": "WITHDIST", + "optional": true + }, + { + "name": "withhash", + "type": "pure-token", + "token": "WITHHASH", + "optional": true + } + ], + "command_flags": [ + "readonly" + ] + }, + "GEOSEARCHSTORE": { + "summary": "Query a sorted set representing a geospatial index to fetch members inside an area of a box or a circle, and store the result in another key.", + "since": "6.2.0", + "group": "geo", + "complexity": "O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape", + "acl_categories": [ + "@write", + "@geo", + "@slow" + ], + "arity": -8, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "destination", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "source", + "type": "key", + "key_spec_index": 1 + }, + { + "name": "from", + "type": "oneof", + "arguments": [ + { + "name": "member", + "type": "string", + "token": "FROMMEMBER" + }, + { + "name": "longitude_latitude", + "type": "block", + "token": "FROMLONLAT", + "arguments": [ + { + "name": "longitude", + "type": "double" + }, + { + "name": "latitude", + "type": "double" + } + ] + } + ] + }, + { + "name": "by", + "type": "oneof", + "arguments": [ + { + "name": "circle", + "type": "block", + "arguments": [ + { + "name": "radius", + "type": "double", + "token": "BYRADIUS" + }, + { + "name": "unit", + "type": "oneof", + "arguments": [ + { + "name": "m", + "type": "pure-token", + "token": "M" + }, + { + "name": "km", + "type": "pure-token", + "token": "KM" + }, + { + "name": "ft", + "type": "pure-token", + "token": "FT" + }, + { + "name": "mi", + "type": "pure-token", + "token": "MI" + } + ] + } + ] + }, + { + "name": "box", + "type": "block", + "arguments": [ + { + "name": "width", + "type": "double", + "token": "BYBOX" + }, + { + "name": "height", + "type": "double" + }, + { + "name": "unit", + "type": "oneof", + "arguments": [ + { + "name": "m", + "type": "pure-token", + "token": "M" + }, + { + "name": "km", + "type": "pure-token", + "token": "KM" + }, + { + "name": "ft", + "type": "pure-token", + "token": "FT" + }, + { + "name": "mi", + "type": "pure-token", + "token": "MI" + } + ] + } + ] + } + ] + }, + { + "name": "order", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "asc", + "type": "pure-token", + "token": "ASC" + }, + { + "name": "desc", + "type": "pure-token", + "token": "DESC" + } + ] + }, + { + "name": "count", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "count", + "type": "integer", + "token": "COUNT" + }, + { + "name": "any", + "type": "pure-token", + "token": "ANY", + "optional": true + } + ] + }, + { + "name": "storedist", + "type": "pure-token", + "token": "STOREDIST", + "optional": true + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "GET": { + "summary": "Get the value of a key", + "since": "1.0.0", + "group": "string", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@string", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "GETBIT": { + "summary": "Returns the bit value at offset in the string value stored at key", + "since": "2.2.0", + "group": "bitmap", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@bitmap", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "offset", + "type": "integer" + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "GETDEL": { + "summary": "Get the value of a key and delete the key", + "since": "6.2.0", + "group": "string", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@string", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "GETEX": { + "summary": "Get the value of a key and optionally set its expiration", + "since": "6.2.0", + "group": "string", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@string", + "@fast" + ], + "arity": -2, + "key_specs": [ + { + "notes": "RW and UPDATE because it changes the TTL", + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "expiration", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "seconds", + "type": "integer", + "token": "EX" + }, + { + "name": "milliseconds", + "type": "integer", + "token": "PX" + }, + { + "name": "unix-time-seconds", + "type": "unix-time", + "token": "EXAT" + }, + { + "name": "unix-time-milliseconds", + "type": "unix-time", + "token": "PXAT" + }, + { + "name": "persist", + "type": "pure-token", + "token": "PERSIST" + } + ] + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "GETRANGE": { + "summary": "Get a substring of the string stored at a key", + "since": "2.4.0", + "group": "string", + "complexity": "O(N) where N is the length of the returned string. The complexity is ultimately determined by the returned length, but because creating a substring from an existing string is very cheap, it can be considered O(1) for small strings.", + "acl_categories": [ + "@read", + "@string", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "start", + "type": "integer" + }, + { + "name": "end", + "type": "integer" + } + ], + "command_flags": [ + "readonly" + ] + }, + "GETSET": { + "summary": "Set the string value of a key and return its old value", + "since": "1.0.0", + "group": "string", + "complexity": "O(1)", + "deprecated_since": "6.2.0", + "replaced_by": "`SET` with the `!GET` argument", + "acl_categories": [ + "@write", + "@string", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "value", + "type": "string" + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ], + "doc_flags": [ + "deprecated" + ] + }, + "HDEL": { + "summary": "Delete one or more hash fields", + "since": "2.0.0", + "group": "hash", + "complexity": "O(N) where N is the number of fields to be removed.", + "history": [ + [ + "2.4.0", + "Accepts multiple `field` arguments." + ] + ], + "acl_categories": [ + "@write", + "@hash", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "field", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "HELLO": { + "summary": "Handshake with Redis", + "since": "6.0.0", + "group": "connection", + "complexity": "O(1)", + "history": [ + [ + "6.2.0", + "`protover` made optional; when called without arguments the command reports the current connection's context." + ] + ], + "acl_categories": [ + "@fast", + "@connection" + ], + "arity": -1, + "arguments": [ + { + "name": "arguments", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "protover", + "type": "integer" + }, + { + "name": "username_password", + "type": "block", + "token": "AUTH", + "optional": true, + "arguments": [ + { + "name": "username", + "type": "string" + }, + { + "name": "password", + "type": "string" + } + ] + }, + { + "name": "clientname", + "type": "string", + "token": "SETNAME", + "optional": true + } + ] + } + ], + "command_flags": [ + "noscript", + "loading", + "stale", + "fast", + "no_auth", + "allow_busy" + ] + }, + "HEXISTS": { + "summary": "Determine if a hash field exists", + "since": "2.0.0", + "group": "hash", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@hash", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "field", + "type": "string" + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "HGET": { + "summary": "Get the value of a hash field", + "since": "2.0.0", + "group": "hash", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@hash", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "field", + "type": "string" + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "HGETALL": { + "summary": "Get all the fields and values in a hash", + "since": "2.0.0", + "group": "hash", + "complexity": "O(N) where N is the size of the hash.", + "acl_categories": [ + "@read", + "@hash", + "@slow" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output_order" + ] + }, + "HINCRBY": { + "summary": "Increment the integer value of a hash field by the given number", + "since": "2.0.0", + "group": "hash", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@hash", + "@fast" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "field", + "type": "string" + }, + { + "name": "increment", + "type": "integer" + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "HINCRBYFLOAT": { + "summary": "Increment the float value of a hash field by the given amount", + "since": "2.6.0", + "group": "hash", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@hash", + "@fast" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "field", + "type": "string" + }, + { + "name": "increment", + "type": "double" + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "HKEYS": { + "summary": "Get all the fields in a hash", + "since": "2.0.0", + "group": "hash", + "complexity": "O(N) where N is the size of the hash.", + "acl_categories": [ + "@read", + "@hash", + "@slow" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output_order" + ] + }, + "HLEN": { + "summary": "Get the number of fields in a hash", + "since": "2.0.0", + "group": "hash", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@hash", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "HMGET": { + "summary": "Get the values of all the given hash fields", + "since": "2.0.0", + "group": "hash", + "complexity": "O(N) where N is the number of fields being requested.", + "acl_categories": [ + "@read", + "@hash", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "field", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "HMSET": { + "summary": "Set multiple hash fields to multiple values", + "since": "2.0.0", + "group": "hash", + "complexity": "O(N) where N is the number of fields being set.", + "deprecated_since": "4.0.0", + "replaced_by": "`HSET` with multiple field-value pairs", + "acl_categories": [ + "@write", + "@hash", + "@fast" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "field_value", + "type": "block", + "multiple": true, + "arguments": [ + { + "name": "field", + "type": "string" + }, + { + "name": "value", + "type": "string" + } + ] + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ], + "doc_flags": [ + "deprecated" + ] + }, + "HRANDFIELD": { + "summary": "Get one or multiple random fields from a hash", + "since": "6.2.0", + "group": "hash", + "complexity": "O(N) where N is the number of fields returned", + "acl_categories": [ + "@read", + "@hash", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "options", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "count", + "type": "integer" + }, + { + "name": "withvalues", + "type": "pure-token", + "token": "WITHVALUES", + "optional": true + } + ] + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "HSCAN": { + "summary": "Incrementally iterate hash fields and associated values", + "since": "2.8.0", + "group": "hash", + "complexity": "O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection..", + "acl_categories": [ + "@read", + "@hash", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "cursor", + "type": "integer" + }, + { + "name": "pattern", + "type": "pattern", + "token": "MATCH", + "optional": true + }, + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "HSET": { + "summary": "Set the string value of a hash field", + "since": "2.0.0", + "group": "hash", + "complexity": "O(1) for each field/value pair added, so O(N) to add N field/value pairs when the command is called with multiple field/value pairs.", + "history": [ + [ + "4.0.0", + "Accepts multiple `field` and `value` arguments." + ] + ], + "acl_categories": [ + "@write", + "@hash", + "@fast" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "field_value", + "type": "block", + "multiple": true, + "arguments": [ + { + "name": "field", + "type": "string" + }, + { + "name": "value", + "type": "string" + } + ] + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "HSETNX": { + "summary": "Set the value of a hash field, only if the field does not exist", + "since": "2.0.0", + "group": "hash", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@hash", + "@fast" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "field", + "type": "string" + }, + { + "name": "value", + "type": "string" + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "HSTRLEN": { + "summary": "Get the length of the value of a hash field", + "since": "3.2.0", + "group": "hash", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@hash", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "field", + "type": "string" + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "HVALS": { + "summary": "Get all the values in a hash", + "since": "2.0.0", + "group": "hash", + "complexity": "O(N) where N is the size of the hash.", + "acl_categories": [ + "@read", + "@hash", + "@slow" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output_order" + ] + }, + "INCR": { + "summary": "Increment the integer value of a key by one", + "since": "1.0.0", + "group": "string", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@string", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "INCRBY": { + "summary": "Increment the integer value of a key by the given amount", + "since": "1.0.0", + "group": "string", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@string", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "increment", + "type": "integer" + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "INCRBYFLOAT": { + "summary": "Increment the float value of a key by the given amount", + "since": "2.6.0", + "group": "string", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@string", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "increment", + "type": "double" + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "INFO": { + "summary": "Get information and statistics about the server", + "since": "1.0.0", + "group": "server", + "complexity": "O(1)", + "history": [ + [ + "7.0.0", + "Added support for taking multiple section arguments." + ] + ], + "acl_categories": [ + "@slow", + "@dangerous" + ], + "arity": -1, + "arguments": [ + { + "name": "section", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "loading", + "stale" + ], + "hints": [ + "nondeterministic_output", + "request_policy:all_shards", + "response_policy:special" + ] + }, + "KEYS": { + "summary": "Find all keys matching the given pattern", + "since": "1.0.0", + "group": "generic", + "complexity": "O(N) with N being the number of keys in the database, under the assumption that the key names in the database and the given pattern have limited length.", + "acl_categories": [ + "@keyspace", + "@read", + "@slow", + "@dangerous" + ], + "arity": 2, + "arguments": [ + { + "name": "pattern", + "type": "pattern" + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "request_policy:all_shards", + "nondeterministic_output_order" + ] + }, + "LASTSAVE": { + "summary": "Get the UNIX time stamp of the last successful save to disk", + "since": "1.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@fast", + "@dangerous" + ], + "arity": 1, + "command_flags": [ + "loading", + "stale", + "fast" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "LATENCY": { + "summary": "A container for latency diagnostics commands", + "since": "2.8.13", + "group": "server", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "LATENCY DOCTOR": { + "summary": "Return a human readable latency analysis report.", + "since": "2.8.13", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ], + "hints": [ + "nondeterministic_output", + "request_policy:all_nodes", + "response_policy:special" + ] + }, + "LATENCY GRAPH": { + "summary": "Return a latency graph for the event.", + "since": "2.8.13", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 3, + "arguments": [ + { + "name": "event", + "type": "string" + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ], + "hints": [ + "nondeterministic_output", + "request_policy:all_nodes", + "response_policy:special" + ] + }, + "LATENCY HELP": { + "summary": "Show helpful text about the different subcommands.", + "since": "2.8.13", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "LATENCY HISTOGRAM": { + "summary": "Return the cumulative distribution of latencies of a subset of commands or all.", + "since": "7.0.0", + "group": "server", + "complexity": "O(N) where N is the number of commands with latency information being retrieved.", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -2, + "arguments": [ + { + "name": "command", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ], + "hints": [ + "nondeterministic_output", + "request_policy:all_nodes", + "response_policy:special" + ] + }, + "LATENCY HISTORY": { + "summary": "Return timestamp-latency samples for the event.", + "since": "2.8.13", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 3, + "arguments": [ + { + "name": "event", + "type": "string" + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ], + "hints": [ + "nondeterministic_output", + "request_policy:all_nodes", + "response_policy:special" + ] + }, + "LATENCY LATEST": { + "summary": "Return the latest latency samples for all events.", + "since": "2.8.13", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ], + "hints": [ + "nondeterministic_output", + "request_policy:all_nodes", + "response_policy:special" + ] + }, + "LATENCY RESET": { + "summary": "Reset latency data for one or more events.", + "since": "2.8.13", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -2, + "arguments": [ + { + "name": "event", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ], + "hints": [ + "request_policy:all_nodes", + "response_policy:all_succeeded" + ] + }, + "LCS": { + "summary": "Find longest common substring", + "since": "7.0.0", + "group": "string", + "complexity": "O(N*M) where N and M are the lengths of s1 and s2, respectively", + "acl_categories": [ + "@read", + "@string", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 1, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key1", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "key2", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "len", + "type": "pure-token", + "token": "LEN", + "optional": true + }, + { + "name": "idx", + "type": "pure-token", + "token": "IDX", + "optional": true + }, + { + "name": "len", + "type": "integer", + "token": "MINMATCHLEN", + "optional": true + }, + { + "name": "withmatchlen", + "type": "pure-token", + "token": "WITHMATCHLEN", + "optional": true + } + ], + "command_flags": [ + "readonly" + ] + }, + "LINDEX": { + "summary": "Get an element from a list by its index", + "since": "1.0.0", + "group": "list", + "complexity": "O(N) where N is the number of elements to traverse to get to the element at index. This makes asking for the first or the last element of the list O(1).", + "acl_categories": [ + "@read", + "@list", + "@slow" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "index", + "type": "integer" + } + ], + "command_flags": [ + "readonly" + ] + }, + "LINSERT": { + "summary": "Insert an element before or after another element in a list", + "since": "2.2.0", + "group": "list", + "complexity": "O(N) where N is the number of elements to traverse before seeing the value pivot. This means that inserting somewhere on the left end on the list (head) can be considered O(1) and inserting somewhere on the right end (tail) is O(N).", + "acl_categories": [ + "@write", + "@list", + "@slow" + ], + "arity": 5, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "where", + "type": "oneof", + "arguments": [ + { + "name": "before", + "type": "pure-token", + "token": "BEFORE" + }, + { + "name": "after", + "type": "pure-token", + "token": "AFTER" + } + ] + }, + { + "name": "pivot", + "type": "string" + }, + { + "name": "element", + "type": "string" + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "LLEN": { + "summary": "Get the length of a list", + "since": "1.0.0", + "group": "list", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@list", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "LMOVE": { + "summary": "Pop an element from a list, push it to another list and return it", + "since": "6.2.0", + "group": "list", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@list", + "@slow" + ], + "arity": 5, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "source", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "destination", + "type": "key", + "key_spec_index": 1 + }, + { + "name": "wherefrom", + "type": "oneof", + "arguments": [ + { + "name": "left", + "type": "pure-token", + "token": "LEFT" + }, + { + "name": "right", + "type": "pure-token", + "token": "RIGHT" + } + ] + }, + { + "name": "whereto", + "type": "oneof", + "arguments": [ + { + "name": "left", + "type": "pure-token", + "token": "LEFT" + }, + { + "name": "right", + "type": "pure-token", + "token": "RIGHT" + } + ] + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "LMPOP": { + "summary": "Pop elements from a list", + "since": "7.0.0", + "group": "list", + "complexity": "O(N+M) where N is the number of provided keys and M is the number of elements returned.", + "acl_categories": [ + "@write", + "@list", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "where", + "type": "oneof", + "arguments": [ + { + "name": "left", + "type": "pure-token", + "token": "LEFT" + }, + { + "name": "right", + "type": "pure-token", + "token": "RIGHT" + } + ] + }, + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + } + ], + "command_flags": [ + "write", + "movablekeys" + ] + }, + "LOLWUT": { + "summary": "Display some computer art and the Redis version", + "since": "5.0.0", + "group": "server", + "acl_categories": [ + "@read", + "@fast" + ], + "arity": -1, + "arguments": [ + { + "name": "version", + "type": "integer", + "token": "VERSION", + "optional": true + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "LPOP": { + "summary": "Remove and get the first elements in a list", + "since": "1.0.0", + "group": "list", + "complexity": "O(N) where N is the number of elements returned", + "history": [ + [ + "6.2.0", + "Added the `count` argument." + ] + ], + "acl_categories": [ + "@write", + "@list", + "@fast" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "count", + "type": "integer", + "since": "6.2.0", + "optional": true + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "LPOS": { + "summary": "Return the index of matching elements on a list", + "since": "6.0.6", + "group": "list", + "complexity": "O(N) where N is the number of elements in the list, for the average case. When searching for elements near the head or the tail of the list, or when the MAXLEN option is provided, the command may run in constant time.", + "acl_categories": [ + "@read", + "@list", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "element", + "type": "string" + }, + { + "name": "rank", + "type": "integer", + "token": "RANK", + "optional": true + }, + { + "name": "num-matches", + "type": "integer", + "token": "COUNT", + "optional": true + }, + { + "name": "len", + "type": "integer", + "token": "MAXLEN", + "optional": true + } + ], + "command_flags": [ + "readonly" + ] + }, + "LPUSH": { + "summary": "Prepend one or multiple elements to a list", + "since": "1.0.0", + "group": "list", + "complexity": "O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.", + "history": [ + [ + "2.4.0", + "Accepts multiple `element` arguments." + ] + ], + "acl_categories": [ + "@write", + "@list", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "element", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "LPUSHX": { + "summary": "Prepend an element to a list, only if the list exists", + "since": "2.2.0", + "group": "list", + "complexity": "O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.", + "history": [ + [ + "4.0.0", + "Accepts multiple `element` arguments." + ] + ], + "acl_categories": [ + "@write", + "@list", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "element", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "LRANGE": { + "summary": "Get a range of elements from a list", + "since": "1.0.0", + "group": "list", + "complexity": "O(S+N) where S is the distance of start offset from HEAD for small lists, from nearest end (HEAD or TAIL) for large lists; and N is the number of elements in the specified range.", + "acl_categories": [ + "@read", + "@list", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "start", + "type": "integer" + }, + { + "name": "stop", + "type": "integer" + } + ], + "command_flags": [ + "readonly" + ] + }, + "LREM": { + "summary": "Remove elements from a list", + "since": "1.0.0", + "group": "list", + "complexity": "O(N+M) where N is the length of the list and M is the number of elements removed.", + "acl_categories": [ + "@write", + "@list", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "count", + "type": "integer" + }, + { + "name": "element", + "type": "string" + } + ], + "command_flags": [ + "write" + ] + }, + "LSET": { + "summary": "Set the value of an element in a list by its index", + "since": "1.0.0", + "group": "list", + "complexity": "O(N) where N is the length of the list. Setting either the first or the last element of the list is O(1).", + "acl_categories": [ + "@write", + "@list", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "index", + "type": "integer" + }, + { + "name": "element", + "type": "string" + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "LTRIM": { + "summary": "Trim a list to the specified range", + "since": "1.0.0", + "group": "list", + "complexity": "O(N) where N is the number of elements to be removed by the operation.", + "acl_categories": [ + "@write", + "@list", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "start", + "type": "integer" + }, + { + "name": "stop", + "type": "integer" + } + ], + "command_flags": [ + "write" + ] + }, + "MEMORY": { + "summary": "A container for memory diagnostics commands", + "since": "4.0.0", + "group": "server", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "MEMORY DOCTOR": { + "summary": "Outputs memory problems report", + "since": "4.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "hints": [ + "nondeterministic_output", + "request_policy:all_shards", + "response_policy:special" + ] + }, + "MEMORY HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "4.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "MEMORY MALLOC-STATS": { + "summary": "Show allocator internal stats", + "since": "4.0.0", + "group": "server", + "complexity": "Depends on how much memory is allocated, could be slow", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "hints": [ + "nondeterministic_output", + "request_policy:all_shards", + "response_policy:special" + ] + }, + "MEMORY PURGE": { + "summary": "Ask the allocator to release memory", + "since": "4.0.0", + "group": "server", + "complexity": "Depends on how much memory is allocated, could be slow", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "hints": [ + "request_policy:all_shards", + "response_policy:all_succeeded" + ] + }, + "MEMORY STATS": { + "summary": "Show memory usage details", + "since": "4.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "hints": [ + "nondeterministic_output", + "request_policy:all_shards", + "response_policy:special" + ] + }, + "MEMORY USAGE": { + "summary": "Estimate the memory usage of a key", + "since": "4.0.0", + "group": "server", + "complexity": "O(N) where N is the number of samples.", + "acl_categories": [ + "@read", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "count", + "type": "integer", + "token": "SAMPLES", + "optional": true + } + ], + "command_flags": [ + "readonly" + ] + }, + "MGET": { + "summary": "Get the values of all the given keys", + "since": "1.0.0", + "group": "string", + "complexity": "O(N) where N is the number of keys to retrieve.", + "acl_categories": [ + "@read", + "@string", + "@fast" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + } + ], + "command_flags": [ + "readonly", + "fast" + ], + "hints": [ + "request_policy:multi_shard" + ] + }, + "MIGRATE": { + "summary": "Atomically transfer a key from a Redis instance to another one.", + "since": "2.6.0", + "group": "generic", + "complexity": "This command actually executes a DUMP+DEL in the source instance, and a RESTORE in the target instance. See the pages of these commands for time complexity. Also an O(N) data transfer between the two instances is performed.", + "history": [ + [ + "3.0.0", + "Added the `COPY` and `REPLACE` options." + ], + [ + "3.0.6", + "Added the `KEYS` option." + ], + [ + "4.0.7", + "Added the `AUTH` option." + ], + [ + "6.0.0", + "Added the `AUTH2` option." + ] + ], + "acl_categories": [ + "@keyspace", + "@write", + "@slow", + "@dangerous" + ], + "arity": -6, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 3 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + }, + { + "begin_search": { + "type": "keyword", + "spec": { + "keyword": "KEYS", + "startfrom": -2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true, + "incomplete": true + } + ], + "arguments": [ + { + "name": "host", + "type": "string" + }, + { + "name": "port", + "type": "integer" + }, + { + "name": "key_or_empty_string", + "type": "oneof", + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "empty_string", + "type": "pure-token", + "token": "" + } + ] + }, + { + "name": "destination-db", + "type": "integer" + }, + { + "name": "timeout", + "type": "integer" + }, + { + "name": "copy", + "type": "pure-token", + "token": "COPY", + "since": "3.0.0", + "optional": true + }, + { + "name": "replace", + "type": "pure-token", + "token": "REPLACE", + "since": "3.0.0", + "optional": true + }, + { + "name": "authentication", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "password", + "type": "string", + "token": "AUTH", + "since": "4.0.7", + "optional": true + }, + { + "name": "username_password", + "type": "block", + "token": "AUTH2", + "since": "6.0.0", + "optional": true, + "arguments": [ + { + "name": "username", + "type": "string" + }, + { + "name": "password", + "type": "string" + } + ] + } + ] + }, + { + "name": "key", + "type": "key", + "key_spec_index": 1, + "token": "KEYS", + "since": "3.0.6", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "write", + "movablekeys" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "MODULE": { + "summary": "A container for module commands", + "since": "4.0.0", + "group": "server", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "MODULE HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "5.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "MODULE LIST": { + "summary": "List all modules loaded by the server", + "since": "4.0.0", + "group": "server", + "complexity": "O(N) where N is the number of loaded modules.", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "noscript" + ], + "hints": [ + "nondeterministic_output_order" + ] + }, + "MODULE LOAD": { + "summary": "Load a module", + "since": "4.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -3, + "arguments": [ + { + "name": "path", + "type": "string" + }, + { + "name": "arg", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "admin", + "noscript", + "no_async_loading" + ] + }, + "MODULE LOADEX": { + "summary": "Load a module with extended parameters", + "since": "7.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -3, + "arguments": [ + { + "name": "path", + "type": "string" + }, + { + "name": "configs", + "type": "block", + "token": "CONFIG", + "optional": true, + "multiple": true, + "multiple_token": true, + "arguments": [ + { + "name": "name", + "type": "string" + }, + { + "name": "value", + "type": "string" + } + ] + }, + { + "name": "args", + "type": "block", + "token": "ARGS", + "optional": true, + "multiple": true, + "arguments": [ + { + "name": "arg", + "type": "string" + } + ] + } + ], + "command_flags": [ + "admin", + "noscript", + "no_async_loading" + ] + }, + "MODULE UNLOAD": { + "summary": "Unload a module", + "since": "4.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 3, + "arguments": [ + { + "name": "name", + "type": "string" + } + ], + "command_flags": [ + "admin", + "noscript", + "no_async_loading" + ] + }, + "MONITOR": { + "summary": "Listen for all requests received by the server in real time", + "since": "1.0.0", + "group": "server", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 1, + "command_flags": [ + "admin", + "noscript", + "loading", + "stale" + ] + }, + "MOVE": { + "summary": "Move a key to another database", + "since": "1.0.0", + "group": "generic", + "complexity": "O(1)", + "acl_categories": [ + "@keyspace", + "@write", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "db", + "type": "integer" + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "MSET": { + "summary": "Set multiple keys to multiple values", + "since": "1.0.1", + "group": "string", + "complexity": "O(N) where N is the number of keys to set.", + "acl_categories": [ + "@write", + "@string", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 2, + "limit": 0 + } + }, + "OW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key_value", + "type": "block", + "multiple": true, + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "value", + "type": "string" + } + ] + } + ], + "command_flags": [ + "write", + "denyoom" + ], + "hints": [ + "request_policy:multi_shard", + "response_policy:all_succeeded" + ] + }, + "MSETNX": { + "summary": "Set multiple keys to multiple values, only if none of the keys exist", + "since": "1.0.1", + "group": "string", + "complexity": "O(N) where N is the number of keys to set.", + "acl_categories": [ + "@write", + "@string", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 2, + "limit": 0 + } + }, + "OW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key_value", + "type": "block", + "multiple": true, + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "value", + "type": "string" + } + ] + } + ], + "command_flags": [ + "write", + "denyoom" + ], + "hints": [ + "request_policy:multi_shard", + "response_policy:agg_min" + ] + }, + "MULTI": { + "summary": "Mark the start of a transaction block", + "since": "1.2.0", + "group": "transactions", + "complexity": "O(1)", + "acl_categories": [ + "@fast", + "@transaction" + ], + "arity": 1, + "command_flags": [ + "noscript", + "loading", + "stale", + "fast", + "allow_busy" + ] + }, + "OBJECT": { + "summary": "A container for object introspection commands", + "since": "2.2.3", + "group": "generic", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "OBJECT ENCODING": { + "summary": "Inspect the internal encoding of a Redis object", + "since": "2.2.3", + "group": "generic", + "complexity": "O(1)", + "acl_categories": [ + "@keyspace", + "@read", + "@slow" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "OBJECT FREQ": { + "summary": "Get the logarithmic access frequency counter of a Redis object", + "since": "4.0.0", + "group": "generic", + "complexity": "O(1)", + "acl_categories": [ + "@keyspace", + "@read", + "@slow" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "OBJECT HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "6.2.0", + "group": "generic", + "complexity": "O(1)", + "acl_categories": [ + "@keyspace", + "@slow" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "OBJECT IDLETIME": { + "summary": "Get the time since a Redis object was last accessed", + "since": "2.2.3", + "group": "generic", + "complexity": "O(1)", + "acl_categories": [ + "@keyspace", + "@read", + "@slow" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "OBJECT REFCOUNT": { + "summary": "Get the number of references to the value of the key", + "since": "2.2.3", + "group": "generic", + "complexity": "O(1)", + "acl_categories": [ + "@keyspace", + "@read", + "@slow" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "PERSIST": { + "summary": "Remove the expiration from a key", + "since": "2.2.0", + "group": "generic", + "complexity": "O(1)", + "acl_categories": [ + "@keyspace", + "@write", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "PEXPIRE": { + "summary": "Set a key's time to live in milliseconds", + "since": "2.6.0", + "group": "generic", + "complexity": "O(1)", + "history": [ + [ + "7.0.0", + "Added options: `NX`, `XX`, `GT` and `LT`." + ] + ], + "acl_categories": [ + "@keyspace", + "@write", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "milliseconds", + "type": "integer" + }, + { + "name": "condition", + "type": "oneof", + "since": "7.0.0", + "optional": true, + "arguments": [ + { + "name": "nx", + "type": "pure-token", + "token": "NX" + }, + { + "name": "xx", + "type": "pure-token", + "token": "XX" + }, + { + "name": "gt", + "type": "pure-token", + "token": "GT" + }, + { + "name": "lt", + "type": "pure-token", + "token": "LT" + } + ] + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "PEXPIREAT": { + "summary": "Set the expiration for a key as a UNIX timestamp specified in milliseconds", + "since": "2.6.0", + "group": "generic", + "complexity": "O(1)", + "history": [ + [ + "7.0.0", + "Added options: `NX`, `XX`, `GT` and `LT`." + ] + ], + "acl_categories": [ + "@keyspace", + "@write", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "unix-time-milliseconds", + "type": "unix-time" + }, + { + "name": "condition", + "type": "oneof", + "since": "7.0.0", + "optional": true, + "arguments": [ + { + "name": "nx", + "type": "pure-token", + "token": "NX" + }, + { + "name": "xx", + "type": "pure-token", + "token": "XX" + }, + { + "name": "gt", + "type": "pure-token", + "token": "GT" + }, + { + "name": "lt", + "type": "pure-token", + "token": "LT" + } + ] + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "PEXPIRETIME": { + "summary": "Get the expiration Unix timestamp for a key in milliseconds", + "since": "7.0.0", + "group": "generic", + "complexity": "O(1)", + "acl_categories": [ + "@keyspace", + "@read", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "PFADD": { + "summary": "Adds the specified elements to the specified HyperLogLog.", + "since": "2.8.9", + "group": "hyperloglog", + "complexity": "O(1) to add every element.", + "acl_categories": [ + "@write", + "@hyperloglog", + "@fast" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "element", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "PFCOUNT": { + "summary": "Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s).", + "since": "2.8.9", + "group": "hyperloglog", + "complexity": "O(1) with a very small average constant time when called with a single key. O(N) with N being the number of keys, and much bigger constant times, when called with multiple keys.", + "acl_categories": [ + "@read", + "@hyperloglog", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "notes": "RW because it may change the internal representation of the key, and propagate to replicas", + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + } + ], + "command_flags": [ + "readonly" + ] + }, + "PFDEBUG": { + "summary": "Internal commands for debugging HyperLogLog values", + "since": "2.8.9", + "group": "hyperloglog", + "complexity": "N/A", + "acl_categories": [ + "@write", + "@hyperloglog", + "@admin", + "@slow", + "@dangerous" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true + } + ], + "arguments": [ + { + "name": "subcommand", + "type": "string" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "write", + "denyoom", + "admin" + ], + "doc_flags": [ + "syscmd" + ] + }, + "PFMERGE": { + "summary": "Merge N different HyperLogLogs into a single one.", + "since": "2.8.9", + "group": "hyperloglog", + "complexity": "O(N) to merge N HyperLogLogs, but with high constant times.", + "acl_categories": [ + "@write", + "@hyperloglog", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "insert": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "destkey", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "sourcekey", + "type": "key", + "key_spec_index": 1, + "multiple": true + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "PFSELFTEST": { + "summary": "An internal command for testing HyperLogLog values", + "since": "2.8.9", + "group": "hyperloglog", + "complexity": "N/A", + "acl_categories": [ + "@hyperloglog", + "@admin", + "@slow", + "@dangerous" + ], + "arity": 1, + "command_flags": [ + "admin" + ], + "doc_flags": [ + "syscmd" + ] + }, + "PING": { + "summary": "Ping the server", + "since": "1.0.0", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@fast", + "@connection" + ], + "arity": -1, + "arguments": [ + { + "name": "message", + "type": "string", + "optional": true + } + ], + "command_flags": [ + "fast" + ], + "hints": [ + "request_policy:all_shards", + "response_policy:all_succeeded" + ] + }, + "PSETEX": { + "summary": "Set the value and expiration in milliseconds of a key", + "since": "2.6.0", + "group": "string", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@string", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "milliseconds", + "type": "integer" + }, + { + "name": "value", + "type": "string" + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "PSUBSCRIBE": { + "summary": "Listen for messages published to channels matching the given patterns", + "since": "2.0.0", + "group": "pubsub", + "complexity": "O(N) where N is the number of patterns the client is already subscribed to.", + "acl_categories": [ + "@pubsub", + "@slow" + ], + "arity": -2, + "arguments": [ + { + "name": "pattern", + "type": "block", + "multiple": true, + "arguments": [ + { + "name": "pattern", + "type": "pattern" + } + ] + } + ], + "command_flags": [ + "pubsub", + "noscript", + "loading", + "stale" + ] + }, + "PSYNC": { + "summary": "Internal command used for replication", + "since": "2.8.0", + "group": "server", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -3, + "arguments": [ + { + "name": "replicationid", + "type": "string" + }, + { + "name": "offset", + "type": "integer" + } + ], + "command_flags": [ + "admin", + "noscript", + "no_async_loading", + "no_multi" + ] + }, + "PTTL": { + "summary": "Get the time to live for a key in milliseconds", + "since": "2.6.0", + "group": "generic", + "complexity": "O(1)", + "history": [ + [ + "2.8.0", + "Added the -2 reply." + ] + ], + "acl_categories": [ + "@keyspace", + "@read", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly", + "fast" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "PUBLISH": { + "summary": "Post a message to a channel", + "since": "2.0.0", + "group": "pubsub", + "complexity": "O(N+M) where N is the number of clients subscribed to the receiving channel and M is the total number of subscribed patterns (by any client).", + "acl_categories": [ + "@pubsub", + "@fast" + ], + "arity": 3, + "arguments": [ + { + "name": "channel", + "type": "string" + }, + { + "name": "message", + "type": "string" + } + ], + "command_flags": [ + "pubsub", + "loading", + "stale", + "fast" + ] + }, + "PUBSUB": { + "summary": "A container for Pub/Sub commands", + "since": "2.8.0", + "group": "pubsub", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "PUBSUB CHANNELS": { + "summary": "List active channels", + "since": "2.8.0", + "group": "pubsub", + "complexity": "O(N) where N is the number of active channels, and assuming constant time pattern matching (relatively short channels and patterns)", + "acl_categories": [ + "@pubsub", + "@slow" + ], + "arity": -2, + "arguments": [ + { + "name": "pattern", + "type": "pattern", + "optional": true + } + ], + "command_flags": [ + "pubsub", + "loading", + "stale" + ] + }, + "PUBSUB HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "6.2.0", + "group": "pubsub", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "PUBSUB NUMPAT": { + "summary": "Get the count of unique patterns pattern subscriptions", + "since": "2.8.0", + "group": "pubsub", + "complexity": "O(1)", + "acl_categories": [ + "@pubsub", + "@slow" + ], + "arity": 2, + "command_flags": [ + "pubsub", + "loading", + "stale" + ] + }, + "PUBSUB NUMSUB": { + "summary": "Get the count of subscribers for channels", + "since": "2.8.0", + "group": "pubsub", + "complexity": "O(N) for the NUMSUB subcommand, where N is the number of requested channels", + "acl_categories": [ + "@pubsub", + "@slow" + ], + "arity": -2, + "arguments": [ + { + "name": "channel", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "pubsub", + "loading", + "stale" + ] + }, + "PUBSUB SHARDCHANNELS": { + "summary": "List active shard channels", + "since": "7.0.0", + "group": "pubsub", + "complexity": "O(N) where N is the number of active shard channels, and assuming constant time pattern matching (relatively short shard channels).", + "acl_categories": [ + "@pubsub", + "@slow" + ], + "arity": -2, + "arguments": [ + { + "name": "pattern", + "type": "pattern", + "optional": true + } + ], + "command_flags": [ + "pubsub", + "loading", + "stale" + ] + }, + "PUBSUB SHARDNUMSUB": { + "summary": "Get the count of subscribers for shard channels", + "since": "7.0.0", + "group": "pubsub", + "complexity": "O(N) for the SHARDNUMSUB subcommand, where N is the number of requested shard channels", + "acl_categories": [ + "@pubsub", + "@slow" + ], + "arity": -2, + "arguments": [ + { + "name": "shardchannel", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "pubsub", + "loading", + "stale" + ] + }, + "PUNSUBSCRIBE": { + "summary": "Stop listening for messages posted to channels matching the given patterns", + "since": "2.0.0", + "group": "pubsub", + "complexity": "O(N+M) where N is the number of patterns the client is already subscribed and M is the number of total patterns subscribed in the system (by any client).", + "acl_categories": [ + "@pubsub", + "@slow" + ], + "arity": -1, + "arguments": [ + { + "name": "pattern", + "type": "pattern", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "pubsub", + "noscript", + "loading", + "stale" + ] + }, + "QUIT": { + "summary": "Close the connection", + "since": "1.0.0", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@fast", + "@connection" + ], + "arity": -1, + "command_flags": [ + "noscript", + "loading", + "stale", + "fast", + "no_auth", + "allow_busy" + ] + }, + "RANDOMKEY": { + "summary": "Return a random key from the keyspace", + "since": "1.0.0", + "group": "generic", + "complexity": "O(1)", + "acl_categories": [ + "@keyspace", + "@read", + "@slow" + ], + "arity": 1, + "command_flags": [ + "readonly" + ], + "hints": [ + "request_policy:all_shards", + "nondeterministic_output" + ] + }, + "READONLY": { + "summary": "Enables read queries for a connection to a cluster replica node", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@fast", + "@connection" + ], + "arity": 1, + "command_flags": [ + "loading", + "stale", + "fast" + ] + }, + "READWRITE": { + "summary": "Disables read queries for a connection to a cluster replica node", + "since": "3.0.0", + "group": "cluster", + "complexity": "O(1)", + "acl_categories": [ + "@fast", + "@connection" + ], + "arity": 1, + "command_flags": [ + "loading", + "stale", + "fast" + ] + }, + "RENAME": { + "summary": "Rename a key", + "since": "1.0.0", + "group": "generic", + "complexity": "O(1)", + "acl_categories": [ + "@keyspace", + "@write", + "@slow" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "newkey", + "type": "key", + "key_spec_index": 1 + } + ], + "command_flags": [ + "write" + ] + }, + "RENAMENX": { + "summary": "Rename a key, only if the new key does not exist", + "since": "1.0.0", + "group": "generic", + "complexity": "O(1)", + "history": [ + [ + "3.2.0", + "The command no longer returns an error when source and destination names are the same." + ] + ], + "acl_categories": [ + "@keyspace", + "@write", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "newkey", + "type": "key", + "key_spec_index": 1 + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "REPLCONF": { + "summary": "An internal command for configuring the replication stream", + "since": "3.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -1, + "command_flags": [ + "admin", + "noscript", + "loading", + "stale", + "allow_busy" + ], + "doc_flags": [ + "syscmd" + ] + }, + "REPLICAOF": { + "summary": "Make the server a replica of another instance, or promote it as master.", + "since": "5.0.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 3, + "arguments": [ + { + "name": "host", + "type": "string" + }, + { + "name": "port", + "type": "integer" + } + ], + "command_flags": [ + "admin", + "noscript", + "stale", + "no_async_loading" + ] + }, + "RESET": { + "summary": "Reset the connection", + "since": "6.2.0", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@fast", + "@connection" + ], + "arity": 1, + "command_flags": [ + "noscript", + "loading", + "stale", + "fast", + "no_auth", + "allow_busy" + ] + }, + "RESTORE": { + "summary": "Create a key using the provided serialized value, previously obtained using DUMP.", + "since": "2.6.0", + "group": "generic", + "complexity": "O(1) to create the new key and additional O(N*M) to reconstruct the serialized value, where N is the number of Redis objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1*M) where M is small, so simply O(1). However for sorted set values the complexity is O(N*M*log(N)) because inserting values into sorted sets is O(log(N)).", + "history": [ + [ + "3.0.0", + "Added the `REPLACE` modifier." + ], + [ + "5.0.0", + "Added the `ABSTTL` modifier." + ], + [ + "5.0.0", + "Added the `IDLETIME` and `FREQ` options." + ] + ], + "acl_categories": [ + "@keyspace", + "@write", + "@slow", + "@dangerous" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "ttl", + "type": "integer" + }, + { + "name": "serialized-value", + "type": "string" + }, + { + "name": "replace", + "type": "pure-token", + "token": "REPLACE", + "since": "3.0.0", + "optional": true + }, + { + "name": "absttl", + "type": "pure-token", + "token": "ABSTTL", + "since": "5.0.0", + "optional": true + }, + { + "name": "seconds", + "type": "integer", + "token": "IDLETIME", + "since": "5.0.0", + "optional": true + }, + { + "name": "frequency", + "type": "integer", + "token": "FREQ", + "since": "5.0.0", + "optional": true + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "RESTORE-ASKING": { + "summary": "An internal command for migrating keys in a cluster", + "since": "3.0.0", + "group": "server", + "complexity": "O(1) to create the new key and additional O(N*M) to reconstruct the serialized value, where N is the number of Redis objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1*M) where M is small, so simply O(1). However for sorted set values the complexity is O(N*M*log(N)) because inserting values into sorted sets is O(log(N)).", + "history": [ + [ + "3.0.0", + "Added the `REPLACE` modifier." + ], + [ + "5.0.0", + "Added the `ABSTTL` modifier." + ], + [ + "5.0.0", + "Added the `IDLETIME` and `FREQ` options." + ] + ], + "acl_categories": [ + "@keyspace", + "@write", + "@slow", + "@dangerous" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "ttl", + "type": "integer" + }, + { + "name": "serialized-value", + "type": "string" + }, + { + "name": "replace", + "type": "pure-token", + "token": "REPLACE", + "since": "3.0.0", + "optional": true + }, + { + "name": "absttl", + "type": "pure-token", + "token": "ABSTTL", + "since": "5.0.0", + "optional": true + }, + { + "name": "seconds", + "type": "integer", + "token": "IDLETIME", + "since": "5.0.0", + "optional": true + }, + { + "name": "frequency", + "type": "integer", + "token": "FREQ", + "since": "5.0.0", + "optional": true + } + ], + "command_flags": [ + "write", + "denyoom", + "asking" + ], + "doc_flags": [ + "syscmd" + ] + }, + "ROLE": { + "summary": "Return the role of the instance in the context of replication", + "since": "2.8.12", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@fast", + "@dangerous" + ], + "arity": 1, + "command_flags": [ + "noscript", + "loading", + "stale", + "fast" + ] + }, + "RPOP": { + "summary": "Remove and get the last elements in a list", + "since": "1.0.0", + "group": "list", + "complexity": "O(N) where N is the number of elements returned", + "history": [ + [ + "6.2.0", + "Added the `count` argument." + ] + ], + "acl_categories": [ + "@write", + "@list", + "@fast" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "count", + "type": "integer", + "since": "6.2.0", + "optional": true + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "RPOPLPUSH": { + "summary": "Remove the last element in a list, prepend it to another list and return it", + "since": "1.2.0", + "group": "list", + "complexity": "O(1)", + "deprecated_since": "6.2.0", + "replaced_by": "`LMOVE` with the `RIGHT` and `LEFT` arguments", + "acl_categories": [ + "@write", + "@list", + "@slow" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "source", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "destination", + "type": "key", + "key_spec_index": 1 + } + ], + "command_flags": [ + "write", + "denyoom" + ], + "doc_flags": [ + "deprecated" + ] + }, + "RPUSH": { + "summary": "Append one or multiple elements to a list", + "since": "1.0.0", + "group": "list", + "complexity": "O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.", + "history": [ + [ + "2.4.0", + "Accepts multiple `element` arguments." + ] + ], + "acl_categories": [ + "@write", + "@list", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "element", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "RPUSHX": { + "summary": "Append an element to a list, only if the list exists", + "since": "2.2.0", + "group": "list", + "complexity": "O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.", + "history": [ + [ + "4.0.0", + "Accepts multiple `element` arguments." + ] + ], + "acl_categories": [ + "@write", + "@list", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "element", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "SADD": { + "summary": "Add one or more members to a set", + "since": "1.0.0", + "group": "set", + "complexity": "O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.", + "history": [ + [ + "2.4.0", + "Accepts multiple `member` arguments." + ] + ], + "acl_categories": [ + "@write", + "@set", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "SAVE": { + "summary": "Synchronously save the dataset to disk", + "since": "1.0.0", + "group": "server", + "complexity": "O(N) where N is the total number of keys in all databases", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 1, + "command_flags": [ + "admin", + "noscript", + "no_async_loading", + "no_multi" + ] + }, + "SCAN": { + "summary": "Incrementally iterate the keys space", + "since": "2.8.0", + "group": "generic", + "complexity": "O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection.", + "history": [ + [ + "6.0.0", + "Added the `TYPE` subcommand." + ] + ], + "acl_categories": [ + "@keyspace", + "@read", + "@slow" + ], + "arity": -2, + "arguments": [ + { + "name": "cursor", + "type": "integer" + }, + { + "name": "pattern", + "type": "pattern", + "token": "MATCH", + "optional": true + }, + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + }, + { + "name": "type", + "type": "string", + "token": "TYPE", + "since": "6.0.0", + "optional": true + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output", + "request_policy:special" + ] + }, + "SCARD": { + "summary": "Get the number of members in a set", + "since": "1.0.0", + "group": "set", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@set", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "SCRIPT": { + "summary": "A container for Lua scripts management commands", + "since": "2.6.0", + "group": "scripting", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "SCRIPT DEBUG": { + "summary": "Set the debug mode for executed scripts.", + "since": "3.2.0", + "group": "scripting", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": 3, + "arguments": [ + { + "name": "mode", + "type": "oneof", + "arguments": [ + { + "name": "yes", + "type": "pure-token", + "token": "YES" + }, + { + "name": "sync", + "type": "pure-token", + "token": "SYNC" + }, + { + "name": "no", + "type": "pure-token", + "token": "NO" + } + ] + } + ], + "command_flags": [ + "noscript" + ] + }, + "SCRIPT EXISTS": { + "summary": "Check existence of scripts in the script cache.", + "since": "2.6.0", + "group": "scripting", + "complexity": "O(N) with N being the number of scripts to check (so checking a single script is an O(1) operation).", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": -3, + "arguments": [ + { + "name": "sha1", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "noscript" + ], + "hints": [ + "request_policy:all_shards", + "response_policy:agg_logical_and" + ] + }, + "SCRIPT FLUSH": { + "summary": "Remove all the scripts from the script cache.", + "since": "2.6.0", + "group": "scripting", + "complexity": "O(N) with N being the number of scripts in cache", + "history": [ + [ + "6.2.0", + "Added the `ASYNC` and `SYNC` flushing mode modifiers." + ] + ], + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": -2, + "arguments": [ + { + "name": "async", + "type": "oneof", + "since": "6.2.0", + "optional": true, + "arguments": [ + { + "name": "async", + "type": "pure-token", + "token": "ASYNC" + }, + { + "name": "sync", + "type": "pure-token", + "token": "SYNC" + } + ] + } + ], + "command_flags": [ + "noscript" + ], + "hints": [ + "request_policy:all_nodes", + "response_policy:all_succeeded" + ] + }, + "SCRIPT HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "5.0.0", + "group": "scripting", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "SCRIPT KILL": { + "summary": "Kill the script currently in execution.", + "since": "2.6.0", + "group": "scripting", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": 2, + "command_flags": [ + "noscript", + "allow_busy" + ], + "hints": [ + "request_policy:all_shards", + "response_policy:one_succeeded" + ] + }, + "SCRIPT LOAD": { + "summary": "Load the specified Lua script into the script cache.", + "since": "2.6.0", + "group": "scripting", + "complexity": "O(N) with N being the length in bytes of the script body.", + "acl_categories": [ + "@slow", + "@scripting" + ], + "arity": 3, + "arguments": [ + { + "name": "script", + "type": "string" + } + ], + "command_flags": [ + "noscript", + "stale" + ], + "hints": [ + "request_policy:all_nodes", + "response_policy:all_succeeded" + ] + }, + "SDIFF": { + "summary": "Subtract multiple sets", + "since": "1.0.0", + "group": "set", + "complexity": "O(N) where N is the total number of elements in all given sets.", + "acl_categories": [ + "@read", + "@set", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output_order" + ] + }, + "SDIFFSTORE": { + "summary": "Subtract multiple sets and store the resulting set in a key", + "since": "1.0.0", + "group": "set", + "complexity": "O(N) where N is the total number of elements in all given sets.", + "acl_categories": [ + "@write", + "@set", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "destination", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "key", + "type": "key", + "key_spec_index": 1, + "multiple": true + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "SELECT": { + "summary": "Change the selected database for the current connection", + "since": "1.0.0", + "group": "connection", + "complexity": "O(1)", + "acl_categories": [ + "@fast", + "@connection" + ], + "arity": 2, + "arguments": [ + { + "name": "index", + "type": "integer" + } + ], + "command_flags": [ + "loading", + "stale", + "fast" + ] + }, + "SET": { + "summary": "Set the string value of a key", + "since": "1.0.0", + "group": "string", + "complexity": "O(1)", + "history": [ + [ + "2.6.12", + "Added the `EX`, `PX`, `NX` and `XX` options." + ], + [ + "6.0.0", + "Added the `KEEPTTL` option." + ], + [ + "6.2.0", + "Added the `GET`, `EXAT` and `PXAT` option." + ], + [ + "7.0.0", + "Allowed the `NX` and `GET` options to be used together." + ] + ], + "acl_categories": [ + "@write", + "@string", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "notes": "RW and ACCESS due to the optional `GET` argument", + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true, + "variable_flags": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "value", + "type": "string" + }, + { + "name": "condition", + "type": "oneof", + "since": "2.6.12", + "optional": true, + "arguments": [ + { + "name": "nx", + "type": "pure-token", + "token": "NX" + }, + { + "name": "xx", + "type": "pure-token", + "token": "XX" + } + ] + }, + { + "name": "get", + "type": "pure-token", + "token": "GET", + "since": "6.2.0", + "optional": true + }, + { + "name": "expiration", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "seconds", + "type": "integer", + "token": "EX", + "since": "2.6.12" + }, + { + "name": "milliseconds", + "type": "integer", + "token": "PX", + "since": "2.6.12" + }, + { + "name": "unix-time-seconds", + "type": "unix-time", + "token": "EXAT", + "since": "6.2.0" + }, + { + "name": "unix-time-milliseconds", + "type": "unix-time", + "token": "PXAT", + "since": "6.2.0" + }, + { + "name": "keepttl", + "type": "pure-token", + "token": "KEEPTTL", + "since": "6.0.0" + } + ] + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "SETBIT": { + "summary": "Sets or clears the bit at offset in the string value stored at key", + "since": "2.2.0", + "group": "bitmap", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@bitmap", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "offset", + "type": "integer" + }, + { + "name": "value", + "type": "integer" + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "SETEX": { + "summary": "Set the value and expiration of a key", + "since": "2.0.0", + "group": "string", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@string", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "seconds", + "type": "integer" + }, + { + "name": "value", + "type": "string" + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "SETNX": { + "summary": "Set the value of a key, only if the key does not exist", + "since": "1.0.0", + "group": "string", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@string", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "value", + "type": "string" + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "SETRANGE": { + "summary": "Overwrite part of a string at key starting at the specified offset", + "since": "2.2.0", + "group": "string", + "complexity": "O(1), not counting the time taken to copy the new string in place. Usually, this string is very small so the amortized complexity is O(1). Otherwise, complexity is O(M) with M being the length of the value argument.", + "acl_categories": [ + "@write", + "@string", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "offset", + "type": "integer" + }, + { + "name": "value", + "type": "string" + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "SHUTDOWN": { + "summary": "Synchronously save the dataset to disk and then shut down the server", + "since": "1.0.0", + "group": "server", + "complexity": "O(N) when saving, where N is the total number of keys in all databases when saving data, otherwise O(1)", + "history": [ + [ + "7.0.0", + "Added the `NOW`, `FORCE` and `ABORT` modifiers." + ] + ], + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -1, + "arguments": [ + { + "name": "nosave_save", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "nosave", + "type": "pure-token", + "token": "NOSAVE" + }, + { + "name": "save", + "type": "pure-token", + "token": "SAVE" + } + ] + }, + { + "name": "now", + "type": "pure-token", + "token": "NOW", + "since": "7.0.0", + "optional": true + }, + { + "name": "force", + "type": "pure-token", + "token": "FORCE", + "since": "7.0.0", + "optional": true + }, + { + "name": "abort", + "type": "pure-token", + "token": "ABORT", + "since": "7.0.0", + "optional": true + } + ], + "command_flags": [ + "admin", + "noscript", + "loading", + "stale", + "no_multi", + "allow_busy" + ] + }, + "SINTER": { + "summary": "Intersect multiple sets", + "since": "1.0.0", + "group": "set", + "complexity": "O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets.", + "acl_categories": [ + "@read", + "@set", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output_order" + ] + }, + "SINTERCARD": { + "summary": "Intersect multiple sets and return the cardinality of the result", + "since": "7.0.0", + "group": "set", + "complexity": "O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets.", + "acl_categories": [ + "@read", + "@set", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "limit", + "type": "integer", + "token": "LIMIT", + "optional": true + } + ], + "command_flags": [ + "readonly", + "movablekeys" + ] + }, + "SINTERSTORE": { + "summary": "Intersect multiple sets and store the resulting set in a key", + "since": "1.0.0", + "group": "set", + "complexity": "O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets.", + "acl_categories": [ + "@write", + "@set", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "destination", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "key", + "type": "key", + "key_spec_index": 1, + "multiple": true + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "SISMEMBER": { + "summary": "Determine if a given value is a member of a set", + "since": "1.0.0", + "group": "set", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@set", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member", + "type": "string" + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "SLAVEOF": { + "summary": "Make the server a replica of another instance, or promote it as master.", + "since": "1.0.0", + "group": "server", + "complexity": "O(1)", + "deprecated_since": "5.0.0", + "replaced_by": "`REPLICAOF`", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 3, + "arguments": [ + { + "name": "host", + "type": "string" + }, + { + "name": "port", + "type": "integer" + } + ], + "command_flags": [ + "admin", + "noscript", + "stale", + "no_async_loading" + ], + "doc_flags": [ + "deprecated" + ] + }, + "SLOWLOG": { + "summary": "A container for slow log commands", + "since": "2.2.12", + "group": "server", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "SLOWLOG GET": { + "summary": "Get the slow log's entries", + "since": "2.2.12", + "group": "server", + "complexity": "O(N) where N is the number of entries returned", + "history": [ + [ + "4.0.0", + "Added client IP address, port and name to the reply." + ] + ], + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": -2, + "arguments": [ + { + "name": "count", + "type": "integer", + "optional": true + } + ], + "command_flags": [ + "admin", + "loading", + "stale" + ], + "hints": [ + "request_policy:all_nodes", + "nondeterministic_output" + ] + }, + "SLOWLOG HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "6.2.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@slow" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "SLOWLOG LEN": { + "summary": "Get the slow log's length", + "since": "2.2.12", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "loading", + "stale" + ], + "hints": [ + "request_policy:all_nodes", + "response_policy:agg_sum", + "nondeterministic_output" + ] + }, + "SLOWLOG RESET": { + "summary": "Clear all entries from the slow log", + "since": "2.2.12", + "group": "server", + "complexity": "O(N) where N is the number of entries in the slowlog", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 2, + "command_flags": [ + "admin", + "loading", + "stale" + ], + "hints": [ + "request_policy:all_nodes", + "response_policy:all_succeeded" + ] + }, + "SMEMBERS": { + "summary": "Get all the members in a set", + "since": "1.0.0", + "group": "set", + "complexity": "O(N) where N is the set cardinality.", + "acl_categories": [ + "@read", + "@set", + "@slow" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output_order" + ] + }, + "SMISMEMBER": { + "summary": "Returns the membership associated with the given elements for a set", + "since": "6.2.0", + "group": "set", + "complexity": "O(N) where N is the number of elements being checked for membership", + "acl_categories": [ + "@read", + "@set", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "SMOVE": { + "summary": "Move a member from one set to another", + "since": "1.0.0", + "group": "set", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@set", + "@fast" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "source", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "destination", + "type": "key", + "key_spec_index": 1 + }, + { + "name": "member", + "type": "string" + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "SORT": { + "summary": "Sort the elements in a list, set or sorted set", + "since": "1.0.0", + "group": "generic", + "complexity": "O(N+M*log(M)) where N is the number of elements in the list or set to sort, and M the number of returned elements. When the elements are not sorted, complexity is O(N).", + "acl_categories": [ + "@write", + "@set", + "@sortedset", + "@list", + "@slow", + "@dangerous" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + }, + { + "notes": "For the optional BY/GET keyword. It is marked 'unknown' because the key names derive from the content of the key we sort", + "begin_search": { + "type": "unknown", + "spec": {} + }, + "find_keys": { + "type": "unknown", + "spec": {} + }, + "RO": true, + "access": true + }, + { + "notes": "For the optional STORE keyword. It is marked 'unknown' because the keyword can appear anywhere in the argument array", + "begin_search": { + "type": "unknown", + "spec": {} + }, + "find_keys": { + "type": "unknown", + "spec": {} + }, + "OW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "pattern", + "type": "pattern", + "key_spec_index": 1, + "token": "BY", + "optional": true + }, + { + "name": "offset_count", + "type": "block", + "token": "LIMIT", + "optional": true, + "arguments": [ + { + "name": "offset", + "type": "integer" + }, + { + "name": "count", + "type": "integer" + } + ] + }, + { + "name": "pattern", + "type": "pattern", + "key_spec_index": 1, + "token": "GET", + "optional": true, + "multiple": true, + "multiple_token": true + }, + { + "name": "order", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "asc", + "type": "pure-token", + "token": "ASC" + }, + { + "name": "desc", + "type": "pure-token", + "token": "DESC" + } + ] + }, + { + "name": "sorting", + "type": "pure-token", + "token": "ALPHA", + "optional": true + }, + { + "name": "destination", + "type": "key", + "key_spec_index": 2, + "token": "STORE", + "optional": true + } + ], + "command_flags": [ + "write", + "denyoom", + "movablekeys" + ] + }, + "SORT_RO": { + "summary": "Sort the elements in a list, set or sorted set. Read-only variant of SORT.", + "since": "7.0.0", + "group": "generic", + "complexity": "O(N+M*log(M)) where N is the number of elements in the list or set to sort, and M the number of returned elements. When the elements are not sorted, complexity is O(N).", + "acl_categories": [ + "@read", + "@set", + "@sortedset", + "@list", + "@slow", + "@dangerous" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + }, + { + "notes": "For the optional BY/GET keyword. It is marked 'unknown' because the key names derive from the content of the key we sort", + "begin_search": { + "type": "unknown", + "spec": {} + }, + "find_keys": { + "type": "unknown", + "spec": {} + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "pattern", + "type": "pattern", + "key_spec_index": 1, + "token": "BY", + "optional": true + }, + { + "name": "offset_count", + "type": "block", + "token": "LIMIT", + "optional": true, + "arguments": [ + { + "name": "offset", + "type": "integer" + }, + { + "name": "count", + "type": "integer" + } + ] + }, + { + "name": "pattern", + "type": "pattern", + "key_spec_index": 1, + "token": "GET", + "optional": true, + "multiple": true, + "multiple_token": true + }, + { + "name": "order", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "asc", + "type": "pure-token", + "token": "ASC" + }, + { + "name": "desc", + "type": "pure-token", + "token": "DESC" + } + ] + }, + { + "name": "sorting", + "type": "pure-token", + "token": "ALPHA", + "optional": true + } + ], + "command_flags": [ + "readonly", + "movablekeys" + ] + }, + "SPOP": { + "summary": "Remove and return one or multiple random members from a set", + "since": "1.0.0", + "group": "set", + "complexity": "Without the count argument O(1), otherwise O(N) where N is the value of the passed count.", + "history": [ + [ + "3.2.0", + "Added the `count` argument." + ] + ], + "acl_categories": [ + "@write", + "@set", + "@fast" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "count", + "type": "integer", + "since": "3.2.0", + "optional": true + } + ], + "command_flags": [ + "write", + "fast" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "SPUBLISH": { + "summary": "Post a message to a shard channel", + "since": "7.0.0", + "group": "pubsub", + "complexity": "O(N) where N is the number of clients subscribed to the receiving shard channel.", + "acl_categories": [ + "@pubsub", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "not_key": true + } + ], + "arguments": [ + { + "name": "shardchannel", + "type": "string" + }, + { + "name": "message", + "type": "string" + } + ], + "command_flags": [ + "pubsub", + "loading", + "stale", + "fast" + ] + }, + "SRANDMEMBER": { + "summary": "Get one or multiple random members from a set", + "since": "1.0.0", + "group": "set", + "complexity": "Without the count argument O(1), otherwise O(N) where N is the absolute value of the passed count.", + "history": [ + [ + "2.6.0", + "Added the optional `count` argument." + ] + ], + "acl_categories": [ + "@read", + "@set", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "count", + "type": "integer", + "since": "2.6.0", + "optional": true + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "SREM": { + "summary": "Remove one or more members from a set", + "since": "1.0.0", + "group": "set", + "complexity": "O(N) where N is the number of members to be removed.", + "history": [ + [ + "2.4.0", + "Accepts multiple `member` arguments." + ] + ], + "acl_categories": [ + "@write", + "@set", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "SSCAN": { + "summary": "Incrementally iterate Set elements", + "since": "2.8.0", + "group": "set", + "complexity": "O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection..", + "acl_categories": [ + "@read", + "@set", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "cursor", + "type": "integer" + }, + { + "name": "pattern", + "type": "pattern", + "token": "MATCH", + "optional": true + }, + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "SSUBSCRIBE": { + "summary": "Listen for messages published to the given shard channels", + "since": "7.0.0", + "group": "pubsub", + "complexity": "O(N) where N is the number of shard channels to subscribe to.", + "acl_categories": [ + "@pubsub", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "not_key": true + } + ], + "arguments": [ + { + "name": "shardchannel", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "pubsub", + "noscript", + "loading", + "stale" + ] + }, + "STRLEN": { + "summary": "Get the length of the value stored in a key", + "since": "2.2.0", + "group": "string", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@string", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "SUBSCRIBE": { + "summary": "Listen for messages published to the given channels", + "since": "2.0.0", + "group": "pubsub", + "complexity": "O(N) where N is the number of channels to subscribe to.", + "acl_categories": [ + "@pubsub", + "@slow" + ], + "arity": -2, + "arguments": [ + { + "name": "channel", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "pubsub", + "noscript", + "loading", + "stale" + ] + }, + "SUBSTR": { + "summary": "Get a substring of the string stored at a key", + "since": "1.0.0", + "group": "string", + "complexity": "O(N) where N is the length of the returned string. The complexity is ultimately determined by the returned length, but because creating a substring from an existing string is very cheap, it can be considered O(1) for small strings.", + "deprecated_since": "2.0.0", + "replaced_by": "`GETRANGE`", + "acl_categories": [ + "@read", + "@string", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "start", + "type": "integer" + }, + { + "name": "end", + "type": "integer" + } + ], + "command_flags": [ + "readonly" + ], + "doc_flags": [ + "deprecated" + ] + }, + "SUNION": { + "summary": "Add multiple sets", + "since": "1.0.0", + "group": "set", + "complexity": "O(N) where N is the total number of elements in all given sets.", + "acl_categories": [ + "@read", + "@set", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output_order" + ] + }, + "SUNIONSTORE": { + "summary": "Add multiple sets and store the resulting set in a key", + "since": "1.0.0", + "group": "set", + "complexity": "O(N) where N is the total number of elements in all given sets.", + "acl_categories": [ + "@write", + "@set", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "destination", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "key", + "type": "key", + "key_spec_index": 1, + "multiple": true + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "SUNSUBSCRIBE": { + "summary": "Stop listening for messages posted to the given shard channels", + "since": "7.0.0", + "group": "pubsub", + "complexity": "O(N) where N is the number of clients already subscribed to a shard channel.", + "acl_categories": [ + "@pubsub", + "@slow" + ], + "arity": -1, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "not_key": true + } + ], + "arguments": [ + { + "name": "shardchannel", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "pubsub", + "noscript", + "loading", + "stale" + ] + }, + "SWAPDB": { + "summary": "Swaps two Redis databases", + "since": "4.0.0", + "group": "server", + "complexity": "O(N) where N is the count of clients watching or blocking on keys from both databases.", + "acl_categories": [ + "@keyspace", + "@write", + "@fast", + "@dangerous" + ], + "arity": 3, + "arguments": [ + { + "name": "index1", + "type": "integer" + }, + { + "name": "index2", + "type": "integer" + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "SYNC": { + "summary": "Internal command used for replication", + "since": "1.0.0", + "group": "server", + "acl_categories": [ + "@admin", + "@slow", + "@dangerous" + ], + "arity": 1, + "command_flags": [ + "admin", + "noscript", + "no_async_loading", + "no_multi" + ] + }, + "TIME": { + "summary": "Return the current server time", + "since": "2.6.0", + "group": "server", + "complexity": "O(1)", + "acl_categories": [ + "@fast" + ], + "arity": 1, + "command_flags": [ + "loading", + "stale", + "fast" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "TOUCH": { + "summary": "Alters the last access time of a key(s). Returns the number of existing keys specified.", + "since": "3.2.1", + "group": "generic", + "complexity": "O(N) where N is the number of keys that will be touched.", + "acl_categories": [ + "@keyspace", + "@read", + "@fast" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + } + ], + "command_flags": [ + "readonly", + "fast" + ], + "hints": [ + "request_policy:multi_shard", + "response_policy:agg_sum" + ] + }, + "TTL": { + "summary": "Get the time to live for a key in seconds", + "since": "1.0.0", + "group": "generic", + "complexity": "O(1)", + "history": [ + [ + "2.8.0", + "Added the -2 reply." + ] + ], + "acl_categories": [ + "@keyspace", + "@read", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly", + "fast" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "TYPE": { + "summary": "Determine the type stored at key", + "since": "1.0.0", + "group": "generic", + "complexity": "O(1)", + "acl_categories": [ + "@keyspace", + "@read", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "UNLINK": { + "summary": "Delete a key asynchronously in another thread. Otherwise it is just as DEL, but non blocking.", + "since": "4.0.0", + "group": "generic", + "complexity": "O(1) for each key removed regardless of its size. Then the command does O(N) work in a different thread in order to reclaim memory, where N is the number of allocations the deleted objects where composed of.", + "acl_categories": [ + "@keyspace", + "@write", + "@fast" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RM": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + } + ], + "command_flags": [ + "write", + "fast" + ], + "hints": [ + "request_policy:multi_shard", + "response_policy:agg_sum" + ] + }, + "UNSUBSCRIBE": { + "summary": "Stop listening for messages posted to the given channels", + "since": "2.0.0", + "group": "pubsub", + "complexity": "O(N) where N is the number of clients already subscribed to a channel.", + "acl_categories": [ + "@pubsub", + "@slow" + ], + "arity": -1, + "arguments": [ + { + "name": "channel", + "type": "string", + "optional": true, + "multiple": true + } + ], + "command_flags": [ + "pubsub", + "noscript", + "loading", + "stale" + ] + }, + "UNWATCH": { + "summary": "Forget about all watched keys", + "since": "2.2.0", + "group": "transactions", + "complexity": "O(1)", + "acl_categories": [ + "@fast", + "@transaction" + ], + "arity": 1, + "command_flags": [ + "noscript", + "loading", + "stale", + "fast", + "allow_busy" + ] + }, + "WAIT": { + "summary": "Wait for the synchronous replication of all the write commands sent in the context of the current connection", + "since": "3.0.0", + "group": "generic", + "complexity": "O(1)", + "acl_categories": [ + "@slow", + "@connection" + ], + "arity": 3, + "arguments": [ + { + "name": "numreplicas", + "type": "integer" + }, + { + "name": "timeout", + "type": "integer" + } + ], + "command_flags": [ + "noscript" + ], + "hints": [ + "request_policy:all_shards", + "response_policy:agg_min" + ] + }, + "WATCH": { + "summary": "Watch the given keys to determine execution of the MULTI/EXEC block", + "since": "2.2.0", + "group": "transactions", + "complexity": "O(1) for every key.", + "acl_categories": [ + "@fast", + "@transaction" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + } + ], + "command_flags": [ + "noscript", + "loading", + "stale", + "fast", + "allow_busy" + ] + }, + "XACK": { + "summary": "Marks a pending message as correctly processed, effectively removing it from the pending entries list of the consumer group. Return value of the command is the number of messages successfully acknowledged, that is, the IDs we were actually able to resolve in the PEL.", + "since": "5.0.0", + "group": "stream", + "complexity": "O(1) for each message ID processed.", + "acl_categories": [ + "@write", + "@stream", + "@fast" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "group", + "type": "string" + }, + { + "name": "id", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "XADD": { + "summary": "Appends a new entry to a stream", + "since": "5.0.0", + "group": "stream", + "complexity": "O(1) when adding a new entry, O(N) when trimming where N being the number of entries evicted.", + "history": [ + [ + "6.2.0", + "Added the `NOMKSTREAM` option, `MINID` trimming strategy and the `LIMIT` option." + ], + [ + "7.0.0", + "Added support for the `<ms>-*` explicit ID form." + ] + ], + "acl_categories": [ + "@write", + "@stream", + "@fast" + ], + "arity": -5, + "key_specs": [ + { + "notes": "UPDATE instead of INSERT because of the optional trimming feature", + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "nomkstream", + "type": "pure-token", + "token": "NOMKSTREAM", + "since": "6.2.0", + "optional": true + }, + { + "name": "trim", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "strategy", + "type": "oneof", + "arguments": [ + { + "name": "maxlen", + "type": "pure-token", + "token": "MAXLEN" + }, + { + "name": "minid", + "type": "pure-token", + "token": "MINID", + "since": "6.2.0" + } + ] + }, + { + "name": "operator", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "equal", + "type": "pure-token", + "token": "=" + }, + { + "name": "approximately", + "type": "pure-token", + "token": "~" + } + ] + }, + { + "name": "threshold", + "type": "string" + }, + { + "name": "count", + "type": "integer", + "token": "LIMIT", + "since": "6.2.0", + "optional": true + } + ] + }, + { + "name": "id_or_auto", + "type": "oneof", + "arguments": [ + { + "name": "auto_id", + "type": "pure-token", + "token": "*" + }, + { + "name": "id", + "type": "string" + } + ] + }, + { + "name": "field_value", + "type": "block", + "multiple": true, + "arguments": [ + { + "name": "field", + "type": "string" + }, + { + "name": "value", + "type": "string" + } + ] + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "XAUTOCLAIM": { + "summary": "Changes (or acquires) ownership of messages in a consumer group, as if the messages were delivered to the specified consumer.", + "since": "6.2.0", + "group": "stream", + "complexity": "O(1) if COUNT is small.", + "history": [ + [ + "7.0.0", + "Added an element to the reply array, containing deleted entries the command cleared from the PEL" + ] + ], + "acl_categories": [ + "@write", + "@stream", + "@fast" + ], + "arity": -6, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "group", + "type": "string" + }, + { + "name": "consumer", + "type": "string" + }, + { + "name": "min-idle-time", + "type": "string" + }, + { + "name": "start", + "type": "string" + }, + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + }, + { + "name": "justid", + "type": "pure-token", + "token": "JUSTID", + "optional": true + } + ], + "command_flags": [ + "write", + "fast" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "XCLAIM": { + "summary": "Changes (or acquires) ownership of a message in a consumer group, as if the message was delivered to the specified consumer.", + "since": "5.0.0", + "group": "stream", + "complexity": "O(log N) with N being the number of messages in the PEL of the consumer group.", + "acl_categories": [ + "@write", + "@stream", + "@fast" + ], + "arity": -6, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "group", + "type": "string" + }, + { + "name": "consumer", + "type": "string" + }, + { + "name": "min-idle-time", + "type": "string" + }, + { + "name": "id", + "type": "string", + "multiple": true + }, + { + "name": "ms", + "type": "integer", + "token": "IDLE", + "optional": true + }, + { + "name": "unix-time-milliseconds", + "type": "unix-time", + "token": "TIME", + "optional": true + }, + { + "name": "count", + "type": "integer", + "token": "RETRYCOUNT", + "optional": true + }, + { + "name": "force", + "type": "pure-token", + "token": "FORCE", + "optional": true + }, + { + "name": "justid", + "type": "pure-token", + "token": "JUSTID", + "optional": true + } + ], + "command_flags": [ + "write", + "fast" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "XDEL": { + "summary": "Removes the specified entries from the stream. Returns the number of items actually deleted, that may be different from the number of IDs passed in case certain IDs do not exist.", + "since": "5.0.0", + "group": "stream", + "complexity": "O(1) for each single item to delete in the stream, regardless of the stream size.", + "acl_categories": [ + "@write", + "@stream", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "id", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "XGROUP": { + "summary": "A container for consumer groups commands", + "since": "5.0.0", + "group": "stream", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "XGROUP CREATE": { + "summary": "Create a consumer group.", + "since": "5.0.0", + "group": "stream", + "complexity": "O(1)", + "history": [ + [ + "7.0.0", + "Added the `entries_read` named argument." + ] + ], + "acl_categories": [ + "@write", + "@stream", + "@slow" + ], + "arity": -5, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "groupname", + "type": "string" + }, + { + "name": "id", + "type": "oneof", + "arguments": [ + { + "name": "id", + "type": "string" + }, + { + "name": "new_id", + "type": "pure-token", + "token": "$" + } + ] + }, + { + "name": "mkstream", + "type": "pure-token", + "token": "MKSTREAM", + "optional": true + }, + { + "name": "entries_read", + "type": "integer", + "token": "ENTRIESREAD", + "optional": true + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "XGROUP CREATECONSUMER": { + "summary": "Create a consumer in a consumer group.", + "since": "6.2.0", + "group": "stream", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@stream", + "@slow" + ], + "arity": 5, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "insert": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "groupname", + "type": "string" + }, + { + "name": "consumername", + "type": "string" + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "XGROUP DELCONSUMER": { + "summary": "Delete a consumer from a consumer group.", + "since": "5.0.0", + "group": "stream", + "complexity": "O(1)", + "acl_categories": [ + "@write", + "@stream", + "@slow" + ], + "arity": 5, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "groupname", + "type": "string" + }, + { + "name": "consumername", + "type": "string" + } + ], + "command_flags": [ + "write" + ] + }, + "XGROUP DESTROY": { + "summary": "Destroy a consumer group.", + "since": "5.0.0", + "group": "stream", + "complexity": "O(N) where N is the number of entries in the group's pending entries list (PEL).", + "acl_categories": [ + "@write", + "@stream", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "groupname", + "type": "string" + } + ], + "command_flags": [ + "write" + ] + }, + "XGROUP HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "5.0.0", + "group": "stream", + "complexity": "O(1)", + "acl_categories": [ + "@stream", + "@slow" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "XGROUP SETID": { + "summary": "Set a consumer group to an arbitrary last delivered ID value.", + "since": "5.0.0", + "group": "stream", + "complexity": "O(1)", + "history": [ + [ + "7.0.0", + "Added the optional `entries_read` argument." + ] + ], + "acl_categories": [ + "@write", + "@stream", + "@slow" + ], + "arity": -5, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "groupname", + "type": "string" + }, + { + "name": "id", + "type": "oneof", + "arguments": [ + { + "name": "id", + "type": "string" + }, + { + "name": "new_id", + "type": "pure-token", + "token": "$" + } + ] + }, + { + "name": "entries_read", + "type": "integer", + "token": "ENTRIESREAD", + "optional": true + } + ], + "command_flags": [ + "write" + ] + }, + "XINFO": { + "summary": "A container for stream introspection commands", + "since": "5.0.0", + "group": "stream", + "complexity": "Depends on subcommand.", + "acl_categories": [ + "@slow" + ], + "arity": -2 + }, + "XINFO CONSUMERS": { + "summary": "List the consumers in a consumer group", + "since": "5.0.0", + "group": "stream", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@stream", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "groupname", + "type": "string" + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "XINFO GROUPS": { + "summary": "List the consumer groups of a stream", + "since": "5.0.0", + "group": "stream", + "complexity": "O(1)", + "history": [ + [ + "7.0.0", + "Added the `entries-read` and `lag` fields" + ] + ], + "acl_categories": [ + "@read", + "@stream", + "@slow" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly" + ] + }, + "XINFO HELP": { + "summary": "Show helpful text about the different subcommands", + "since": "5.0.0", + "group": "stream", + "complexity": "O(1)", + "acl_categories": [ + "@stream", + "@slow" + ], + "arity": 2, + "command_flags": [ + "loading", + "stale" + ] + }, + "XINFO STREAM": { + "summary": "Get information about a stream", + "since": "5.0.0", + "group": "stream", + "complexity": "O(1)", + "history": [ + [ + "6.0.0", + "Added the `FULL` modifier." + ], + [ + "7.0.0", + "Added the `max-deleted-entry-id`, `entries-added`, `recorded-first-entry-id`, `entries-read` and `lag` fields" + ] + ], + "acl_categories": [ + "@read", + "@stream", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "full", + "type": "block", + "token": "FULL", + "optional": true, + "arguments": [ + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + } + ] + } + ], + "command_flags": [ + "readonly" + ] + }, + "XLEN": { + "summary": "Return the number of entries in a stream", + "since": "5.0.0", + "group": "stream", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@stream", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "XPENDING": { + "summary": "Return information and entries from a stream consumer group pending entries list, that are messages fetched but never acknowledged.", + "since": "5.0.0", + "group": "stream", + "complexity": "O(N) with N being the number of elements returned, so asking for a small fixed number of entries per call is O(1). O(M), where M is the total number of entries scanned when used with the IDLE filter. When the command returns just the summary and the list of consumers is small, it runs in O(1) time; otherwise, an additional O(N) time for iterating every consumer.", + "history": [ + [ + "6.2.0", + "Added the `IDLE` option and exclusive range intervals." + ] + ], + "acl_categories": [ + "@read", + "@stream", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "group", + "type": "string" + }, + { + "name": "filters", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "min-idle-time", + "type": "integer", + "token": "IDLE", + "since": "6.2.0", + "optional": true + }, + { + "name": "start", + "type": "string" + }, + { + "name": "end", + "type": "string" + }, + { + "name": "count", + "type": "integer" + }, + { + "name": "consumer", + "type": "string", + "optional": true + } + ] + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "XRANGE": { + "summary": "Return a range of elements in a stream, with IDs matching the specified IDs interval", + "since": "5.0.0", + "group": "stream", + "complexity": "O(N) with N being the number of elements being returned. If N is constant (e.g. always asking for the first 10 elements with COUNT), you can consider it O(1).", + "history": [ + [ + "6.2.0", + "Added exclusive ranges." + ] + ], + "acl_categories": [ + "@read", + "@stream", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "start", + "type": "string" + }, + { + "name": "end", + "type": "string" + }, + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + } + ], + "command_flags": [ + "readonly" + ] + }, + "XREAD": { + "summary": "Return never seen elements in multiple streams, with IDs greater than the ones reported by the caller for each stream. Can block.", + "since": "5.0.0", + "group": "stream", + "complexity": "For each stream mentioned: O(N) with N being the number of elements being returned, it means that XREAD-ing with a fixed COUNT is O(1). Note that when the BLOCK option is used, XADD will pay O(M) time in order to serve the M clients blocked on the stream getting new data.", + "acl_categories": [ + "@read", + "@stream", + "@slow", + "@blocking" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "keyword", + "spec": { + "keyword": "STREAMS", + "startfrom": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 2 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + }, + { + "name": "milliseconds", + "type": "integer", + "token": "BLOCK", + "optional": true + }, + { + "name": "streams", + "type": "block", + "token": "STREAMS", + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "id", + "type": "string", + "multiple": true + } + ] + } + ], + "command_flags": [ + "readonly", + "blocking", + "movablekeys" + ] + }, + "XREADGROUP": { + "summary": "Return new entries from a stream using a consumer group, or access the history of the pending entries for a given consumer. Can block.", + "since": "5.0.0", + "group": "stream", + "complexity": "For each stream mentioned: O(M) with M being the number of elements returned. If M is constant (e.g. always asking for the first 10 elements with COUNT), you can consider it O(1). On the other side when XREADGROUP blocks, XADD will pay the O(N) time in order to serve the N clients blocked on the stream getting new data.", + "acl_categories": [ + "@write", + "@stream", + "@slow", + "@blocking" + ], + "arity": -7, + "key_specs": [ + { + "begin_search": { + "type": "keyword", + "spec": { + "keyword": "STREAMS", + "startfrom": 4 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": -1, + "keystep": 1, + "limit": 2 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "group_consumer", + "type": "block", + "token": "GROUP", + "arguments": [ + { + "name": "group", + "type": "string" + }, + { + "name": "consumer", + "type": "string" + } + ] + }, + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + }, + { + "name": "milliseconds", + "type": "integer", + "token": "BLOCK", + "optional": true + }, + { + "name": "noack", + "type": "pure-token", + "token": "NOACK", + "optional": true + }, + { + "name": "streams", + "type": "block", + "token": "STREAMS", + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "id", + "type": "string", + "multiple": true + } + ] + } + ], + "command_flags": [ + "write", + "blocking", + "movablekeys" + ] + }, + "XREVRANGE": { + "summary": "Return a range of elements in a stream, with IDs matching the specified IDs interval, in reverse order (from greater to smaller IDs) compared to XRANGE", + "since": "5.0.0", + "group": "stream", + "complexity": "O(N) with N being the number of elements returned. If N is constant (e.g. always asking for the first 10 elements with COUNT), you can consider it O(1).", + "history": [ + [ + "6.2.0", + "Added exclusive ranges." + ] + ], + "acl_categories": [ + "@read", + "@stream", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "end", + "type": "string" + }, + { + "name": "start", + "type": "string" + }, + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + } + ], + "command_flags": [ + "readonly" + ] + }, + "XSETID": { + "summary": "An internal command for replicating stream values", + "since": "5.0.0", + "group": "stream", + "complexity": "O(1)", + "history": [ + [ + "7.0.0", + "Added the `entries_added` and `max_deleted_entry_id` arguments." + ] + ], + "acl_categories": [ + "@write", + "@stream", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "last-id", + "type": "string" + }, + { + "name": "entries_added", + "type": "integer", + "token": "ENTRIESADDED", + "optional": true + }, + { + "name": "max_deleted_entry_id", + "type": "string", + "token": "MAXDELETEDID", + "optional": true + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "XTRIM": { + "summary": "Trims the stream to (approximately if '~' is passed) a certain size", + "since": "5.0.0", + "group": "stream", + "complexity": "O(N), with N being the number of evicted entries. Constant times are very small however, since entries are organized in macro nodes containing multiple entries that can be released with a single deallocation.", + "history": [ + [ + "6.2.0", + "Added the `MINID` trimming strategy and the `LIMIT` option." + ] + ], + "acl_categories": [ + "@write", + "@stream", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "trim", + "type": "block", + "arguments": [ + { + "name": "strategy", + "type": "oneof", + "arguments": [ + { + "name": "maxlen", + "type": "pure-token", + "token": "MAXLEN" + }, + { + "name": "minid", + "type": "pure-token", + "token": "MINID", + "since": "6.2.0" + } + ] + }, + { + "name": "operator", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "equal", + "type": "pure-token", + "token": "=" + }, + { + "name": "approximately", + "type": "pure-token", + "token": "~" + } + ] + }, + { + "name": "threshold", + "type": "string" + }, + { + "name": "count", + "type": "integer", + "token": "LIMIT", + "since": "6.2.0", + "optional": true + } + ] + } + ], + "command_flags": [ + "write" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "ZADD": { + "summary": "Add one or more members to a sorted set, or update its score if it already exists", + "since": "1.2.0", + "group": "sorted-set", + "complexity": "O(log(N)) for each item added, where N is the number of elements in the sorted set.", + "history": [ + [ + "2.4.0", + "Accepts multiple elements." + ], + [ + "3.0.2", + "Added the `XX`, `NX`, `CH` and `INCR` options." + ], + [ + "6.2.0", + "Added the `GT` and `LT` options." + ] + ], + "acl_categories": [ + "@write", + "@sortedset", + "@fast" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "condition", + "type": "oneof", + "since": "3.0.2", + "optional": true, + "arguments": [ + { + "name": "nx", + "type": "pure-token", + "token": "NX" + }, + { + "name": "xx", + "type": "pure-token", + "token": "XX" + } + ] + }, + { + "name": "comparison", + "type": "oneof", + "since": "6.2.0", + "optional": true, + "arguments": [ + { + "name": "gt", + "type": "pure-token", + "token": "GT" + }, + { + "name": "lt", + "type": "pure-token", + "token": "LT" + } + ] + }, + { + "name": "change", + "type": "pure-token", + "token": "CH", + "since": "3.0.2", + "optional": true + }, + { + "name": "increment", + "type": "pure-token", + "token": "INCR", + "since": "3.0.2", + "optional": true + }, + { + "name": "score_member", + "type": "block", + "multiple": true, + "arguments": [ + { + "name": "score", + "type": "double" + }, + { + "name": "member", + "type": "string" + } + ] + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "ZCARD": { + "summary": "Get the number of members in a sorted set", + "since": "1.2.0", + "group": "sorted-set", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@sortedset", + "@fast" + ], + "arity": 2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "ZCOUNT": { + "summary": "Count the members in a sorted set with scores within the given values", + "since": "2.0.0", + "group": "sorted-set", + "complexity": "O(log(N)) with N being the number of elements in the sorted set.", + "acl_categories": [ + "@read", + "@sortedset", + "@fast" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "min", + "type": "double" + }, + { + "name": "max", + "type": "double" + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "ZDIFF": { + "summary": "Subtract multiple sorted sets", + "since": "6.2.0", + "group": "sorted-set", + "complexity": "O(L + (N-K)log(N)) worst case where L is the total number of elements in all the sets, N is the size of the first set, and K is the size of the result set.", + "acl_categories": [ + "@read", + "@sortedset", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "withscores", + "type": "pure-token", + "token": "WITHSCORES", + "optional": true + } + ], + "command_flags": [ + "readonly", + "movablekeys" + ] + }, + "ZDIFFSTORE": { + "summary": "Subtract multiple sorted sets and store the resulting sorted set in a new key", + "since": "6.2.0", + "group": "sorted-set", + "complexity": "O(L + (N-K)log(N)) worst case where L is the total number of elements in all the sets, N is the size of the first set, and K is the size of the result set.", + "acl_categories": [ + "@write", + "@sortedset", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "destination", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 1, + "multiple": true + } + ], + "command_flags": [ + "write", + "denyoom", + "movablekeys" + ] + }, + "ZINCRBY": { + "summary": "Increment the score of a member in a sorted set", + "since": "1.2.0", + "group": "sorted-set", + "complexity": "O(log(N)) where N is the number of elements in the sorted set.", + "acl_categories": [ + "@write", + "@sortedset", + "@fast" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "update": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "increment", + "type": "integer" + }, + { + "name": "member", + "type": "string" + } + ], + "command_flags": [ + "write", + "denyoom", + "fast" + ] + }, + "ZINTER": { + "summary": "Intersect multiple sorted sets", + "since": "6.2.0", + "group": "sorted-set", + "complexity": "O(N*K)+O(M*log(M)) worst case with N being the smallest input sorted set, K being the number of input sorted sets and M being the number of elements in the resulting sorted set.", + "acl_categories": [ + "@read", + "@sortedset", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "weight", + "type": "integer", + "token": "WEIGHTS", + "optional": true, + "multiple": true + }, + { + "name": "aggregate", + "type": "oneof", + "token": "AGGREGATE", + "optional": true, + "arguments": [ + { + "name": "sum", + "type": "pure-token", + "token": "SUM" + }, + { + "name": "min", + "type": "pure-token", + "token": "MIN" + }, + { + "name": "max", + "type": "pure-token", + "token": "MAX" + } + ] + }, + { + "name": "withscores", + "type": "pure-token", + "token": "WITHSCORES", + "optional": true + } + ], + "command_flags": [ + "readonly", + "movablekeys" + ] + }, + "ZINTERCARD": { + "summary": "Intersect multiple sorted sets and return the cardinality of the result", + "since": "7.0.0", + "group": "sorted-set", + "complexity": "O(N*K) worst case with N being the smallest input sorted set, K being the number of input sorted sets.", + "acl_categories": [ + "@read", + "@sortedset", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "limit", + "type": "integer", + "token": "LIMIT", + "optional": true + } + ], + "command_flags": [ + "readonly", + "movablekeys" + ] + }, + "ZINTERSTORE": { + "summary": "Intersect multiple sorted sets and store the resulting sorted set in a new key", + "since": "2.0.0", + "group": "sorted-set", + "complexity": "O(N*K)+O(M*log(M)) worst case with N being the smallest input sorted set, K being the number of input sorted sets and M being the number of elements in the resulting sorted set.", + "acl_categories": [ + "@write", + "@sortedset", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "destination", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 1, + "multiple": true + }, + { + "name": "weight", + "type": "integer", + "token": "WEIGHTS", + "optional": true, + "multiple": true + }, + { + "name": "aggregate", + "type": "oneof", + "token": "AGGREGATE", + "optional": true, + "arguments": [ + { + "name": "sum", + "type": "pure-token", + "token": "SUM" + }, + { + "name": "min", + "type": "pure-token", + "token": "MIN" + }, + { + "name": "max", + "type": "pure-token", + "token": "MAX" + } + ] + } + ], + "command_flags": [ + "write", + "denyoom", + "movablekeys" + ] + }, + "ZLEXCOUNT": { + "summary": "Count the number of members in a sorted set between a given lexicographical range", + "since": "2.8.9", + "group": "sorted-set", + "complexity": "O(log(N)) with N being the number of elements in the sorted set.", + "acl_categories": [ + "@read", + "@sortedset", + "@fast" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "min", + "type": "string" + }, + { + "name": "max", + "type": "string" + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "ZMPOP": { + "summary": "Remove and return members with scores in a sorted set", + "since": "7.0.0", + "group": "sorted-set", + "complexity": "O(K) + O(N*log(M)) where K is the number of provided keys, N being the number of elements in the sorted set, and M being the number of elements popped.", + "acl_categories": [ + "@write", + "@sortedset", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "where", + "type": "oneof", + "arguments": [ + { + "name": "min", + "type": "pure-token", + "token": "MIN" + }, + { + "name": "max", + "type": "pure-token", + "token": "MAX" + } + ] + }, + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + } + ], + "command_flags": [ + "write", + "movablekeys" + ] + }, + "ZMSCORE": { + "summary": "Get the score associated with the given members in a sorted set", + "since": "6.2.0", + "group": "sorted-set", + "complexity": "O(N) where N is the number of members being requested.", + "acl_categories": [ + "@read", + "@sortedset", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "ZPOPMAX": { + "summary": "Remove and return members with the highest scores in a sorted set", + "since": "5.0.0", + "group": "sorted-set", + "complexity": "O(log(N)*M) with N being the number of elements in the sorted set, and M being the number of elements popped.", + "acl_categories": [ + "@write", + "@sortedset", + "@fast" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "count", + "type": "integer", + "optional": true + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "ZPOPMIN": { + "summary": "Remove and return members with the lowest scores in a sorted set", + "since": "5.0.0", + "group": "sorted-set", + "complexity": "O(log(N)*M) with N being the number of elements in the sorted set, and M being the number of elements popped.", + "acl_categories": [ + "@write", + "@sortedset", + "@fast" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "access": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "count", + "type": "integer", + "optional": true + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "ZRANDMEMBER": { + "summary": "Get one or multiple random elements from a sorted set", + "since": "6.2.0", + "group": "sorted-set", + "complexity": "O(N) where N is the number of elements returned", + "acl_categories": [ + "@read", + "@sortedset", + "@slow" + ], + "arity": -2, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "options", + "type": "block", + "optional": true, + "arguments": [ + { + "name": "count", + "type": "integer" + }, + { + "name": "withscores", + "type": "pure-token", + "token": "WITHSCORES", + "optional": true + } + ] + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "ZRANGE": { + "summary": "Return a range of members in a sorted set", + "since": "1.2.0", + "group": "sorted-set", + "complexity": "O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements returned.", + "history": [ + [ + "6.2.0", + "Added the `REV`, `BYSCORE`, `BYLEX` and `LIMIT` options." + ] + ], + "acl_categories": [ + "@read", + "@sortedset", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "start", + "type": "string" + }, + { + "name": "stop", + "type": "string" + }, + { + "name": "sortby", + "type": "oneof", + "since": "6.2.0", + "optional": true, + "arguments": [ + { + "name": "byscore", + "type": "pure-token", + "token": "BYSCORE" + }, + { + "name": "bylex", + "type": "pure-token", + "token": "BYLEX" + } + ] + }, + { + "name": "rev", + "type": "pure-token", + "token": "REV", + "since": "6.2.0", + "optional": true + }, + { + "name": "offset_count", + "type": "block", + "token": "LIMIT", + "since": "6.2.0", + "optional": true, + "arguments": [ + { + "name": "offset", + "type": "integer" + }, + { + "name": "count", + "type": "integer" + } + ] + }, + { + "name": "withscores", + "type": "pure-token", + "token": "WITHSCORES", + "optional": true + } + ], + "command_flags": [ + "readonly" + ] + }, + "ZRANGEBYLEX": { + "summary": "Return a range of members in a sorted set, by lexicographical range", + "since": "2.8.9", + "group": "sorted-set", + "complexity": "O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).", + "deprecated_since": "6.2.0", + "replaced_by": "`ZRANGE` with the `BYLEX` argument", + "acl_categories": [ + "@read", + "@sortedset", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "min", + "type": "string" + }, + { + "name": "max", + "type": "string" + }, + { + "name": "offset_count", + "type": "block", + "token": "LIMIT", + "optional": true, + "arguments": [ + { + "name": "offset", + "type": "integer" + }, + { + "name": "count", + "type": "integer" + } + ] + } + ], + "command_flags": [ + "readonly" + ], + "doc_flags": [ + "deprecated" + ] + }, + "ZRANGEBYSCORE": { + "summary": "Return a range of members in a sorted set, by score", + "since": "1.0.5", + "group": "sorted-set", + "complexity": "O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).", + "deprecated_since": "6.2.0", + "replaced_by": "`ZRANGE` with the `BYSCORE` argument", + "history": [ + [ + "2.0.0", + "Added the `WITHSCORES` modifier." + ] + ], + "acl_categories": [ + "@read", + "@sortedset", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "min", + "type": "double" + }, + { + "name": "max", + "type": "double" + }, + { + "name": "withscores", + "type": "pure-token", + "token": "WITHSCORES", + "since": "2.0.0", + "optional": true + }, + { + "name": "offset_count", + "type": "block", + "token": "LIMIT", + "optional": true, + "arguments": [ + { + "name": "offset", + "type": "integer" + }, + { + "name": "count", + "type": "integer" + } + ] + } + ], + "command_flags": [ + "readonly" + ], + "doc_flags": [ + "deprecated" + ] + }, + "ZRANGESTORE": { + "summary": "Store a range of members from sorted set into another key", + "since": "6.2.0", + "group": "sorted-set", + "complexity": "O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements stored into the destination key.", + "acl_categories": [ + "@write", + "@sortedset", + "@slow" + ], + "arity": -5, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "dst", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "src", + "type": "key", + "key_spec_index": 1 + }, + { + "name": "min", + "type": "string" + }, + { + "name": "max", + "type": "string" + }, + { + "name": "sortby", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "byscore", + "type": "pure-token", + "token": "BYSCORE" + }, + { + "name": "bylex", + "type": "pure-token", + "token": "BYLEX" + } + ] + }, + { + "name": "rev", + "type": "pure-token", + "token": "REV", + "optional": true + }, + { + "name": "offset_count", + "type": "block", + "token": "LIMIT", + "optional": true, + "arguments": [ + { + "name": "offset", + "type": "integer" + }, + { + "name": "count", + "type": "integer" + } + ] + } + ], + "command_flags": [ + "write", + "denyoom" + ] + }, + "ZRANK": { + "summary": "Determine the index of a member in a sorted set", + "since": "2.0.0", + "group": "sorted-set", + "complexity": "O(log(N))", + "acl_categories": [ + "@read", + "@sortedset", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member", + "type": "string" + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "ZREM": { + "summary": "Remove one or more members from a sorted set", + "since": "1.2.0", + "group": "sorted-set", + "complexity": "O(M*log(N)) with N being the number of elements in the sorted set and M the number of elements to be removed.", + "history": [ + [ + "2.4.0", + "Accepts multiple elements." + ] + ], + "acl_categories": [ + "@write", + "@sortedset", + "@fast" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member", + "type": "string", + "multiple": true + } + ], + "command_flags": [ + "write", + "fast" + ] + }, + "ZREMRANGEBYLEX": { + "summary": "Remove all members in a sorted set between the given lexicographical range", + "since": "2.8.9", + "group": "sorted-set", + "complexity": "O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.", + "acl_categories": [ + "@write", + "@sortedset", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "min", + "type": "string" + }, + { + "name": "max", + "type": "string" + } + ], + "command_flags": [ + "write" + ] + }, + "ZREMRANGEBYRANK": { + "summary": "Remove all members in a sorted set within the given indexes", + "since": "2.0.0", + "group": "sorted-set", + "complexity": "O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.", + "acl_categories": [ + "@write", + "@sortedset", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "start", + "type": "integer" + }, + { + "name": "stop", + "type": "integer" + } + ], + "command_flags": [ + "write" + ] + }, + "ZREMRANGEBYSCORE": { + "summary": "Remove all members in a sorted set within the given scores", + "since": "1.2.0", + "group": "sorted-set", + "complexity": "O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.", + "acl_categories": [ + "@write", + "@sortedset", + "@slow" + ], + "arity": 4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RW": true, + "delete": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "min", + "type": "double" + }, + { + "name": "max", + "type": "double" + } + ], + "command_flags": [ + "write" + ] + }, + "ZREVRANGE": { + "summary": "Return a range of members in a sorted set, by index, with scores ordered from high to low", + "since": "1.2.0", + "group": "sorted-set", + "complexity": "O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements returned.", + "deprecated_since": "6.2.0", + "replaced_by": "`ZRANGE` with the `REV` argument", + "acl_categories": [ + "@read", + "@sortedset", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "start", + "type": "integer" + }, + { + "name": "stop", + "type": "integer" + }, + { + "name": "withscores", + "type": "pure-token", + "token": "WITHSCORES", + "optional": true + } + ], + "command_flags": [ + "readonly" + ], + "doc_flags": [ + "deprecated" + ] + }, + "ZREVRANGEBYLEX": { + "summary": "Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings.", + "since": "2.8.9", + "group": "sorted-set", + "complexity": "O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).", + "deprecated_since": "6.2.0", + "replaced_by": "`ZRANGE` with the `REV` and `BYLEX` arguments", + "acl_categories": [ + "@read", + "@sortedset", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "max", + "type": "string" + }, + { + "name": "min", + "type": "string" + }, + { + "name": "offset_count", + "type": "block", + "token": "LIMIT", + "optional": true, + "arguments": [ + { + "name": "offset", + "type": "integer" + }, + { + "name": "count", + "type": "integer" + } + ] + } + ], + "command_flags": [ + "readonly" + ], + "doc_flags": [ + "deprecated" + ] + }, + "ZREVRANGEBYSCORE": { + "summary": "Return a range of members in a sorted set, by score, with scores ordered from high to low", + "since": "2.2.0", + "group": "sorted-set", + "complexity": "O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).", + "deprecated_since": "6.2.0", + "replaced_by": "`ZRANGE` with the `REV` and `BYSCORE` arguments", + "history": [ + [ + "2.1.6", + "`min` and `max` can be exclusive." + ] + ], + "acl_categories": [ + "@read", + "@sortedset", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "max", + "type": "double" + }, + { + "name": "min", + "type": "double" + }, + { + "name": "withscores", + "type": "pure-token", + "token": "WITHSCORES", + "optional": true + }, + { + "name": "offset_count", + "type": "block", + "token": "LIMIT", + "optional": true, + "arguments": [ + { + "name": "offset", + "type": "integer" + }, + { + "name": "count", + "type": "integer" + } + ] + } + ], + "command_flags": [ + "readonly" + ], + "doc_flags": [ + "deprecated" + ] + }, + "ZREVRANK": { + "summary": "Determine the index of a member in a sorted set, with scores ordered from high to low", + "since": "2.0.0", + "group": "sorted-set", + "complexity": "O(log(N))", + "acl_categories": [ + "@read", + "@sortedset", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member", + "type": "string" + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "ZSCAN": { + "summary": "Incrementally iterate sorted sets elements and associated scores", + "since": "2.8.0", + "group": "sorted-set", + "complexity": "O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection..", + "acl_categories": [ + "@read", + "@sortedset", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "cursor", + "type": "integer" + }, + { + "name": "pattern", + "type": "pattern", + "token": "MATCH", + "optional": true + }, + { + "name": "count", + "type": "integer", + "token": "COUNT", + "optional": true + } + ], + "command_flags": [ + "readonly" + ], + "hints": [ + "nondeterministic_output" + ] + }, + "ZSCORE": { + "summary": "Get the score associated with the given member in a sorted set", + "since": "1.2.0", + "group": "sorted-set", + "complexity": "O(1)", + "acl_categories": [ + "@read", + "@sortedset", + "@fast" + ], + "arity": 3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "key", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "member", + "type": "string" + } + ], + "command_flags": [ + "readonly", + "fast" + ] + }, + "ZUNION": { + "summary": "Add multiple sorted sets", + "since": "6.2.0", + "group": "sorted-set", + "complexity": "O(N)+O(M*log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set.", + "acl_categories": [ + "@read", + "@sortedset", + "@slow" + ], + "arity": -3, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 0, + "multiple": true + }, + { + "name": "weight", + "type": "integer", + "token": "WEIGHTS", + "optional": true, + "multiple": true + }, + { + "name": "aggregate", + "type": "oneof", + "token": "AGGREGATE", + "optional": true, + "arguments": [ + { + "name": "sum", + "type": "pure-token", + "token": "SUM" + }, + { + "name": "min", + "type": "pure-token", + "token": "MIN" + }, + { + "name": "max", + "type": "pure-token", + "token": "MAX" + } + ] + }, + { + "name": "withscores", + "type": "pure-token", + "token": "WITHSCORES", + "optional": true + } + ], + "command_flags": [ + "readonly", + "movablekeys" + ] + }, + "ZUNIONSTORE": { + "summary": "Add multiple sorted sets and store the resulting sorted set in a new key", + "since": "2.0.0", + "group": "sorted-set", + "complexity": "O(N)+O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set.", + "acl_categories": [ + "@write", + "@sortedset", + "@slow" + ], + "arity": -4, + "key_specs": [ + { + "begin_search": { + "type": "index", + "spec": { + "index": 1 + } + }, + "find_keys": { + "type": "range", + "spec": { + "lastkey": 0, + "keystep": 1, + "limit": 0 + } + }, + "OW": true, + "update": true + }, + { + "begin_search": { + "type": "index", + "spec": { + "index": 2 + } + }, + "find_keys": { + "type": "keynum", + "spec": { + "keynumidx": 0, + "firstkey": 1, + "keystep": 1 + } + }, + "RO": true, + "access": true + } + ], + "arguments": [ + { + "name": "destination", + "type": "key", + "key_spec_index": 0 + }, + { + "name": "numkeys", + "type": "integer" + }, + { + "name": "key", + "type": "key", + "key_spec_index": 1, + "multiple": true + }, + { + "name": "weight", + "type": "integer", + "token": "WEIGHTS", + "optional": true, + "multiple": true + }, + { + "name": "aggregate", + "type": "oneof", + "token": "AGGREGATE", + "optional": true, + "arguments": [ + { + "name": "sum", + "type": "pure-token", + "token": "SUM" + }, + { + "name": "min", + "type": "pure-token", + "token": "MIN" + }, + { + "name": "max", + "type": "pure-token", + "token": "MAX" + } + ] + } + ], + "command_flags": [ + "write", + "denyoom", + "movablekeys" + ] + } +} diff --git a/iredis/data/commands/__init__.py b/iredis/data/commands/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/iredis/data/commands/__init__.py diff --git a/iredis/data/commands/_index.md b/iredis/data/commands/_index.md new file mode 100644 index 0000000..c963623 --- /dev/null +++ b/iredis/data/commands/_index.md @@ -0,0 +1,4 @@ +--- +title: "Redis Commands" +linkTitle: "Commands" +--- diff --git a/iredis/data/commands/acl-cat.md b/iredis/data/commands/acl-cat.md new file mode 100644 index 0000000..0eb256f --- /dev/null +++ b/iredis/data/commands/acl-cat.md @@ -0,0 +1,82 @@ +The command shows the available ACL categories if called without arguments. +If a category name is given, the command shows all the Redis commands in +the specified category. + +ACL categories are very useful in order to create ACL rules that include or +exclude a large set of commands at once, without specifying every single +command. For instance, the following rule will let the user `karin` perform +everything but the most dangerous operations that may affect the server +stability: + + ACL SETUSER karin on +@all -@dangerous + +We first add all the commands to the set of commands that `karin` is able +to execute, but then we remove all the dangerous commands. + +Checking for all the available categories is as simple as: + +``` +> ACL CAT + 1) "keyspace" + 2) "read" + 3) "write" + 4) "set" + 5) "sortedset" + 6) "list" + 7) "hash" + 8) "string" + 9) "bitmap" +10) "hyperloglog" +11) "geo" +12) "stream" +13) "pubsub" +14) "admin" +15) "fast" +16) "slow" +17) "blocking" +18) "dangerous" +19) "connection" +20) "transaction" +21) "scripting" +``` + +Then we may want to know what commands are part of a given category: + +``` +> ACL CAT dangerous + 1) "flushdb" + 2) "acl" + 3) "slowlog" + 4) "debug" + 5) "role" + 6) "keys" + 7) "pfselftest" + 8) "client" + 9) "bgrewriteaof" +10) "replicaof" +11) "monitor" +12) "restore-asking" +13) "latency" +14) "replconf" +15) "pfdebug" +16) "bgsave" +17) "sync" +18) "config" +19) "flushall" +20) "cluster" +21) "info" +22) "lastsave" +23) "slaveof" +24) "swapdb" +25) "module" +26) "restore" +27) "migrate" +28) "save" +29) "shutdown" +30) "psync" +31) "sort" +``` + +@return + +@array-reply: a list of ACL categories or a list of commands inside a given category. The command may return an error if an invalid category name is given as argument. diff --git a/iredis/data/commands/acl-deluser.md b/iredis/data/commands/acl-deluser.md new file mode 100644 index 0000000..e3f443e --- /dev/null +++ b/iredis/data/commands/acl-deluser.md @@ -0,0 +1,16 @@ +Delete all the specified ACL users and terminate all the connections that are +authenticated with such users. Note: the special `default` user cannot be +removed from the system, this is the default user that every new connection +is authenticated with. The list of users may include usernames that do not +exist, in such case no operation is performed for the non existing users. + +@return + +@integer-reply: The number of users that were deleted. This number will not always match the number of arguments since certain users may not exist. + +@examples + +``` +> ACL DELUSER antirez +1 +``` diff --git a/iredis/data/commands/acl-dryrun.md b/iredis/data/commands/acl-dryrun.md new file mode 100644 index 0000000..4afb3cd --- /dev/null +++ b/iredis/data/commands/acl-dryrun.md @@ -0,0 +1,18 @@ +Simulate the execution of a given command by a given user. +This command can be used to test the permissions of a given user without having to enable the user or cause the side effects of running the command. + +@return + +@simple-string-reply: `OK` on success. +@bulk-string-reply: An error describing why the user can't execute the command. + +@examples + +``` +> ACL SETUSER VIRGINIA +SET ~* +"OK" +> ACL DRYRUN VIRGINIA SET foo bar +"OK" +> ACL DRYRUN VIRGINIA GET foo bar +"This user has no permissions to run the 'GET' command" +``` diff --git a/iredis/data/commands/acl-genpass.md b/iredis/data/commands/acl-genpass.md new file mode 100644 index 0000000..2afbaec --- /dev/null +++ b/iredis/data/commands/acl-genpass.md @@ -0,0 +1,43 @@ +ACL users need a solid password in order to authenticate to the server without +security risks. Such password does not need to be remembered by humans, but +only by computers, so it can be very long and strong (unguessable by an +external attacker). The `ACL GENPASS` command generates a password starting +from /dev/urandom if available, otherwise (in systems without /dev/urandom) it +uses a weaker system that is likely still better than picking a weak password +by hand. + +By default (if /dev/urandom is available) the password is strong and +can be used for other uses in the context of a Redis application, for +instance in order to create unique session identifiers or other kind of +unguessable and not colliding IDs. The password generation is also very cheap +because we don't really ask /dev/urandom for bits at every execution. At +startup Redis creates a seed using /dev/urandom, then it will use SHA256 +in counter mode, with HMAC-SHA256(seed,counter) as primitive, in order to +create more random bytes as needed. This means that the application developer +should be feel free to abuse `ACL GENPASS` to create as many secure +pseudorandom strings as needed. + +The command output is a hexadecimal representation of a binary string. +By default it emits 256 bits (so 64 hex characters). The user can provide +an argument in form of number of bits to emit from 1 to 1024 to change +the output length. Note that the number of bits provided is always +rounded to the next multiple of 4. So for instance asking for just 1 +bit password will result in 4 bits to be emitted, in the form of a single +hex character. + +@return + +@bulk-string-reply: by default 64 bytes string representing 256 bits of pseudorandom data. Otherwise if an argument if needed, the output string length is the number of specified bits (rounded to the next multiple of 4) divided by 4. + +@examples + +``` +> ACL GENPASS +"dd721260bfe1b3d9601e7fbab36de6d04e2e67b0ef1c53de59d45950db0dd3cc" + +> ACL GENPASS 32 +"355ef3dd" + +> ACL GENPASS 5 +"90" +``` diff --git a/iredis/data/commands/acl-getuser.md b/iredis/data/commands/acl-getuser.md new file mode 100644 index 0000000..6c2eeed --- /dev/null +++ b/iredis/data/commands/acl-getuser.md @@ -0,0 +1,43 @@ +The command returns all the rules defined for an existing ACL user. + +Specifically, it lists the user's ACL flags, password hashes, commands, key patterns, channel patterns (Added in version 6.2) and selectors (Added in version 7.0). +Additional information may be returned in the future if more metadata is added to the user. + +Command rules are always returned in the same format as the one used in the `ACL SETUSER` command. +Before version 7.0, keys and channels were returned as an array of patterns, however in version 7.0 later they are now also returned in same format as the one used in the `ACL SETUSER` command. +Note: This description of command rules reflects the user's effective permissions, so while it may not be identical to the set of rules used to configure the user, it is still functionally identical. + +Selectors are listed in the order they were applied to the user, and include information about commands, key patterns, and channel patterns. + +@array-reply: a list of ACL rule definitions for the user. + +If `user` does not exist a @nil-reply is returned. + +@examples + +Here's an example configuration for a user + +``` +> ACL SETUSER sample on nopass +GET allkeys &* (+SET ~key2) +"OK" +> ACL GETUSER sample +1) "flags" +2) 1) "on" + 2) "allkeys" + 3) "nopass" +3) "passwords" +4) (empty array) +5) "commands" +6) "+@all" +7) "keys" +8) "~*" +9) "channels" +10) "&*" +11) "selectors" +12) 1) 1) "commands" + 6) "+SET" + 7) "keys" + 8) "~key2" + 9) "channels" + 10) "&*" +``` diff --git a/iredis/data/commands/acl-help.md b/iredis/data/commands/acl-help.md new file mode 100644 index 0000000..ddb9432 --- /dev/null +++ b/iredis/data/commands/acl-help.md @@ -0,0 +1,5 @@ +The `ACL HELP` command returns a helpful text describing the different subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/acl-list.md b/iredis/data/commands/acl-list.md new file mode 100644 index 0000000..e21e710 --- /dev/null +++ b/iredis/data/commands/acl-list.md @@ -0,0 +1,17 @@ +The command shows the currently active ACL rules in the Redis server. Each +line in the returned array defines a different user, and the format is the +same used in the redis.conf file or the external ACL file, so you can +cut and paste what is returned by the ACL LIST command directly inside a +configuration file if you wish (but make sure to check `ACL SAVE`). + +@return + +An array of strings. + +@examples + +``` +> ACL LIST +1) "user antirez on #9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 ~objects:* &* +@all -@admin -@dangerous" +2) "user default on nopass ~* &* +@all" +``` diff --git a/iredis/data/commands/acl-load.md b/iredis/data/commands/acl-load.md new file mode 100644 index 0000000..521c1a6 --- /dev/null +++ b/iredis/data/commands/acl-load.md @@ -0,0 +1,23 @@ +When Redis is configured to use an ACL file (with the `aclfile` configuration +option), this command will reload the ACLs from the file, replacing all +the current ACL rules with the ones defined in the file. The command makes +sure to have an *all or nothing* behavior, that is: + +* If every line in the file is valid, all the ACLs are loaded. +* If one or more line in the file is not valid, nothing is loaded, and the old ACL rules defined in the server memory continue to be used. + +@return + +@simple-string-reply: `OK` on success. + +The command may fail with an error for several reasons: if the file is not readable, if there is an error inside the file, and in such case the error will be reported to the user in the error. Finally the command will fail if the server is not configured to use an external ACL file. + +@examples + +``` +> ACL LOAD ++OK + +> ACL LOAD +-ERR /tmp/foo:1: Unknown command or category name in ACL... +``` diff --git a/iredis/data/commands/acl-log.md b/iredis/data/commands/acl-log.md new file mode 100644 index 0000000..adeaf8d --- /dev/null +++ b/iredis/data/commands/acl-log.md @@ -0,0 +1,41 @@ +The command shows a list of recent ACL security events: + +1. Failures to authenticate their connections with `AUTH` or `HELLO`. +2. Commands denied because against the current ACL rules. +3. Commands denied because accessing keys not allowed in the current ACL rules. + +The optional argument specifies how many entries to show. By default +up to ten failures are returned. The special `RESET` argument clears the log. +Entries are displayed starting from the most recent. + +@return + +When called to show security events: + +@array-reply: a list of ACL security events. + +When called with `RESET`: + +@simple-string-reply: `OK` if the security log was cleared. + +@examples + +``` +> AUTH someuser wrongpassword +(error) WRONGPASS invalid username-password pair +> ACL LOG 1 +1) 1) "count" + 2) (integer) 1 + 3) "reason" + 4) "auth" + 5) "context" + 6) "toplevel" + 7) "object" + 8) "AUTH" + 9) "username" + 10) "someuser" + 11) "age-seconds" + 12) "4.0960000000000001" + 13) "client-info" + 14) "id=6 addr=127.0.0.1:63026 fd=8 name= age=9 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=48 qbuf-free=32720 obl=0 oll=0 omem=0 events=r cmd=auth user=default" +``` diff --git a/iredis/data/commands/acl-save.md b/iredis/data/commands/acl-save.md new file mode 100644 index 0000000..57badc8 --- /dev/null +++ b/iredis/data/commands/acl-save.md @@ -0,0 +1,18 @@ +When Redis is configured to use an ACL file (with the `aclfile` configuration +option), this command will save the currently defined ACLs from the server memory to the ACL file. + +@return + +@simple-string-reply: `OK` on success. + +The command may fail with an error for several reasons: if the file cannot be written or if the server is not configured to use an external ACL file. + +@examples + +``` +> ACL SAVE ++OK + +> ACL SAVE +-ERR There was an error trying to save the ACLs. Please check the server logs for more information +``` diff --git a/iredis/data/commands/acl-setuser.md b/iredis/data/commands/acl-setuser.md new file mode 100644 index 0000000..a6ae4a8 --- /dev/null +++ b/iredis/data/commands/acl-setuser.md @@ -0,0 +1,104 @@ +Create an ACL user with the specified rules or modify the rules of an +existing user. This is the main interface in order to manipulate Redis ACL +users interactively: if the username does not exist, the command creates +the username without any privilege, then reads from left to right all the +rules provided as successive arguments, setting the user ACL rules as specified. + +If the user already exists, the provided ACL rules are simply applied +*in addition* to the rules already set. For example: + + ACL SETUSER virginia on allkeys +set + +The above command will create a user called `virginia` that is active +(the on rule), can access any key (allkeys rule), and can call the +set command (+set rule). Then another SETUSER call can modify the user rules: + + ACL SETUSER virginia +get + +The above rule will not apply the new rule to the user virginia, so other than `SET`, the user virginia will now be able to also use the `GET` command. + +Starting from Redis 7.0, ACL rules can also be grouped into multiple distinct sets of rules, called selectors. +Selectors are added by wrapping the rules in parentheses and providing them just like any other rule. +In order to execute a command, either the root permissions (rules defined outside of parenthesis) or any of the selectors (rules defined inside parenthesis) must match the given command. +For example: + + ACL SETUSER virginia on +GET allkeys (+SET ~app1*) + +This sets a user with two sets of permission, one defined on the user and one defined with a selector. +The root user permissions only allows executing the get command, but can be executed on any keys. +The selector then grants a secondary set of permissions: access to the `SET` command to be executed on any key that starts with "app1". +Using multiple selectors allows you to grant permissions that are different depending on what keys are being accessed. + +When we want to be sure to define a user from scratch, without caring if +it had previously defined rules associated, we can use the special rule +`reset` as first rule, in order to flush all the other existing rules: + + ACL SETUSER antirez reset [... other rules ...] + +After resetting a user, it returns back to the status it has when it +was just created: non active (off rule), can't execute any command, can't +access any key: + + > ACL SETUSER antirez reset + +OK + > ACL LIST + 1) "user antirez off -@all" + +ACL rules are either words like "on", "off", "reset", "allkeys", or are +special rules that start with a special character, and are followed by +another string (without any space in between), like "+SET". + +The following documentation is a reference manual about the capabilities of this command, however our [ACL tutorial](/topics/acl) may be a more gentle introduction to how the ACL system works in general. + +## List of rules + +Redis ACL rules are split into two categories: rules that define command permissions, "Command rules", and rules that define user state, "User management rules". +This is a list of all the supported Redis ACL rules: + +### Command rules + +* `~<pattern>`: add the specified key pattern (glob style pattern, like in the `KEYS` command), to the list of key patterns accessible by the user. This grants both read and write permissions to keys that match the pattern. You can add multiple key patterns to the same user. Example: `~objects:*` +* `%R~<pattern>`: (Available in Redis 7.0 and later) Add the specified read key pattern. This behaves similar to the regular key pattern but only grants permission to read from keys that match the given pattern. See [key permissions](/topics/acl#key-permissions) for more information. +* `%W~<pattern>`: (Available in Redis 7.0 and later) Add the specified write key pattern. This behaves similar to the regular key pattern but only grants permission to write to keys that match the given pattern. See [key permissions](/topics/acl#key-permissions) for more information. +* `%RW~<pattern>`: (Available in Redis 7.0 and later) Alias for `~<pattern>`. +* `allkeys`: alias for `~*`, it allows the user to access all the keys. +* `resetkeys`: removes all the key patterns from the list of key patterns the user can access. +* `&<pattern>`: (Available in Redis 6.2 and later) add the specified glob style pattern to the list of Pub/Sub channel patterns accessible by the user. You can add multiple channel patterns to the same user. Example: `&chatroom:*` +* `allchannels`: alias for `&*`, it allows the user to access all Pub/Sub channels. +* `resetchannels`: removes all channel patterns from the list of Pub/Sub channel patterns the user can access. +* `+<command>`: Add the command to the list of commands the user can call. Can be used with `|` for allowing subcommands (e.g "+config|get"). +* `+@<category>`: add all the commands in the specified category to the list of commands the user is able to execute. Example: `+@string` (adds all the string commands). For a list of categories check the `ACL CAT` command. +* `+<command>|first-arg`: Allow a specific first argument of an otherwise disabled command. It is only supported on commands with no sub-commands, and is not allowed as negative form like -SELECT|1, only additive starting with "+". This feature is deprecated and may be removed in the future. +* `allcommands`: alias of `+@all`. Adds all the commands there are in the server, including *future commands* loaded via module, to be executed by this user. +* `-<command>`: Remove the command to the list of commands the user can call. Starting Redis 7.0, it can be used with `|` for blocking subcommands (e.g "-config|set"). +* `-@<category>`: Like `+@<category>` but removes all the commands in the category instead of adding them. +* `nocommands`: alias for `-@all`. Removes all the commands, the user will no longer be able to execute anything. + +### User management rules + +* `on`: set the user as active, it will be possible to authenticate as this user using `AUTH <username> <password>`. +* `off`: set user as not active, it will be impossible to log as this user. Please note that if a user gets disabled (set to off) after there are connections already authenticated with such a user, the connections will continue to work as expected. To also kill the old connections you can use `CLIENT KILL` with the user option. An alternative is to delete the user with `ACL DELUSER`, that will result in all the connections authenticated as the deleted user to be disconnected. +* `nopass`: the user is set as a "no password" user. It means that it will be possible to authenticate as such user with any password. By default, the `default` special user is set as "nopass". The `nopass` rule will also reset all the configured passwords for the user. +* `>password`: Add the specified clear text password as a hashed password in the list of the users passwords. Every user can have many active passwords, so that password rotation will be simpler. The specified password is not stored as clear text inside the server. Example: `>mypassword`. +* `#<hashedpassword>`: Add the specified hashed password to the list of user passwords. A Redis hashed password is hashed with SHA256 and translated into a hexadecimal string. Example: `#c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2`. +* `<password`: Like `>password` but removes the password instead of adding it. +* `!<hashedpassword>`: Like `#<hashedpassword>` but removes the password instead of adding it. +* `(<rule list>)`: (Available in Redis 7.0 and later) Create a new selector to match rules against. Selectors are evaluated after the user permissions, and are evaluated according to the order they are defined. If a command matches either the user permissions or any selector, it is allowed. See [selectors](/topics/acl#selectors) for more information. +* `clearselectors`: (Available in Redis 7.0 and later) Delete all of the selectors attached to the user. +* `reset`: Remove any capability from the user. It is set to off, without passwords, unable to execute any command, unable to access any key. + +@return + +@simple-string-reply: `OK` on success. + +If the rules contain errors, the error is returned. + +@examples + +``` +> ACL SETUSER alan allkeys +@string +@set -SADD >alanpassword ++OK + +> ACL SETUSER antirez heeyyyy +(error) ERR Error in ACL SETUSER modifier 'heeyyyy': Syntax error +``` diff --git a/iredis/data/commands/acl-users.md b/iredis/data/commands/acl-users.md new file mode 100644 index 0000000..9b0fe1b --- /dev/null +++ b/iredis/data/commands/acl-users.md @@ -0,0 +1,15 @@ +The command shows a list of all the usernames of the currently configured +users in the Redis ACL system. + +@return + +An array of strings. + +@examples + +``` +> ACL USERS +1) "anna" +2) "antirez" +3) "default" +``` diff --git a/iredis/data/commands/acl-whoami.md b/iredis/data/commands/acl-whoami.md new file mode 100644 index 0000000..5ec7b84 --- /dev/null +++ b/iredis/data/commands/acl-whoami.md @@ -0,0 +1,14 @@ +Return the username the current connection is authenticated with. +New connections are authenticated with the "default" user. They +can change user using `AUTH`. + +@return + +@bulk-string-reply: the username of the current connection. + +@examples + +``` +> ACL WHOAMI +"default" +``` diff --git a/iredis/data/commands/acl.md b/iredis/data/commands/acl.md new file mode 100644 index 0000000..eb9277c --- /dev/null +++ b/iredis/data/commands/acl.md @@ -0,0 +1,3 @@ +This is a container command for [Access Control List](/docs/manual/security/acl/) commands. + +To see the list of available commands you can call `ACL HELP`. diff --git a/iredis/data/commands/append.md b/iredis/data/commands/append.md new file mode 100644 index 0000000..2c8bd74 --- /dev/null +++ b/iredis/data/commands/append.md @@ -0,0 +1,56 @@ +If `key` already exists and is a string, this command appends the `value` at the +end of the string. +If `key` does not exist it is created and set as an empty string, so `APPEND` +will be similar to `SET` in this special case. + +@return + +@integer-reply: the length of the string after the append operation. + +@examples + +```cli +EXISTS mykey +APPEND mykey "Hello" +APPEND mykey " World" +GET mykey +``` + +## Pattern: Time series + +The `APPEND` command can be used to create a very compact representation of a +list of fixed-size samples, usually referred as _time series_. +Every time a new sample arrives we can store it using the command + +``` +APPEND timeseries "fixed-size sample" +``` + +Accessing individual elements in the time series is not hard: + +* `STRLEN` can be used in order to obtain the number of samples. +* `GETRANGE` allows for random access of elements. + If our time series have associated time information we can easily implement + a binary search to get range combining `GETRANGE` with the Lua scripting + engine available in Redis 2.6. +* `SETRANGE` can be used to overwrite an existing time series. + +The limitation of this pattern is that we are forced into an append-only mode +of operation, there is no way to cut the time series to a given size easily +because Redis currently lacks a command able to trim string objects. +However the space efficiency of time series stored in this way is remarkable. + +Hint: it is possible to switch to a different key based on the current Unix +time, in this way it is possible to have just a relatively small amount of +samples per key, to avoid dealing with very big keys, and to make this pattern +more friendly to be distributed across many Redis instances. + +An example sampling the temperature of a sensor using fixed-size strings (using +a binary format is better in real implementations). + +```cli +APPEND ts "0043" +APPEND ts "0035" +GETRANGE ts 0 3 +GETRANGE ts 4 7 +``` diff --git a/iredis/data/commands/asking.md b/iredis/data/commands/asking.md new file mode 100644 index 0000000..d98643c --- /dev/null +++ b/iredis/data/commands/asking.md @@ -0,0 +1,10 @@ +When a cluster client receives an `-ASK` redirect, the `ASKING` command is sent to the target node followed by the command which was redirected. +This is normally done automatically by cluster clients. + +If an `-ASK` redirect is received during a transaction, only one ASKING command needs to be sent to the target node before sending the complete transaction to the target node. + +See [ASK redirection in the Redis Cluster Specification](/topics/cluster-spec#ask-redirection) for details. + +@return + +@simple-string-reply: `OK`. diff --git a/iredis/data/commands/auth.md b/iredis/data/commands/auth.md new file mode 100644 index 0000000..7c1e02a --- /dev/null +++ b/iredis/data/commands/auth.md @@ -0,0 +1,36 @@ +The AUTH command authenticates the current connection in two cases: + +1. If the Redis server is password protected via the `requirepass` option. +2. If a Redis 6.0 instance, or greater, is using the [Redis ACL system](/topics/acl). + +Redis versions prior of Redis 6 were only able to understand the one argument +version of the command: + + AUTH <password> + +This form just authenticates against the password set with `requirepass`. +In this configuration Redis will deny any command executed by the just +connected clients, unless the connection gets authenticated via `AUTH`. + +If the password provided via AUTH matches the password in the configuration file, the server replies with the `OK` status code and starts accepting commands. +Otherwise, an error is returned and the clients needs to try a new password. + +When Redis ACLs are used, the command should be given in an extended way: + + AUTH <username> <password> + +In order to authenticate the current connection with one of the connections +defined in the ACL list (see `ACL SETUSER`) and the official [ACL guide](/topics/acl) for more information. + +When ACLs are used, the single argument form of the command, where only the password is specified, assumes that the implicit username is "default". + +## Security notice + +Because of the high performance nature of Redis, it is possible to try +a lot of passwords in parallel in very short time, so make sure to generate a +strong and very long password so that this attack is infeasible. +A good way to generate strong passwords is via the `ACL GENPASS` command. + +@return + +@simple-string-reply or an error if the password, or username/password pair, is invalid. diff --git a/iredis/data/commands/bgrewriteaof.md b/iredis/data/commands/bgrewriteaof.md new file mode 100644 index 0000000..85f5204 --- /dev/null +++ b/iredis/data/commands/bgrewriteaof.md @@ -0,0 +1,30 @@ +Instruct Redis to start an [Append Only File][tpaof] rewrite process. +The rewrite will create a small optimized version of the current Append Only +File. + +[tpaof]: /topics/persistence#append-only-file + +If `BGREWRITEAOF` fails, no data gets lost as the old AOF will be untouched. + +The rewrite will be only triggered by Redis if there is not already a background +process doing persistence. + +Specifically: + +* If a Redis child is creating a snapshot on disk, the AOF rewrite is _scheduled_ but not started until the saving child producing the RDB file terminates. In this case the `BGREWRITEAOF` will still return a positive status reply, but with an appropriate message. You can check if an AOF rewrite is scheduled looking at the `INFO` command as of Redis 2.6 or successive versions. +* If an AOF rewrite is already in progress the command returns an error and no + AOF rewrite will be scheduled for a later time. +* If the AOF rewrite could start, but the attempt at starting it fails (for instance because of an error in creating the child process), an error is returned to the caller. + +Since Redis 2.4 the AOF rewrite is automatically triggered by Redis, however the +`BGREWRITEAOF` command can be used to trigger a rewrite at any time. + +Please refer to the [persistence documentation][tp] for detailed information. + +[tp]: /topics/persistence + +@return + +@simple-string-reply: A simple string reply indicating that the rewriting started or is about to start ASAP, when the call is executed with success. + +The command may reply with an error in certain cases, as documented above. diff --git a/iredis/data/commands/bgsave.md b/iredis/data/commands/bgsave.md new file mode 100644 index 0000000..714d960 --- /dev/null +++ b/iredis/data/commands/bgsave.md @@ -0,0 +1,24 @@ +Save the DB in background. + +Normally the OK code is immediately returned. +Redis forks, the parent continues to serve the clients, the child saves the DB +on disk then exits. + +An error is returned if there is already a background save running or if there +is another non-background-save process running, specifically an in-progress AOF +rewrite. + +If `BGSAVE SCHEDULE` is used, the command will immediately return `OK` when an +AOF rewrite is in progress and schedule the background save to run at the next +opportunity. + +A client may be able to check if the operation succeeded using the `LASTSAVE` +command. + +Please refer to the [persistence documentation][tp] for detailed information. + +[tp]: /topics/persistence + +@return + +@simple-string-reply: `Background saving started` if `BGSAVE` started correctly or `Background saving scheduled` when used with the `SCHEDULE` subcommand. diff --git a/iredis/data/commands/bitcount.md b/iredis/data/commands/bitcount.md new file mode 100644 index 0000000..95bd3a3 --- /dev/null +++ b/iredis/data/commands/bitcount.md @@ -0,0 +1,75 @@ +Count the number of set bits (population counting) in a string. + +By default all the bytes contained in the string are examined. +It is possible to specify the counting operation only in an interval passing the +additional arguments _start_ and _end_. + +Like for the `GETRANGE` command start and end can contain negative values in +order to index bytes starting from the end of the string, where -1 is the last +byte, -2 is the penultimate, and so forth. + +Non-existent keys are treated as empty strings, so the command will return zero. + +By default, the additional arguments _start_ and _end_ specify a byte index. +We can use an additional argument `BIT` to specify a bit index. +So 0 is the first bit, 1 is the second bit, and so forth. +For negative values, -1 is the last bit, -2 is the penultimate, and so forth. + +@return + +@integer-reply + +The number of bits set to 1. + +@examples + +```cli +SET mykey "foobar" +BITCOUNT mykey +BITCOUNT mykey 0 0 +BITCOUNT mykey 1 1 +BITCOUNT mykey 1 1 BYTE +BITCOUNT mykey 5 30 BIT +``` + +## Pattern: real-time metrics using bitmaps + +Bitmaps are a very space-efficient representation of certain kinds of +information. +One example is a Web application that needs the history of user visits, so that +for instance it is possible to determine what users are good targets of beta +features. + +Using the `SETBIT` command this is trivial to accomplish, identifying every day +with a small progressive integer. +For instance day 0 is the first day the application was put online, day 1 the +next day, and so forth. + +Every time a user performs a page view, the application can register that in +the current day the user visited the web site using the `SETBIT` command setting +the bit corresponding to the current day. + +Later it will be trivial to know the number of single days the user visited the +web site simply calling the `BITCOUNT` command against the bitmap. + +A similar pattern where user IDs are used instead of days is described +in the article called "[Fast easy realtime metrics using Redis +bitmaps][hbgc212fermurb]". + +[hbgc212fermurb]: http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps + +## Performance considerations + +In the above example of counting days, even after 10 years the application is +online we still have just `365*10` bits of data per user, that is just 456 bytes +per user. +With this amount of data `BITCOUNT` is still as fast as any other O(1) Redis +command like `GET` or `INCR`. + +When the bitmap is big, there are two alternatives: + +* Taking a separated key that is incremented every time the bitmap is modified. + This can be very efficient and atomic using a small Redis Lua script. +* Running the bitmap incrementally using the `BITCOUNT` _start_ and _end_ + optional parameters, accumulating the results client-side, and optionally + caching the result into a key. diff --git a/iredis/data/commands/bitfield.md b/iredis/data/commands/bitfield.md new file mode 100644 index 0000000..6609c85 --- /dev/null +++ b/iredis/data/commands/bitfield.md @@ -0,0 +1,116 @@ +The command treats a Redis string as an array of bits, and is capable of addressing specific integer fields of varying bit widths and arbitrary non (necessary) aligned offset. In practical terms using this command you can set, for example, a signed 5 bits integer at bit offset 1234 to a specific value, retrieve a 31 bit unsigned integer from offset 4567. Similarly the command handles increments and decrements of the specified integers, providing guaranteed and well specified overflow and underflow behavior that the user can configure. + +`BITFIELD` is able to operate with multiple bit fields in the same command call. It takes a list of operations to perform, and returns an array of replies, where each array matches the corresponding operation in the list of arguments. + +For example the following command increments a 5 bit signed integer at bit offset 100, and gets the value of the 4 bit unsigned integer at bit offset 0: + + > BITFIELD mykey INCRBY i5 100 1 GET u4 0 + 1) (integer) 1 + 2) (integer) 0 + +Note that: + +1. Addressing with `!GET` bits outside the current string length (including the case the key does not exist at all), results in the operation to be performed like the missing part all consists of bits set to 0. +2. Addressing with `!SET` or `!INCRBY` bits outside the current string length will enlarge the string, zero-padding it, as needed, for the minimal length needed, according to the most far bit touched. + +## Supported subcommands and integer encoding + +The following is the list of supported commands. + +* **GET** `<encoding>` `<offset>` -- Returns the specified bit field. +* **SET** `<encoding>` `<offset>` `<value>` -- Set the specified bit field and returns its old value. +* **INCRBY** `<encoding>` `<offset>` `<increment>` -- Increments or decrements (if a negative increment is given) the specified bit field and returns the new value. + +There is another subcommand that only changes the behavior of successive +`!INCRBY` and `!SET` subcommands calls by setting the overflow behavior: + +* **OVERFLOW** `[WRAP|SAT|FAIL]` + +Where an integer encoding is expected, it can be composed by prefixing with `i` for signed integers and `u` for unsigned integers with the number of bits of our integer encoding. So for example `u8` is an unsigned integer of 8 bits and `i16` is a +signed integer of 16 bits. + +The supported encodings are up to 64 bits for signed integers, and up to 63 bits for +unsigned integers. This limitation with unsigned integers is due to the fact +that currently the Redis protocol is unable to return 64 bit unsigned integers +as replies. + +## Bits and positional offsets + +There are two ways in order to specify offsets in the bitfield command. +If a number without any prefix is specified, it is used just as a zero based +bit offset inside the string. + +However if the offset is prefixed with a `#` character, the specified offset +is multiplied by the integer encoding's width, so for example: + + BITFIELD mystring SET i8 #0 100 SET i8 #1 200 + +Will set the first i8 integer at offset 0 and the second at offset 8. +This way you don't have to do the math yourself inside your client if what +you want is a plain array of integers of a given size. + +## Overflow control + +Using the `OVERFLOW` command the user is able to fine-tune the behavior of +the increment or decrement overflow (or underflow) by specifying one of +the following behaviors: + +* **WRAP**: wrap around, both with signed and unsigned integers. In the case of unsigned integers, wrapping is like performing the operation modulo the maximum value the integer can contain (the C standard behavior). With signed integers instead wrapping means that overflows restart towards the most negative value and underflows towards the most positive ones, so for example if an `i8` integer is set to the value 127, incrementing it by 1 will yield `-128`. +* **SAT**: uses saturation arithmetic, that is, on underflows the value is set to the minimum integer value, and on overflows to the maximum integer value. For example incrementing an `i8` integer starting from value 120 with an increment of 10, will result into the value 127, and further increments will always keep the value at 127. The same happens on underflows, but towards the value is blocked at the most negative value. +* **FAIL**: in this mode no operation is performed on overflows or underflows detected. The corresponding return value is set to NULL to signal the condition to the caller. + +Note that each `OVERFLOW` statement only affects the `!INCRBY` and `!SET` +commands that follow it in the list of subcommands, up to the next `OVERFLOW` +statement. + +By default, **WRAP** is used if not otherwise specified. + + > BITFIELD mykey incrby u2 100 1 OVERFLOW SAT incrby u2 102 1 + 1) (integer) 1 + 2) (integer) 1 + > BITFIELD mykey incrby u2 100 1 OVERFLOW SAT incrby u2 102 1 + 1) (integer) 2 + 2) (integer) 2 + > BITFIELD mykey incrby u2 100 1 OVERFLOW SAT incrby u2 102 1 + 1) (integer) 3 + 2) (integer) 3 + > BITFIELD mykey incrby u2 100 1 OVERFLOW SAT incrby u2 102 1 + 1) (integer) 0 + 2) (integer) 3 + +## Return value + +The command returns an array with each entry being the corresponding result of +the sub command given at the same position. `OVERFLOW` subcommands don't count +as generating a reply. + +The following is an example of `OVERFLOW FAIL` returning NULL. + + > BITFIELD mykey OVERFLOW FAIL incrby u2 102 1 + 1) (nil) + +## Motivations + +The motivation for this command is that the ability to store many small integers +as a single large bitmap (or segmented over a few keys to avoid having huge keys) is extremely memory efficient, and opens new use cases for Redis to be applied, especially in the field of real time analytics. This use cases are supported by the ability to specify the overflow in a controlled way. + +Fun fact: Reddit's 2017 April fools' project [r/place](https://reddit.com/r/place) was [built using the Redis BITFIELD command](https://redditblog.com/2017/04/13/how-we-built-rplace/) in order to take an in-memory representation of the collaborative canvas. + +## Performance considerations + +Usually `BITFIELD` is a fast command, however note that addressing far bits of currently short strings will trigger an allocation that may be more costly than executing the command on bits already existing. + +## Orders of bits + +The representation used by `BITFIELD` considers the bitmap as having the +bit number 0 to be the most significant bit of the first byte, and so forth, so +for example setting a 5 bits unsigned integer to value 23 at offset 7 into a +bitmap previously set to all zeroes, will produce the following representation: + + +--------+--------+ + |00000001|01110000| + +--------+--------+ + +When offsets and integer sizes are aligned to bytes boundaries, this is the +same as big endian, however when such alignment does not exist, its important +to also understand how the bits inside a byte are ordered. diff --git a/iredis/data/commands/bitfield_ro.md b/iredis/data/commands/bitfield_ro.md new file mode 100644 index 0000000..94057a1 --- /dev/null +++ b/iredis/data/commands/bitfield_ro.md @@ -0,0 +1,19 @@ +Read-only variant of the `BITFIELD` command. +It is like the original `BITFIELD` but only accepts `!GET` subcommand and can safely be used in read-only replicas. + +Since the original `BITFIELD` has `!SET` and `!INCRBY` options it is technically flagged as a writing command in the Redis command table. +For this reason read-only replicas in a Redis Cluster will redirect it to the master instance even if the connection is in read-only mode (see the `READONLY` command of Redis Cluster). + +Since Redis 6.2, the `BITFIELD_RO` variant was introduced in order to allow `BITFIELD` behavior in read-only replicas without breaking compatibility on command flags. + +See original `BITFIELD` for more details. + +@examples + +``` +BITFIELD_RO hello GET i8 16 +``` + +@return + +@array-reply: An array with each entry being the corresponding result of the subcommand given at the same position. diff --git a/iredis/data/commands/bitop.md b/iredis/data/commands/bitop.md new file mode 100644 index 0000000..d35c756 --- /dev/null +++ b/iredis/data/commands/bitop.md @@ -0,0 +1,62 @@ +Perform a bitwise operation between multiple keys (containing string values) and +store the result in the destination key. + +The `BITOP` command supports four bitwise operations: **AND**, **OR**, **XOR** +and **NOT**, thus the valid forms to call the command are: + + +* `BITOP AND destkey srckey1 srckey2 srckey3 ... srckeyN` +* `BITOP OR destkey srckey1 srckey2 srckey3 ... srckeyN` +* `BITOP XOR destkey srckey1 srckey2 srckey3 ... srckeyN` +* `BITOP NOT destkey srckey` + +As you can see **NOT** is special as it only takes an input key, because it +performs inversion of bits so it only makes sense as a unary operator. + +The result of the operation is always stored at `destkey`. + +## Handling of strings with different lengths + +When an operation is performed between strings having different lengths, all the +strings shorter than the longest string in the set are treated as if they were +zero-padded up to the length of the longest string. + +The same holds true for non-existent keys, that are considered as a stream of +zero bytes up to the length of the longest string. + +@return + +@integer-reply + +The size of the string stored in the destination key, that is equal to the +size of the longest input string. + +@examples + +```cli +SET key1 "foobar" +SET key2 "abcdef" +BITOP AND dest key1 key2 +GET dest +``` + +## Pattern: real time metrics using bitmaps + +`BITOP` is a good complement to the pattern documented in the `BITCOUNT` command +documentation. +Different bitmaps can be combined in order to obtain a target bitmap where +the population counting operation is performed. + +See the article called "[Fast easy realtime metrics using Redis +bitmaps][hbgc212fermurb]" for an interesting use cases. + +[hbgc212fermurb]: http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps + +## Performance considerations + +`BITOP` is a potentially slow command as it runs in O(N) time. +Care should be taken when running it against long input strings. + +For real-time metrics and statistics involving large inputs a good approach is +to use a replica (with read-only option disabled) where the bit-wise +operations are performed to avoid blocking the master instance. diff --git a/iredis/data/commands/bitpos.md b/iredis/data/commands/bitpos.md new file mode 100644 index 0000000..1016941 --- /dev/null +++ b/iredis/data/commands/bitpos.md @@ -0,0 +1,52 @@ +Return the position of the first bit set to 1 or 0 in a string. + +The position is returned, thinking of the string as an array of bits from left to +right, where the first byte's most significant bit is at position 0, the second +byte's most significant bit is at position 8, and so forth. + +The same bit position convention is followed by `GETBIT` and `SETBIT`. + +By default, all the bytes contained in the string are examined. +It is possible to look for bits only in a specified interval passing the additional arguments _start_ and _end_ (it is possible to just pass _start_, the operation will assume that the end is the last byte of the string. However there are semantic differences as explained later). +By default, the range is interpreted as a range of bytes and not a range of bits, so `start=0` and `end=2` means to look at the first three bytes. + +You can use the optional `BIT` modifier to specify that the range should be interpreted as a range of bits. +So `start=0` and `end=2` means to look at the first three bits. + +Note that bit positions are returned always as absolute values starting from bit zero even when _start_ and _end_ are used to specify a range. + +Like for the `GETRANGE` command start and end can contain negative values in +order to index bytes starting from the end of the string, where -1 is the last +byte, -2 is the penultimate, and so forth. When `BIT` is specified, -1 is the last +bit, -2 is the penultimate, and so forth. + +Non-existent keys are treated as empty strings. + +@return + +@integer-reply + +The command returns the position of the first bit set to 1 or 0 according to the request. + +If we look for set bits (the bit argument is 1) and the string is empty or composed of just zero bytes, -1 is returned. + +If we look for clear bits (the bit argument is 0) and the string only contains bit set to 1, the function returns the first bit not part of the string on the right. So if the string is three bytes set to the value `0xff` the command `BITPOS key 0` will return 24, since up to bit 23 all the bits are 1. + +Basically, the function considers the right of the string as padded with zeros if you look for clear bits and specify no range or the _start_ argument **only**. + +However, this behavior changes if you are looking for clear bits and specify a range with both __start__ and __end__. If no clear bit is found in the specified range, the function returns -1 as the user specified a clear range and there are no 0 bits in that range. + +@examples + +```cli +SET mykey "\xff\xf0\x00" +BITPOS mykey 0 +SET mykey "\x00\xff\xf0" +BITPOS mykey 1 0 +BITPOS mykey 1 2 +BITPOS mykey 1 2 -1 BYTE +BITPOS mykey 1 7 15 BIT +set mykey "\x00\x00\x00" +BITPOS mykey 1 +BITPOS mykey 1 7 -3 BIT +``` diff --git a/iredis/data/commands/blmove.md b/iredis/data/commands/blmove.md new file mode 100644 index 0000000..463a2dc --- /dev/null +++ b/iredis/data/commands/blmove.md @@ -0,0 +1,24 @@ +`BLMOVE` is the blocking variant of `LMOVE`. +When `source` contains elements, this command behaves exactly like `LMOVE`. +When used inside a `MULTI`/`EXEC` block, this command behaves exactly like `LMOVE`. +When `source` is empty, Redis will block the connection until another client +pushes to it or until `timeout` (a double value specifying the maximum number of seconds to block) is reached. +A `timeout` of zero can be used to block indefinitely. + +This command comes in place of the now deprecated `BRPOPLPUSH`. Doing +`BLMOVE RIGHT LEFT` is equivalent. + +See `LMOVE` for more information. + +@return + +@bulk-string-reply: the element being popped from `source` and pushed to `destination`. +If `timeout` is reached, a @nil-reply is returned. + +## Pattern: Reliable queue + +Please see the pattern description in the `LMOVE` documentation. + +## Pattern: Circular list + +Please see the pattern description in the `LMOVE` documentation. diff --git a/iredis/data/commands/blmpop.md b/iredis/data/commands/blmpop.md new file mode 100644 index 0000000..262713e --- /dev/null +++ b/iredis/data/commands/blmpop.md @@ -0,0 +1,15 @@ +`BLMPOP` is the blocking variant of `LMPOP`. + +When any of the lists contains elements, this command behaves exactly like `LMPOP`. +When used inside a `MULTI`/`EXEC` block, this command behaves exactly like `LMPOP`. +When all lists are empty, Redis will block the connection until another client pushes to it or until the `timeout` (a double value specifying the maximum number of seconds to block) elapses. +A `timeout` of zero can be used to block indefinitely. + +See `LMPOP` for more information. + +@return + +@array-reply: specifically: + +* A `nil` when no element could be popped, and timeout is reached. +* A two-element array with the first element being the name of the key from which elements were popped, and the second element is an array of elements. diff --git a/iredis/data/commands/blpop.md b/iredis/data/commands/blpop.md new file mode 100644 index 0000000..1d73fff --- /dev/null +++ b/iredis/data/commands/blpop.md @@ -0,0 +1,140 @@ +`BLPOP` is a blocking list pop primitive. +It is the blocking version of `LPOP` because it blocks the connection when there +are no elements to pop from any of the given lists. +An element is popped from the head of the first list that is non-empty, with the +given keys being checked in the order that they are given. + +## Non-blocking behavior + +When `BLPOP` is called, if at least one of the specified keys contains a +non-empty list, an element is popped from the head of the list and returned to +the caller together with the `key` it was popped from. + +Keys are checked in the order that they are given. +Let's say that the key `list1` doesn't exist and `list2` and `list3` hold +non-empty lists. +Consider the following command: + +``` +BLPOP list1 list2 list3 0 +``` + +`BLPOP` guarantees to return an element from the list stored at `list2` (since +it is the first non empty list when checking `list1`, `list2` and `list3` in +that order). + +## Blocking behavior + +If none of the specified keys exist, `BLPOP` blocks the connection until another +client performs an `LPUSH` or `RPUSH` operation against one of the keys. + +Once new data is present on one of the lists, the client returns with the name +of the key unblocking it and the popped value. + +When `BLPOP` causes a client to block and a non-zero timeout is specified, +the client will unblock returning a `nil` multi-bulk value when the specified +timeout has expired without a push operation against at least one of the +specified keys. + +**The timeout argument is interpreted as a double value specifying the maximum number of seconds to block**. A timeout of zero can be used to block indefinitely. + +## What key is served first? What client? What element? Priority ordering details. + +* If the client tries to blocks for multiple keys, but at least one key contains elements, the returned key / element pair is the first key from left to right that has one or more elements. In this case the client is not blocked. So for instance `BLPOP key1 key2 key3 key4 0`, assuming that both `key2` and `key4` are non-empty, will always return an element from `key2`. +* If multiple clients are blocked for the same key, the first client to be served is the one that was waiting for more time (the first that blocked for the key). Once a client is unblocked it does not retain any priority, when it blocks again with the next call to `BLPOP` it will be served accordingly to the number of clients already blocked for the same key, that will all be served before it (from the first to the last that blocked). +* When a client is blocking for multiple keys at the same time, and elements are available at the same time in multiple keys (because of a transaction or a Lua script added elements to multiple lists), the client will be unblocked using the first key that received a push operation (assuming it has enough elements to serve our client, as there may be other clients as well waiting for this key). Basically after the execution of every command Redis will run a list of all the keys that received data AND that have at least a client blocked. The list is ordered by new element arrival time, from the first key that received data to the last. For every key processed, Redis will serve all the clients waiting for that key in a FIFO fashion, as long as there are elements in this key. When the key is empty or there are no longer clients waiting for this key, the next key that received new data in the previous command / transaction / script is processed, and so forth. + +## Behavior of `!BLPOP` when multiple elements are pushed inside a list. + +There are times when a list can receive multiple elements in the context of the same conceptual command: + +* Variadic push operations such as `LPUSH mylist a b c`. +* After an `EXEC` of a `MULTI` block with multiple push operations against the same list. +* Executing a Lua Script with Redis 2.6 or newer. + +When multiple elements are pushed inside a list where there are clients blocking, the behavior is different for Redis 2.4 and Redis 2.6 or newer. + +For Redis 2.6 what happens is that the command performing multiple pushes is executed, and *only after* the execution of the command the blocked clients are served. Consider this sequence of commands. + + Client A: BLPOP foo 0 + Client B: LPUSH foo a b c + +If the above condition happens using a Redis 2.6 server or greater, Client **A** will be served with the `c` element, because after the `LPUSH` command the list contains `c,b,a`, so taking an element from the left means to return `c`. + +Instead Redis 2.4 works in a different way: clients are served *in the context* of the push operation, so as long as `LPUSH foo a b c` starts pushing the first element to the list, it will be delivered to the Client **A**, that will receive `a` (the first element pushed). + +The behavior of Redis 2.4 creates a lot of problems when replicating or persisting data into the AOF file, so the much more generic and semantically simpler behavior was introduced into Redis 2.6 to prevent problems. + +Note that for the same reason a Lua script or a `MULTI/EXEC` block may push elements into a list and afterward **delete the list**. In this case the blocked clients will not be served at all and will continue to be blocked as long as no data is present on the list after the execution of a single command, transaction, or script. + +## `!BLPOP` inside a `!MULTI` / `!EXEC` transaction + +`BLPOP` can be used with pipelining (sending multiple commands and +reading the replies in batch), however this setup makes sense almost solely +when it is the last command of the pipeline. + +Using `BLPOP` inside a `MULTI` / `EXEC` block does not make a lot of sense +as it would require blocking the entire server in order to execute the block +atomically, which in turn does not allow other clients to perform a push +operation. For this reason the behavior of `BLPOP` inside `MULTI` / `EXEC` when the list is empty is to return a `nil` multi-bulk reply, which is the same +thing that happens when the timeout is reached. + +If you like science fiction, think of time flowing at infinite speed inside a +`MULTI` / `EXEC` block... + +@return + +@array-reply: specifically: + +* A `nil` multi-bulk when no element could be popped and the timeout expired. +* A two-element multi-bulk with the first element being the name of the key + where an element was popped and the second element being the value of the + popped element. + +@examples + +``` +redis> DEL list1 list2 +(integer) 0 +redis> RPUSH list1 a b c +(integer) 3 +redis> BLPOP list1 list2 0 +1) "list1" +2) "a" +``` + +## Reliable queues + +When `BLPOP` returns an element to the client, it also removes the element from the list. This means that the element only exists in the context of the client: if the client crashes while processing the returned element, it is lost forever. + +This can be a problem with some application where we want a more reliable messaging system. When this is the case, please check the `BRPOPLPUSH` command, that is a variant of `BLPOP` that adds the returned element to a target list before returning it to the client. + +## Pattern: Event notification + +Using blocking list operations it is possible to mount different blocking +primitives. +For instance for some application you may need to block waiting for elements +into a Redis Set, so that as far as a new element is added to the Set, it is +possible to retrieve it without resort to polling. +This would require a blocking version of `SPOP` that is not available, but using +blocking list operations we can easily accomplish this task. + +The consumer will do: + +``` +LOOP forever + WHILE SPOP(key) returns elements + ... process elements ... + END + BRPOP helper_key +END +``` + +While in the producer side we'll use simply: + +``` +MULTI +SADD key element +LPUSH helper_key x +EXEC +``` diff --git a/iredis/data/commands/brpop.md b/iredis/data/commands/brpop.md new file mode 100644 index 0000000..dfa2b91 --- /dev/null +++ b/iredis/data/commands/brpop.md @@ -0,0 +1,32 @@ +`BRPOP` is a blocking list pop primitive. +It is the blocking version of `RPOP` because it blocks the connection when there +are no elements to pop from any of the given lists. +An element is popped from the tail of the first list that is non-empty, with the +given keys being checked in the order that they are given. + +See the [BLPOP documentation][cb] for the exact semantics, since `BRPOP` is +identical to `BLPOP` with the only difference being that it pops elements from +the tail of a list instead of popping from the head. + +[cb]: /commands/blpop + +@return + +@array-reply: specifically: + +* A `nil` multi-bulk when no element could be popped and the timeout expired. +* A two-element multi-bulk with the first element being the name of the key + where an element was popped and the second element being the value of the + popped element. + +@examples + +``` +redis> DEL list1 list2 +(integer) 0 +redis> RPUSH list1 a b c +(integer) 3 +redis> BRPOP list1 list2 0 +1) "list1" +2) "c" +``` diff --git a/iredis/data/commands/brpoplpush.md b/iredis/data/commands/brpoplpush.md new file mode 100644 index 0000000..9a6fe37 --- /dev/null +++ b/iredis/data/commands/brpoplpush.md @@ -0,0 +1,21 @@ +`BRPOPLPUSH` is the blocking variant of `RPOPLPUSH`. +When `source` contains elements, this command behaves exactly like `RPOPLPUSH`. +When used inside a `MULTI`/`EXEC` block, this command behaves exactly like `RPOPLPUSH`. +When `source` is empty, Redis will block the connection until another client +pushes to it or until `timeout` is reached. +A `timeout` of zero can be used to block indefinitely. + +See `RPOPLPUSH` for more information. + +@return + +@bulk-string-reply: the element being popped from `source` and pushed to `destination`. +If `timeout` is reached, a @nil-reply is returned. + +## Pattern: Reliable queue + +Please see the pattern description in the `RPOPLPUSH` documentation. + +## Pattern: Circular list + +Please see the pattern description in the `RPOPLPUSH` documentation. diff --git a/iredis/data/commands/bzmpop.md b/iredis/data/commands/bzmpop.md new file mode 100644 index 0000000..dc0c077 --- /dev/null +++ b/iredis/data/commands/bzmpop.md @@ -0,0 +1,16 @@ +`BZMPOP` is the blocking variant of `ZMPOP`. + +When any of the sorted sets contains elements, this command behaves exactly like `ZMPOP`. +When used inside a `MULTI`/`EXEC` block, this command behaves exactly like `ZMPOP`. +When all sorted sets are empty, Redis will block the connection until another client adds members to one of the keys or until the `timeout` (a double value specifying the maximum number of seconds to block) elapses. +A `timeout` of zero can be used to block indefinitely. + +See `ZMPOP` for more information. + +@return + +@array-reply: specifically: + +* A `nil` when no element could be popped. +* A two-element array with the first element being the name of the key from which elements were popped, and the second element is an array of the popped elements. Every entry in the elements array is also an array that contains the member and its score. + diff --git a/iredis/data/commands/bzpopmax.md b/iredis/data/commands/bzpopmax.md new file mode 100644 index 0000000..8155ed8 --- /dev/null +++ b/iredis/data/commands/bzpopmax.md @@ -0,0 +1,37 @@ +`BZPOPMAX` is the blocking variant of the sorted set `ZPOPMAX` primitive. + +It is the blocking version because it blocks the connection when there are no +members to pop from any of the given sorted sets. +A member with the highest score is popped from first sorted set that is +non-empty, with the given keys being checked in the order that they are given. + +The `timeout` argument is interpreted as a double value specifying the maximum +number of seconds to block. A timeout of zero can be used to block indefinitely. + +See the [BZPOPMIN documentation][cb] for the exact semantics, since `BZPOPMAX` +is identical to `BZPOPMIN` with the only difference being that it pops members +with the highest scores instead of popping the ones with the lowest scores. + +[cb]: /commands/bzpopmin + +@return + +@array-reply: specifically: + +* A `nil` multi-bulk when no element could be popped and the timeout expired. +* A three-element multi-bulk with the first element being the name of the key + where a member was popped, the second element is the popped member itself, + and the third element is the score of the popped element. + +@examples + +``` +redis> DEL zset1 zset2 +(integer) 0 +redis> ZADD zset1 0 a 1 b 2 c +(integer) 3 +redis> BZPOPMAX zset1 zset2 0 +1) "zset1" +2) "c" +3) "2" +``` diff --git a/iredis/data/commands/bzpopmin.md b/iredis/data/commands/bzpopmin.md new file mode 100644 index 0000000..b48a4fb --- /dev/null +++ b/iredis/data/commands/bzpopmin.md @@ -0,0 +1,37 @@ +`BZPOPMIN` is the blocking variant of the sorted set `ZPOPMIN` primitive. + +It is the blocking version because it blocks the connection when there are no +members to pop from any of the given sorted sets. +A member with the lowest score is popped from first sorted set that is +non-empty, with the given keys being checked in the order that they are given. + +The `timeout` argument is interpreted as a double value specifying the maximum +number of seconds to block. A timeout of zero can be used to block indefinitely. + +See the [BLPOP documentation][cl] for the exact semantics, since `BZPOPMIN` is +identical to `BLPOP` with the only difference being the data structure being +popped from. + +[cl]: /commands/blpop + +@return + +@array-reply: specifically: + +* A `nil` multi-bulk when no element could be popped and the timeout expired. +* A three-element multi-bulk with the first element being the name of the key + where a member was popped, the second element is the popped member itself, + and the third element is the score of the popped element. + +@examples + +``` +redis> DEL zset1 zset2 +(integer) 0 +redis> ZADD zset1 0 a 1 b 2 c +(integer) 3 +redis> BZPOPMIN zset1 zset2 0 +1) "zset1" +2) "a" +3) "0" +``` diff --git a/iredis/data/commands/client-caching.md b/iredis/data/commands/client-caching.md new file mode 100644 index 0000000..1f4b8b8 --- /dev/null +++ b/iredis/data/commands/client-caching.md @@ -0,0 +1,22 @@ +This command controls the tracking of the keys in the next command executed +by the connection, when tracking is enabled in `OPTIN` or `OPTOUT` mode. +Please check the +[client side caching documentation](/topics/client-side-caching) for +background information. + +When tracking is enabled Redis, using the `CLIENT TRACKING` command, it is +possible to specify the `OPTIN` or `OPTOUT` options, so that keys +in read only commands are not automatically remembered by the server to +be invalidated later. When we are in `OPTIN` mode, we can enable the +tracking of the keys in the next command by calling `CLIENT CACHING yes` +immediately before it. Similarly when we are in `OPTOUT` mode, and keys +are normally tracked, we can avoid the keys in the next command to be +tracked using `CLIENT CACHING no`. + +Basically the command sets a state in the connection, that is valid only +for the next command execution, that will modify the behavior of client +tracking. + +@return + +@simple-string-reply: `OK` or an error if the argument is not yes or no. diff --git a/iredis/data/commands/client-getname.md b/iredis/data/commands/client-getname.md new file mode 100644 index 0000000..f60539d --- /dev/null +++ b/iredis/data/commands/client-getname.md @@ -0,0 +1,5 @@ +The `CLIENT GETNAME` returns the name of the current connection as set by `CLIENT SETNAME`. Since every new connection starts without an associated name, if no name was assigned a null bulk reply is returned. + +@return + +@bulk-string-reply: The connection name, or a null bulk reply if no name is set. diff --git a/iredis/data/commands/client-getredir.md b/iredis/data/commands/client-getredir.md new file mode 100644 index 0000000..2cc3269 --- /dev/null +++ b/iredis/data/commands/client-getredir.md @@ -0,0 +1,11 @@ +This command returns the client ID we are redirecting our +[tracking](/topics/client-side-caching) notifications to. We set a client +to redirect to when using `CLIENT TRACKING` to enable tracking. However in +order to avoid forcing client libraries implementations to remember the +ID notifications are redirected to, this command exists in order to improve +introspection and allow clients to check later if redirection is active +and towards which client ID. + +@return + +@integer-reply: the ID of the client we are redirecting the notifications to. The command returns `-1` if client tracking is not enabled, or `0` if client tracking is enabled but we are not redirecting the notifications to any client. diff --git a/iredis/data/commands/client-help.md b/iredis/data/commands/client-help.md new file mode 100644 index 0000000..964a625 --- /dev/null +++ b/iredis/data/commands/client-help.md @@ -0,0 +1,5 @@ +The `CLIENT HELP` command returns a helpful text describing the different subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/client-id.md b/iredis/data/commands/client-id.md new file mode 100644 index 0000000..fe6723c --- /dev/null +++ b/iredis/data/commands/client-id.md @@ -0,0 +1,20 @@ +The command just returns the ID of the current connection. Every connection +ID has certain guarantees: + +1. It is never repeated, so if `CLIENT ID` returns the same number, the caller can be sure that the underlying client did not disconnect and reconnect the connection, but it is still the same connection. +2. The ID is monotonically incremental. If the ID of a connection is greater than the ID of another connection, it is guaranteed that the second connection was established with the server at a later time. + +This command is especially useful together with `CLIENT UNBLOCK` which was +introduced also in Redis 5 together with `CLIENT ID`. Check the `CLIENT UNBLOCK` command page for a pattern involving the two commands. + +@examples + +```cli +CLIENT ID +``` + +@return + +@integer-reply + +The id of the client. diff --git a/iredis/data/commands/client-info.md b/iredis/data/commands/client-info.md new file mode 100644 index 0000000..f60592e --- /dev/null +++ b/iredis/data/commands/client-info.md @@ -0,0 +1,13 @@ +The command returns information and statistics about the current client connection in a mostly human readable format. + +The reply format is identical to that of `CLIENT LIST`, and the content consists only of information about the current client. + +@examples + +```cli +CLIENT INFO +``` + +@return + +@bulk-string-reply: a unique string, as described at the `CLIENT LIST` page, for the current client. diff --git a/iredis/data/commands/client-kill.md b/iredis/data/commands/client-kill.md new file mode 100644 index 0000000..ea65aaf --- /dev/null +++ b/iredis/data/commands/client-kill.md @@ -0,0 +1,53 @@ +The `CLIENT KILL` command closes a given client connection. This command support two formats, the old format: + + CLIENT KILL addr:port + +The `ip:port` should match a line returned by the `CLIENT LIST` command (`addr` field). + +The new format: + + CLIENT KILL <filter> <value> ... ... <filter> <value> + +With the new form it is possible to kill clients by different attributes +instead of killing just by address. The following filters are available: + +* `CLIENT KILL ADDR ip:port`. This is exactly the same as the old three-arguments behavior. +* `CLIENT KILL LADDR ip:port`. Kill all clients connected to specified local (bind) address. +* `CLIENT KILL ID client-id`. Allows to kill a client by its unique `ID` field. Client `ID`'s are retrieved using the `CLIENT LIST` command. +* `CLIENT KILL TYPE type`, where *type* is one of `normal`, `master`, `replica` and `pubsub`. This closes the connections of **all the clients** in the specified class. Note that clients blocked into the `MONITOR` command are considered to belong to the `normal` class. +* `CLIENT KILL USER username`. Closes all the connections that are authenticated with the specified [ACL](/topics/acl) username, however it returns an error if the username does not map to an existing ACL user. +* `CLIENT KILL SKIPME yes/no`. By default this option is set to `yes`, that is, the client calling the command will not get killed, however setting this option to `no` will have the effect of also killing the client calling the command. + +It is possible to provide multiple filters at the same time. The command will handle multiple filters via logical AND. For example: + + CLIENT KILL addr 127.0.0.1:12345 type pubsub + +is valid and will kill only a pubsub client with the specified address. This format containing multiple filters is rarely useful currently. + +When the new form is used the command no longer returns `OK` or an error, but instead the number of killed clients, that may be zero. + +## CLIENT KILL and Redis Sentinel + +Recent versions of Redis Sentinel (Redis 2.8.12 or greater) use CLIENT KILL +in order to kill clients when an instance is reconfigured, in order to +force clients to perform the handshake with one Sentinel again and update +its configuration. + +## Notes + +Due to the single-threaded nature of Redis, it is not possible to +kill a client connection while it is executing a command. From +the client point of view, the connection can never be closed +in the middle of the execution of a command. However, the client +will notice the connection has been closed only when the +next command is sent (and results in network error). + +@return + +When called with the three arguments format: + +@simple-string-reply: `OK` if the connection exists and has been closed + +When called with the filter / value format: + +@integer-reply: the number of clients killed. diff --git a/iredis/data/commands/client-list.md b/iredis/data/commands/client-list.md new file mode 100644 index 0000000..6241425 --- /dev/null +++ b/iredis/data/commands/client-list.md @@ -0,0 +1,79 @@ +The `CLIENT LIST` command returns information and statistics about the client +connections server in a mostly human readable format. + +You can use one of the optional subcommands to filter the list. The `TYPE type` subcommand filters the list by clients' type, where *type* is one of `normal`, `master`, `replica`, and `pubsub`. Note that clients blocked by the `MONITOR` command belong to the `normal` class. + +The `ID` filter only returns entries for clients with IDs matching the `client-id` arguments. + +@return + +@bulk-string-reply: a unique string, formatted as follows: + +* One client connection per line (separated by LF) +* Each line is composed of a succession of `property=value` fields separated + by a space character. + +Here is the meaning of the fields: + +* `id`: a unique 64-bit client ID +* `addr`: address/port of the client +* `laddr`: address/port of local address client connected to (bind address) +* `fd`: file descriptor corresponding to the socket +* `name`: the name set by the client with `CLIENT SETNAME` +* `age`: total duration of the connection in seconds +* `idle`: idle time of the connection in seconds +* `flags`: client flags (see below) +* `db`: current database ID +* `sub`: number of channel subscriptions +* `psub`: number of pattern matching subscriptions +* `ssub`: number of shard channel subscriptions. Added in Redis 7.0.3 +* `multi`: number of commands in a MULTI/EXEC context +* `qbuf`: query buffer length (0 means no query pending) +* `qbuf-free`: free space of the query buffer (0 means the buffer is full) +* `argv-mem`: incomplete arguments for the next command (already extracted from query buffer) +* `multi-mem`: memory is used up by buffered multi commands. Added in Redis 7.0 +* `obl`: output buffer length +* `oll`: output list length (replies are queued in this list when the buffer is full) +* `omem`: output buffer memory usage +* `tot-mem`: total memory consumed by this client in its various buffers +* `events`: file descriptor events (see below) +* `cmd`: last command played +* `user`: the authenticated username of the client +* `redir`: client id of current client tracking redirection +* `resp`: client RESP protocol version. Added in Redis 7.0 + +The client flags can be a combination of: + +``` +A: connection to be closed ASAP +b: the client is waiting in a blocking operation +c: connection to be closed after writing entire reply +d: a watched keys has been modified - EXEC will fail +i: the client is waiting for a VM I/O (deprecated) +M: the client is a master +N: no specific flag set +O: the client is a client in MONITOR mode +P: the client is a Pub/Sub subscriber +r: the client is in readonly mode against a cluster node +S: the client is a replica node connection to this instance +u: the client is unblocked +U: the client is connected via a Unix domain socket +x: the client is in a MULTI/EXEC context +t: the client enabled keys tracking in order to perform client side caching +R: the client tracking target client is invalid +B: the client enabled broadcast tracking mode +``` + +The file descriptor events can be: + +``` +r: the client socket is readable (event loop) +w: the client socket is writable (event loop) +``` + +## Notes + +New fields are regularly added for debugging purpose. Some could be removed +in the future. A version safe Redis client using this command should parse +the output accordingly (i.e. handling gracefully missing fields, skipping +unknown fields). diff --git a/iredis/data/commands/client-no-evict.md b/iredis/data/commands/client-no-evict.md new file mode 100644 index 0000000..70070a6 --- /dev/null +++ b/iredis/data/commands/client-no-evict.md @@ -0,0 +1,11 @@ +The `CLIENT NO-EVICT` command sets the [client eviction](/topics/clients#client-eviction) mode for the current connection. + +When turned on and client eviction is configured, the current connection will be excluded from the client eviction process even if we're above the configured client eviction threshold. + +When turned off, the current client will be re-included in the pool of potential clients to be evicted (and evicted if needed). + +See [client eviction](/topics/clients#client-eviction) for more details. + +@return + +@simple-string-reply: `OK`. diff --git a/iredis/data/commands/client-pause.md b/iredis/data/commands/client-pause.md new file mode 100644 index 0000000..6f778da --- /dev/null +++ b/iredis/data/commands/client-pause.md @@ -0,0 +1,44 @@ +`CLIENT PAUSE` is a connections control command able to suspend all the Redis clients for the specified amount of time (in milliseconds). + +The command performs the following actions: + +* It stops processing all the pending commands from normal and pub/sub clients for the given mode. However interactions with replicas will continue normally. Note that clients are formally paused when they try to execute a command, so no work is taken on the server side for inactive clients. +* However it returns OK to the caller ASAP, so the `CLIENT PAUSE` command execution is not paused by itself. +* When the specified amount of time has elapsed, all the clients are unblocked: this will trigger the processing of all the commands accumulated in the query buffer of every client during the pause. + +Client pause currently supports two modes: + +* `ALL`: This is the default mode. All client commands are blocked. +* `WRITE`: Clients are only blocked if they attempt to execute a write command. + +For the `WRITE` mode, some commands have special behavior: + +* `EVAL`/`EVALSHA`: Will block client for all scripts. +* `PUBLISH`: Will block client. +* `PFCOUNT`: Will block client. +* `WAIT`: Acknowledgments will be delayed, so this command will appear blocked. + +This command is useful as it makes able to switch clients from a Redis instance to another one in a controlled way. For example during an instance upgrade the system administrator could do the following: + +* Pause the clients using `CLIENT PAUSE` +* Wait a few seconds to make sure the replicas processed the latest replication stream from the master. +* Turn one of the replicas into a master. +* Reconfigure clients to connect with the new master. + +Since Redis 6.2, the recommended mode for client pause is `WRITE`. This mode will stop all replication traffic, can be +aborted with the `CLIENT UNPAUSE` command, and allows reconfiguring the old master without risking accepting writes after the +failover. This is also the mode used during cluster failover. + +For versions before 6.2, it is possible to send `CLIENT PAUSE` in a MULTI/EXEC block together with the `INFO replication` command in order to get the current master offset at the time the clients are blocked. This way it is possible to wait for a specific offset in the replica side in order to make sure all the replication stream was processed. + +Since Redis 3.2.10 / 4.0.0, this command also prevents keys to be evicted or +expired during the time clients are paused. This way the dataset is guaranteed +to be static not just from the point of view of clients not being able to write, but also from the point of view of internal operations. + +@return + +@simple-string-reply: The command returns OK or an error if the timeout is invalid. + +## Behavior change history + +* `>= 3.2.0`: Client pause prevents client pause and key eviction as well.
\ No newline at end of file diff --git a/iredis/data/commands/client-reply.md b/iredis/data/commands/client-reply.md new file mode 100644 index 0000000..f2c3ed8 --- /dev/null +++ b/iredis/data/commands/client-reply.md @@ -0,0 +1,13 @@ +Sometimes it can be useful for clients to completely disable replies from the Redis server. For example when the client sends fire and forget commands or performs a mass loading of data, or in caching contexts where new data is streamed constantly. In such contexts to use server time and bandwidth in order to send back replies to clients, which are going to be ignored, is considered wasteful. + +The `CLIENT REPLY` command controls whether the server will reply the client's commands. The following modes are available: + +* `ON`. This is the default mode in which the server returns a reply to every command. +* `OFF`. In this mode the server will not reply to client commands. +* `SKIP`. This mode skips the reply of command immediately after it. + +@return + +When called with either `OFF` or `SKIP` subcommands, no reply is made. When called with `ON`: + +@simple-string-reply: `OK`. diff --git a/iredis/data/commands/client-setname.md b/iredis/data/commands/client-setname.md new file mode 100644 index 0000000..c1e70af --- /dev/null +++ b/iredis/data/commands/client-setname.md @@ -0,0 +1,19 @@ +The `CLIENT SETNAME` command assigns a name to the current connection. + +The assigned name is displayed in the output of `CLIENT LIST` so that it is possible to identify the client that performed a given connection. + +For instance when Redis is used in order to implement a queue, producers and consumers of messages may want to set the name of the connection according to their role. + +There is no limit to the length of the name that can be assigned if not the usual limits of the Redis string type (512 MB). However it is not possible to use spaces in the connection name as this would violate the format of the `CLIENT LIST` reply. + +It is possible to entirely remove the connection name setting it to the empty string, that is not a valid connection name since it serves to this specific purpose. + +The connection name can be inspected using `CLIENT GETNAME`. + +Every new connection starts without an assigned name. + +Tip: setting names to connections is a good way to debug connection leaks due to bugs in the application using Redis. + +@return + +@simple-string-reply: `OK` if the connection name was successfully set. diff --git a/iredis/data/commands/client-tracking.md b/iredis/data/commands/client-tracking.md new file mode 100644 index 0000000..e77f7d9 --- /dev/null +++ b/iredis/data/commands/client-tracking.md @@ -0,0 +1,33 @@ +This command enables the tracking feature of the Redis server, that is used +for [server assisted client side caching](/topics/client-side-caching). + +When tracking is enabled Redis remembers the keys that the connection +requested, in order to send later invalidation messages when such keys are +modified. Invalidation messages are sent in the same connection (only available +when the RESP3 protocol is used) or redirected in a different connection +(available also with RESP2 and Pub/Sub). A special *broadcasting* mode is +available where clients participating in this protocol receive every +notification just subscribing to given key prefixes, regardless of the +keys that they requested. Given the complexity of the argument please +refer to [the main client side caching documentation](/topics/client-side-caching) for the details. This manual page is only a reference for the options of this subcommand. + +In order to enable tracking, use: + + CLIENT TRACKING on ... options ... + +The feature will remain active in the current connection for all its life, +unless tracking is turned off with `CLIENT TRACKING off` at some point. + +The following are the list of options that modify the behavior of the +command when enabling tracking: + +* `REDIRECT <id>`: send invalidation messages to the connection with the specified ID. The connection must exist. You can get the ID of a connection using `CLIENT ID`. If the connection we are redirecting to is terminated, when in RESP3 mode the connection with tracking enabled will receive `tracking-redir-broken` push messages in order to signal the condition. +* `BCAST`: enable tracking in broadcasting mode. In this mode invalidation messages are reported for all the prefixes specified, regardless of the keys requested by the connection. Instead when the broadcasting mode is not enabled, Redis will track which keys are fetched using read-only commands, and will report invalidation messages only for such keys. +* `PREFIX <prefix>`: for broadcasting, register a given key prefix, so that notifications will be provided only for keys starting with this string. This option can be given multiple times to register multiple prefixes. If broadcasting is enabled without this option, Redis will send notifications for every key. You can't delete a single prefix, but you can delete all prefixes by disabling and re-enabling tracking. Using this option adds the additional time complexity of O(N^2), where N is the total number of prefixes tracked. +* `OPTIN`: when broadcasting is NOT active, normally don't track keys in read only commands, unless they are called immediately after a `CLIENT CACHING yes` command. +* `OPTOUT`: when broadcasting is NOT active, normally track keys in read only commands, unless they are called immediately after a `CLIENT CACHING no` command. +* `NOLOOP`: don't send notifications about keys modified by this connection itself. + +@return + +@simple-string-reply: `OK` if the connection was successfully put in tracking mode or if the tracking mode was successfully disabled. Otherwise an error is returned. diff --git a/iredis/data/commands/client-trackinginfo.md b/iredis/data/commands/client-trackinginfo.md new file mode 100644 index 0000000..82de43e --- /dev/null +++ b/iredis/data/commands/client-trackinginfo.md @@ -0,0 +1,18 @@ +The command returns information about the current client connection's use of the [server assisted client side caching](/topics/client-side-caching) feature. + +@return + +@array-reply: a list of tracking information sections and their respective values, specifically: + +* **flags**: A list of tracking flags used by the connection. The flags and their meanings are as follows: + * `off`: The connection isn't using server assisted client side caching. + * `on`: Server assisted client side caching is enabled for the connection. + * `bcast`: The client uses broadcasting mode. + * `optin`: The client does not cache keys by default. + * `optout`: The client caches keys by default. + * `caching-yes`: The next command will cache keys (exists only together with `optin`). + * `caching-no`: The next command won't cache keys (exists only together with `optout`). + * `noloop`: The client isn't notified about keys modified by itself. + * `broken_redirect`: The client ID used for redirection isn't valid anymore. +* **redirect**: The client ID used for notifications redirection, or -1 when none. +* **prefixes**: A list of key prefixes for which notifications are sent to the client. diff --git a/iredis/data/commands/client-unblock.md b/iredis/data/commands/client-unblock.md new file mode 100644 index 0000000..11dff98 --- /dev/null +++ b/iredis/data/commands/client-unblock.md @@ -0,0 +1,58 @@ +This command can unblock, from a different connection, a client blocked in a blocking operation, such as for instance `BRPOP` or `XREAD` or `WAIT`. + +By default the client is unblocked as if the timeout of the command was +reached, however if an additional (and optional) argument is passed, it is possible to specify the unblocking behavior, that can be **TIMEOUT** (the default) or **ERROR**. If **ERROR** is specified, the behavior is to unblock the client returning as error the fact that the client was force-unblocked. Specifically the client will receive the following error: + + -UNBLOCKED client unblocked via CLIENT UNBLOCK + +Note: of course as usually it is not guaranteed that the error text remains +the same, however the error code will remain `-UNBLOCKED`. + +This command is useful especially when we are monitoring many keys with +a limited number of connections. For instance we may want to monitor multiple +streams with `XREAD` without using more than N connections. However at some +point the consumer process is informed that there is one more stream key +to monitor. In order to avoid using more connections, the best behavior would +be to stop the blocking command from one of the connections in the pool, add +the new key, and issue the blocking command again. + +To obtain this behavior the following pattern is used. The process uses +an additional *control connection* in order to send the `CLIENT UNBLOCK` command +if needed. In the meantime, before running the blocking operation on the other +connections, the process runs `CLIENT ID` in order to get the ID associated +with that connection. When a new key should be added, or when a key should +no longer be monitored, the relevant connection blocking command is aborted +by sending `CLIENT UNBLOCK` in the control connection. The blocking command +will return and can be finally reissued. + +This example shows the application in the context of Redis streams, however +the pattern is a general one and can be applied to other cases. + +@examples + +``` +Connection A (blocking connection): +> CLIENT ID +2934 +> BRPOP key1 key2 key3 0 +(client is blocked) + +... Now we want to add a new key ... + +Connection B (control connection): +> CLIENT UNBLOCK 2934 +1 + +Connection A (blocking connection): +... BRPOP reply with timeout ... +NULL +> BRPOP key1 key2 key3 key4 0 +(client is blocked again) +``` + +@return + +@integer-reply, specifically: + +* `1` if the client was unblocked successfully. +* `0` if the client wasn't unblocked. diff --git a/iredis/data/commands/client-unpause.md b/iredis/data/commands/client-unpause.md new file mode 100644 index 0000000..c438485 --- /dev/null +++ b/iredis/data/commands/client-unpause.md @@ -0,0 +1,5 @@ +`CLIENT UNPAUSE` is used to resume command processing for all clients that were paused by `CLIENT PAUSE`. + +@return + +@simple-string-reply: The command returns `OK` diff --git a/iredis/data/commands/client.md b/iredis/data/commands/client.md new file mode 100644 index 0000000..fdfd0e8 --- /dev/null +++ b/iredis/data/commands/client.md @@ -0,0 +1,3 @@ +This is a container command for client connection commands. + +To see the list of available commands you can call `CLIENT HELP`.
\ No newline at end of file diff --git a/iredis/data/commands/cluster-addslots.md b/iredis/data/commands/cluster-addslots.md new file mode 100644 index 0000000..0604066 --- /dev/null +++ b/iredis/data/commands/cluster-addslots.md @@ -0,0 +1,51 @@ +This command is useful in order to modify a node's view of the cluster +configuration. Specifically it assigns a set of hash slots to the node +receiving the command. If the command is successful, the node will map +the specified hash slots to itself, and will start broadcasting the new +configuration. + +However note that: + +1. The command only works if all the specified slots are, from the point of view of the node receiving the command, currently not assigned. A node will refuse to take ownership for slots that already belong to some other node (including itself). +2. The command fails if the same slot is specified multiple times. +3. As a side effect of the command execution, if a slot among the ones specified as argument is set as `importing`, this state gets cleared once the node assigns the (previously unbound) slot to itself. + +## Example + +For example the following command assigns slots 1 2 3 to the node receiving +the command: + + > CLUSTER ADDSLOTS 1 2 3 + OK + +However trying to execute it again results into an error since the slots +are already assigned: + + > CLUSTER ADDSLOTS 1 2 3 + ERR Slot 1 is already busy + +## Usage in Redis Cluster + +This command only works in cluster mode and is useful in the following +Redis Cluster operations: + +1. To create a new cluster ADDSLOTS is used in order to initially setup master nodes splitting the available hash slots among them. +2. In order to fix a broken cluster where certain slots are unassigned. + +## Information about slots propagation and warnings + +Note that once a node assigns a set of slots to itself, it will start +propagating this information in heartbeat packet headers. However the +other nodes will accept the information only if they have the slot as +not already bound with another node, or if the configuration epoch of the +node advertising the new hash slot, is greater than the node currently listed +in the table. + +This means that this command should be used with care only by applications +orchestrating Redis Cluster, like `redis-cli`, and the command if used +out of the right context can leave the cluster in a wrong state or cause +data loss. + +@return + +@simple-string-reply: `OK` if the command was successful. Otherwise an error is returned. diff --git a/iredis/data/commands/cluster-addslotsrange.md b/iredis/data/commands/cluster-addslotsrange.md new file mode 100644 index 0000000..a00e23f --- /dev/null +++ b/iredis/data/commands/cluster-addslotsrange.md @@ -0,0 +1,27 @@ +The `CLUSTER ADDSLOTSRANGE` is similar to the `CLUSTER ADDSLOTS` command in that they both assign hash slots to nodes. + +The difference between the two commands is that `ADDSLOTS` takes a list of slots to assign to the node, while `ADDSLOTSRANGE` takes a list of slot ranges (specified by start and end slots) to assign to the node. + +## Example + +To assign slots 1 2 3 4 5 to the node, the `ADDSLOTS` command is: + + > CLUSTER ADDSLOTS 1 2 3 4 5 + OK + +The same operation can be completed with the following `ADDSLOTSRANGE` command: + + > CLUSTER ADDSLOTSRANGE 1 5 + OK + + +## Usage in Redis Cluster + +This command only works in cluster mode and is useful in the following Redis Cluster operations: + +1. To create a new cluster ADDSLOTSRANGE is used in order to initially setup master nodes splitting the available hash slots among them. +2. In order to fix a broken cluster where certain slots are unassigned. + +@return + +@simple-string-reply: `OK` if the command was successful. Otherwise an error is returned. diff --git a/iredis/data/commands/cluster-bumpepoch.md b/iredis/data/commands/cluster-bumpepoch.md new file mode 100644 index 0000000..b05694a --- /dev/null +++ b/iredis/data/commands/cluster-bumpepoch.md @@ -0,0 +1,9 @@ +Advances the cluster config epoch. + +The `CLUSTER BUMPEPOCH` command triggers an increment to the cluster's config epoch from the connected node. The epoch will be incremented if the node's config epoch is zero, or if it is less than the cluster's greatest epoch. + +**Note:** config epoch management is performed internally by the cluster, and relies on obtaining a consensus of nodes. The `CLUSTER BUMPEPOCH` attempts to increment the config epoch **WITHOUT** getting the consensus, so using it may violate the "last failover wins" rule. Use it with caution. + +@return + +@simple-string-reply: `BUMPED` if the epoch was incremented, or `STILL` if the node already has the greatest config epoch in the cluster. diff --git a/iredis/data/commands/cluster-count-failure-reports.md b/iredis/data/commands/cluster-count-failure-reports.md new file mode 100644 index 0000000..ac1ef71 --- /dev/null +++ b/iredis/data/commands/cluster-count-failure-reports.md @@ -0,0 +1,22 @@ +The command returns the number of *failure reports* for the specified node. +Failure reports are the way Redis Cluster uses in order to promote a +`PFAIL` state, that means a node is not reachable, to a `FAIL` state, +that means that the majority of masters in the cluster agreed within +a window of time that the node is not reachable. + +A few more details: + +* A node flags another node with `PFAIL` when the node is not reachable for a time greater than the configured *node timeout*, which is a fundamental configuration parameter of a Redis Cluster. +* Nodes in `PFAIL` state are provided in gossip sections of heartbeat packets. +* Every time a node processes gossip packets from other nodes, it creates (and refreshes the TTL if needed) **failure reports**, remembering that a given node said another given node is in `PFAIL` condition. +* Each failure report has a time to live of two times the *node timeout* time. +* If at a given time a node has another node flagged with `PFAIL`, and at the same time collected the majority of other master nodes *failure reports* about this node (including itself if it is a master), then it elevates the failure state of the node from `PFAIL` to `FAIL`, and broadcasts a message forcing all the nodes that can be reached to flag the node as `FAIL`. + +This command returns the number of failure reports for the current node which are currently not expired (so received within two times the *node timeout* time). The count does not include what the node we are asking this count believes about the node ID we pass as argument, the count *only* includes the failure reports the node received from other nodes. + +This command is mainly useful for debugging, when the failure detector of +Redis Cluster is not operating as we believe it should. + +@return + +@integer-reply: the number of active failure reports for the node. diff --git a/iredis/data/commands/cluster-countkeysinslot.md b/iredis/data/commands/cluster-countkeysinslot.md new file mode 100644 index 0000000..0bffec8 --- /dev/null +++ b/iredis/data/commands/cluster-countkeysinslot.md @@ -0,0 +1,13 @@ +Returns the number of keys in the specified Redis Cluster hash slot. The +command only queries the local data set, so contacting a node +that is not serving the specified hash slot will always result in a count of +zero being returned. + +``` +> CLUSTER COUNTKEYSINSLOT 7000 +(integer) 50341 +``` + +@return + +@integer-reply: The number of keys in the specified hash slot, or an error if the hash slot is invalid. diff --git a/iredis/data/commands/cluster-delslots.md b/iredis/data/commands/cluster-delslots.md new file mode 100644 index 0000000..77204e1 --- /dev/null +++ b/iredis/data/commands/cluster-delslots.md @@ -0,0 +1,48 @@ +In Redis Cluster, each node keeps track of which master is serving +a particular hash slot. + +The `CLUSTER DELSLOTS` command asks a particular Redis Cluster node to +forget which master is serving the hash slots specified as arguments. + +In the context of a node that has received a `CLUSTER DELSLOTS` command and +has consequently removed the associations for the passed hash slots, +we say those hash slots are *unbound*. Note that the existence of +unbound hash slots occurs naturally when a node has not been +configured to handle them (something that can be done with the +`CLUSTER ADDSLOTS` command) and if it has not received any information about +who owns those hash slots (something that it can learn from heartbeat +or update messages). + +If a node with unbound hash slots receives a heartbeat packet from +another node that claims to be the owner of some of those hash +slots, the association is established instantly. Moreover, if a +heartbeat or update message is received with a configuration epoch +greater than the node's own, the association is re-established. + +However, note that: + +1. The command only works if all the specified slots are already +associated with some node. +2. The command fails if the same slot is specified multiple times. +3. As a side effect of the command execution, the node may go into +*down* state because not all hash slots are covered. + +## Example + +The following command removes the association for slots 5000 and +5001 from the node receiving the command: + + > CLUSTER DELSLOTS 5000 5001 + OK + +## Usage in Redis Cluster + +This command only works in cluster mode and may be useful for +debugging and in order to manually orchestrate a cluster configuration +when a new cluster is created. It is currently not used by `redis-cli`, +and mainly exists for API completeness. + +@return + +@simple-string-reply: `OK` if the command was successful. Otherwise +an error is returned. diff --git a/iredis/data/commands/cluster-delslotsrange.md b/iredis/data/commands/cluster-delslotsrange.md new file mode 100644 index 0000000..e4c1f2b --- /dev/null +++ b/iredis/data/commands/cluster-delslotsrange.md @@ -0,0 +1,32 @@ +The `CLUSTER DELSLOTSRANGE` command is similar to the `CLUSTER DELSLOTS` command in that they both remove hash slots from the node. +The difference is that `CLUSTER DELSLOTS` takes a list of hash slots to remove from the node, while `CLUSTER DELSLOTSRANGE` takes a list of slot ranges (specified by start and end slots) to remove from the node. + +## Example + +To remove slots 1 2 3 4 5 from the node, the `CLUSTER DELSLOTS` command is: + + > CLUSTER DELSLOTS 1 2 3 4 5 + OK + +The same operation can be completed with the following `CLUSTER DELSLOTSRANGE` command: + + > CLUSTER DELSLOTSRANGE 1 5 + OK + +However, note that: + +1. The command only works if all the specified slots are already associated with the node. +2. The command fails if the same slot is specified multiple times. +3. As a side effect of the command execution, the node may go into *down* state because not all hash slots are covered. + +## Usage in Redis Cluster + +This command only works in cluster mode and may be useful for +debugging and in order to manually orchestrate a cluster configuration +when a new cluster is created. It is currently not used by `redis-cli`, +and mainly exists for API completeness. + +@return + +@simple-string-reply: `OK` if the command was successful. Otherwise +an error is returned. diff --git a/iredis/data/commands/cluster-failover.md b/iredis/data/commands/cluster-failover.md new file mode 100644 index 0000000..911eaea --- /dev/null +++ b/iredis/data/commands/cluster-failover.md @@ -0,0 +1,67 @@ +This command, that can only be sent to a Redis Cluster replica node, forces +the replica to start a manual failover of its master instance. + +A manual failover is a special kind of failover that is usually executed when +there are no actual failures, but we wish to swap the current master with one +of its replicas (which is the node we send the command to), in a safe way, +without any window for data loss. It works in the following way: + +1. The replica tells the master to stop processing queries from clients. +2. The master replies to the replica with the current *replication offset*. +3. The replica waits for the replication offset to match on its side, to make sure it processed all the data from the master before it continues. +4. The replica starts a failover, obtains a new configuration epoch from the majority of the masters, and broadcasts the new configuration. +5. The old master receives the configuration update: unblocks its clients and starts replying with redirection messages so that they'll continue the chat with the new master. + +This way clients are moved away from the old master to the new master +atomically and only when the replica that is turning into the new master +has processed all of the replication stream from the old master. + +## FORCE option: manual failover when the master is down + +The command behavior can be modified by two options: **FORCE** and **TAKEOVER**. + +If the **FORCE** option is given, the replica does not perform any handshake +with the master, that may be not reachable, but instead just starts a +failover ASAP starting from point 4. This is useful when we want to start +a manual failover while the master is no longer reachable. + +However using **FORCE** we still need the majority of masters to be available +in order to authorize the failover and generate a new configuration epoch +for the replica that is going to become master. + +## TAKEOVER option: manual failover without cluster consensus + +There are situations where this is not enough, and we want a replica to failover +without any agreement with the rest of the cluster. A real world use case +for this is to mass promote replicas in a different data center to masters +in order to perform a data center switch, while all the masters are down +or partitioned away. + +The **TAKEOVER** option implies everything **FORCE** implies, but also does +not uses any cluster authorization in order to failover. A replica receiving +`CLUSTER FAILOVER TAKEOVER` will instead: + +1. Generate a new `configEpoch` unilaterally, just taking the current greatest epoch available and incrementing it if its local configuration epoch is not already the greatest. +2. Assign itself all the hash slots of its master, and propagate the new configuration to every node which is reachable ASAP, and eventually to every other node. + +Note that **TAKEOVER violates the last-failover-wins principle** of Redis Cluster, since the configuration epoch generated by the replica violates the normal generation of configuration epochs in several ways: + +1. There is no guarantee that it is actually the higher configuration epoch, since, for example, we can use the **TAKEOVER** option within a minority, nor any message exchange is performed to generate the new configuration epoch. +2. If we generate a configuration epoch which happens to collide with another instance, eventually our configuration epoch, or the one of another instance with our same epoch, will be moved away using the *configuration epoch collision resolution algorithm*. + +Because of this the **TAKEOVER** option should be used with care. + +## Implementation details and notes + +* `CLUSTER FAILOVER`, unless the **TAKEOVER** option is specified, does not execute a failover synchronously. + It only *schedules* a manual failover, bypassing the failure detection stage. +* An `OK` reply is no guarantee that the failover will succeed. +* A replica can only be promoted to a master if it is known as a replica by a majority of the masters in the cluster. + If the replica is a new node that has just been added to the cluster (for example after upgrading it), it may not yet be known to all the masters in the cluster. + To check that the masters are aware of a new replica, you can send `CLUSTER NODES` or `CLUSTER REPLICAS` to each of the master nodes and check that it appears as a replica, before sending `CLUSTER FAILOVER` to the replica. +* To check that the failover has actually happened you can use `ROLE`, `INFO REPLICATION` (which indicates "role:master" after successful failover), or `CLUSTER NODES` to verify that the state of the cluster has changed sometime after the command was sent. +* To check if the failover has failed, check the replica's log for "Manual failover timed out", which is logged if the replica has given up after a few seconds. + +@return + +@simple-string-reply: `OK` if the command was accepted and a manual failover is going to be attempted. An error if the operation cannot be executed, for example if we are talking with a node which is already a master. diff --git a/iredis/data/commands/cluster-flushslots.md b/iredis/data/commands/cluster-flushslots.md new file mode 100644 index 0000000..b0b3fdf --- /dev/null +++ b/iredis/data/commands/cluster-flushslots.md @@ -0,0 +1,7 @@ +Deletes all slots from a node. + +The `CLUSTER FLUSHSLOTS` deletes all information about slots from the connected node. It can only be called when the database is empty. + +@return + +@simple-string-reply: `OK` diff --git a/iredis/data/commands/cluster-forget.md b/iredis/data/commands/cluster-forget.md new file mode 100644 index 0000000..6bff506 --- /dev/null +++ b/iredis/data/commands/cluster-forget.md @@ -0,0 +1,57 @@ +The command is used in order to remove a node, specified via its node ID, +from the set of *known nodes* of the Redis Cluster node receiving the command. +In other words the specified node is removed from the *nodes table* of the +node receiving the command. + +Because when a given node is part of the cluster, all the other nodes +participating in the cluster knows about it, in order for a node to be +completely removed from a cluster, the `CLUSTER FORGET` command must be +sent to all the remaining nodes, regardless of the fact they are masters +or replicas. + +However the command cannot simply drop the node from the internal node +table of the node receiving the command, it also implements a ban-list, not +allowing the same node to be added again as a side effect of processing the +*gossip section* of the heartbeat packets received from other nodes. + +## Details on why the ban-list is needed + +In the following example we'll show why the command must not just remove +a given node from the nodes table, but also prevent it for being re-inserted +again for some time. + +Let's assume we have four nodes, A, B, C and D. In order to +end with just a three nodes cluster A, B, C we may follow these steps: + +1. Reshard all the hash slots from D to nodes A, B, C. +2. D is now empty, but still listed in the nodes table of A, B and C. +3. We contact A, and send `CLUSTER FORGET D`. +4. B sends node A a heartbeat packet, where node D is listed. +5. A does no longer known node D (see step 3), so it starts a handshake with D. +6. D ends re-added in the nodes table of A. + +As you can see in this way removing a node is fragile, we need to send +`CLUSTER FORGET` commands to all the nodes ASAP hoping there are no +gossip sections processing in the meantime. Because of this problem the +command implements a ban-list with an expire time for each entry. + +So what the command really does is: + +1. The specified node gets removed from the nodes table. +2. The node ID of the removed node gets added to the ban-list, for 1 minute. +3. The node will skip all the node IDs listed in the ban-list when processing gossip sections received in heartbeat packets from other nodes. + +This way we have a 60 second window to inform all the nodes in the cluster that +we want to remove a node. + +## Special conditions not allowing the command execution + +The command does not succeed and returns an error in the following cases: + +1. The specified node ID is not found in the nodes table. +2. The node receiving the command is a replica, and the specified node ID identifies its current master. +3. The node ID identifies the same node we are sending the command to. + +@return + +@simple-string-reply: `OK` if the command was executed successfully, otherwise an error is returned. diff --git a/iredis/data/commands/cluster-getkeysinslot.md b/iredis/data/commands/cluster-getkeysinslot.md new file mode 100644 index 0000000..120bf44 --- /dev/null +++ b/iredis/data/commands/cluster-getkeysinslot.md @@ -0,0 +1,20 @@ +The command returns an array of keys names stored in the contacted node and +hashing to the specified hash slot. The maximum number of keys to return +is specified via the `count` argument, so that it is possible for the user +of this API to batch-processing keys. + +The main usage of this command is during rehashing of cluster slots from one +node to another. The way the rehashing is performed is exposed in the Redis +Cluster specification, or in a more simple to digest form, as an appendix +of the `CLUSTER SETSLOT` command documentation. + +``` +> CLUSTER GETKEYSINSLOT 7000 3 +1) "key_39015" +2) "key_89793" +3) "key_92937" +``` + +@return + +@array-reply: From 0 to *count* key names in a Redis array reply. diff --git a/iredis/data/commands/cluster-help.md b/iredis/data/commands/cluster-help.md new file mode 100644 index 0000000..3b1e159 --- /dev/null +++ b/iredis/data/commands/cluster-help.md @@ -0,0 +1,5 @@ +The `CLUSTER HELP` command returns a helpful text describing the different subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/cluster-info.md b/iredis/data/commands/cluster-info.md new file mode 100644 index 0000000..372cc73 --- /dev/null +++ b/iredis/data/commands/cluster-info.md @@ -0,0 +1,52 @@ +`CLUSTER INFO` provides `INFO` style information about Redis Cluster vital parameters. +The following fields are always present in the reply: + +``` +cluster_state:ok +cluster_slots_assigned:16384 +cluster_slots_ok:16384 +cluster_slots_pfail:0 +cluster_slots_fail:0 +cluster_known_nodes:6 +cluster_size:3 +cluster_current_epoch:6 +cluster_my_epoch:2 +cluster_stats_messages_sent:1483972 +cluster_stats_messages_received:1483968 +total_cluster_links_buffer_limit_exceeded:0 +``` + +* `cluster_state`: State is `ok` if the node is able to receive queries. `fail` if there is at least one hash slot which is unbound (no node associated), in error state (node serving it is flagged with FAIL flag), or if the majority of masters can't be reached by this node. +* `cluster_slots_assigned`: Number of slots which are associated to some node (not unbound). This number should be 16384 for the node to work properly, which means that each hash slot should be mapped to a node. +* `cluster_slots_ok`: Number of hash slots mapping to a node not in `FAIL` or `PFAIL` state. +* `cluster_slots_pfail`: Number of hash slots mapping to a node in `PFAIL` state. Note that those hash slots still work correctly, as long as the `PFAIL` state is not promoted to `FAIL` by the failure detection algorithm. `PFAIL` only means that we are currently not able to talk with the node, but may be just a transient error. +* `cluster_slots_fail`: Number of hash slots mapping to a node in `FAIL` state. If this number is not zero the node is not able to serve queries unless `cluster-require-full-coverage` is set to `no` in the configuration. +* `cluster_known_nodes`: The total number of known nodes in the cluster, including nodes in `HANDSHAKE` state that may not currently be proper members of the cluster. +* `cluster_size`: The number of master nodes serving at least one hash slot in the cluster. +* `cluster_current_epoch`: The local `Current Epoch` variable. This is used in order to create unique increasing version numbers during fail overs. +* `cluster_my_epoch`: The `Config Epoch` of the node we are talking with. This is the current configuration version assigned to this node. +* `cluster_stats_messages_sent`: Number of messages sent via the cluster node-to-node binary bus. +* `cluster_stats_messages_received`: Number of messages received via the cluster node-to-node binary bus. +* `total_cluster_links_buffer_limit_exceeded`: Accumulated count of cluster links freed due to exceeding the `cluster-link-sendbuf-limit` configuration. + +The following message-related fields may be included in the reply if the value is not 0: +Each message type includes statistics on the number of messages sent and received. +Here are the explanation of these fields: + +* `cluster_stats_messages_ping_sent` and `cluster_stats_messages_ping_received`: Cluster bus PING (not to be confused with the client command `PING`). +* `cluster_stats_messages_pong_sent` and `cluster_stats_messages_pong_received`: PONG (reply to PING). +* `cluster_stats_messages_meet_sent` and `cluster_stats_messages_meet_received`: Handshake message sent to a new node, either through gossip or `CLUSTER MEET`. +* `cluster_stats_messages_fail_sent` and `cluster_stats_messages_fail_received`: Mark node xxx as failing. +* `cluster_stats_messages_publish_sent` and `cluster_stats_messages_publish_received`: Pub/Sub Publish propagation, see [Pubsub](/topics/pubsub#pubsub). +* `cluster_stats_messages_auth-req_sent` and `cluster_stats_messages_auth-req_received`: Replica initiated leader election to replace its master. +* `cluster_stats_messages_auth-ack_sent` and `cluster_stats_messages_auth-ack_received`: Message indicating a vote during leader election. +* `cluster_stats_messages_update_sent` and `cluster_stats_messages_update_received`: Another node slots configuration. +* `cluster_stats_messages_mfstart_sent` and `cluster_stats_messages_mfstart_received`: Pause clients for manual failover. +* `cluster_stats_messages_module_sent` and `cluster_stats_messages_module_received`: Module cluster API message. +* `cluster_stats_messages_publishshard_sent` and `cluster_stats_messages_publishshard_received`: Pub/Sub Publish shard propagation, see [Sharded Pubsub](/topics/pubsub#sharded-pubsub). + +More information about the Current Epoch and Config Epoch variables are available in the [Redis Cluster specification document](/topics/cluster-spec#cluster-current-epoch). + +@return + +@bulk-string-reply: A map between named fields and values in the form of `<field>:<value>` lines separated by newlines composed by the two bytes `CRLF`. diff --git a/iredis/data/commands/cluster-keyslot.md b/iredis/data/commands/cluster-keyslot.md new file mode 100644 index 0000000..7e03587 --- /dev/null +++ b/iredis/data/commands/cluster-keyslot.md @@ -0,0 +1,24 @@ +Returns an integer identifying the hash slot the specified key hashes to. +This command is mainly useful for debugging and testing, since it exposes +via an API the underlying Redis implementation of the hashing algorithm. +Example use cases for this command: + +1. Client libraries may use Redis in order to test their own hashing algorithm, generating random keys and hashing them with both their local implementation and using Redis `CLUSTER KEYSLOT` command, then checking if the result is the same. +2. Humans may use this command in order to check what is the hash slot, and then the associated Redis Cluster node, responsible for a given key. + +## Example + +``` +> CLUSTER KEYSLOT somekey +(integer) 11058 +> CLUSTER KEYSLOT foo{hash_tag} +(integer) 2515 +> CLUSTER KEYSLOT bar{hash_tag} +(integer) 2515 +``` + +Note that the command implements the full hashing algorithm, including support for **hash tags**, that is the special property of Redis Cluster key hashing algorithm, of hashing just what is between `{` and `}` if such a pattern is found inside the key name, in order to force multiple keys to be handled by the same node. + +@return + +@integer-reply: The hash slot number. diff --git a/iredis/data/commands/cluster-links.md b/iredis/data/commands/cluster-links.md new file mode 100644 index 0000000..7b33762 --- /dev/null +++ b/iredis/data/commands/cluster-links.md @@ -0,0 +1,48 @@ +Each node in a Redis Cluster maintains a pair of long-lived TCP link with each peer in the cluster: One for sending outbound messages towards the peer and one for receiving inbound messages from the peer. + +`CLUSTER LINKS` outputs information of all such peer links as an array, where each array element is a map that contains attributes and their values for an individual link. + +@examples + +The following is an example output: + +``` +> CLUSTER LINKS +1) 1) "direction" + 2) "to" + 3) "node" + 4) "8149d745fa551e40764fecaf7cab9dbdf6b659ae" + 5) "create-time" + 6) (integer) 1639442739375 + 7) "events" + 8) "rw" + 9) "send-buffer-allocated" + 10) (integer) 4512 + 11) "send-buffer-used" + 12) (integer) 0 +2) 1) "direction" + 2) "from" + 3) "node" + 4) "8149d745fa551e40764fecaf7cab9dbdf6b659ae" + 5) "create-time" + 6) (integer) 1639442739411 + 7) "events" + 8) "r" + 9) "send-buffer-allocated" + 10) (integer) 0 + 11) "send-buffer-used" + 12) (integer) 0 +``` + +Each map is composed of the following attributes of the corresponding cluster link and their values: + +1. `direction`: This link is established by the local node `to` the peer, or accepted by the local node `from` the peer. +2. `node`: The node id of the peer. +3. `create-time`: Creation time of the link. (In the case of a `to` link, this is the time when the TCP link is created by the local node, not the time when it is actually established.) +4. `events`: Events currently registered for the link. `r` means readable event, `w` means writable event. +5. `send-buffer-allocated`: Allocated size of the link's send buffer, which is used to buffer outgoing messages toward the peer. +6. `send-buffer-used`: Size of the portion of the link's send buffer that is currently holding data(messages). + +@return + +@array-reply: An array of maps where each map contains various attributes and their values of a cluster link. diff --git a/iredis/data/commands/cluster-meet.md b/iredis/data/commands/cluster-meet.md new file mode 100644 index 0000000..b33c9fb --- /dev/null +++ b/iredis/data/commands/cluster-meet.md @@ -0,0 +1,42 @@ +`CLUSTER MEET` is used in order to connect different Redis nodes with cluster +support enabled, into a working cluster. + +The basic idea is that nodes by default don't trust each other, and are +considered unknown, so that it is unlikely that different cluster nodes will +mix into a single one because of system administration errors or network +addresses modifications. + +So in order for a given node to accept another one into the list of nodes +composing a Redis Cluster, there are only two ways: + +1. The system administrator sends a `CLUSTER MEET` command to force a node to meet another one. +2. An already known node sends a list of nodes in the gossip section that we are not aware of. If the receiving node trusts the sending node as a known node, it will process the gossip section and send a handshake to the nodes that are still not known. + +Note that Redis Cluster needs to form a full mesh (each node is connected with each other node), but in order to create a cluster, there is no need to send all the `CLUSTER MEET` commands needed to form the full mesh. What matter is to send enough `CLUSTER MEET` messages so that each node can reach each other node through a *chain of known nodes*. Thanks to the exchange of gossip information in heartbeat packets, the missing links will be created. + +So, if we link node A with node B via `CLUSTER MEET`, and B with C, A and C will find their ways to handshake and create a link. + +Another example: if we imagine a cluster formed of the following four nodes called A, B, C and D, we may send just the following set of commands to A: + +1. `CLUSTER MEET B-ip B-port` +2. `CLUSTER MEET C-ip C-port` +3. `CLUSTER MEET D-ip D-port` + +As a side effect of `A` knowing and being known by all the other nodes, it will send gossip sections in the heartbeat packets that will allow each other node to create a link with each other one, forming a full mesh in a matter of seconds, even if the cluster is large. + +Moreover `CLUSTER MEET` does not need to be reciprocal. If I send the command to A in order to join B, I don't need to also send it to B in order to join A. + +If the optional `cluster_bus_port` argument is not provided, the default of port + 10000 will be used. + +## Implementation details: MEET and PING packets + +When a given node receives a `CLUSTER MEET` message, the node specified in the +command still does not know the node we sent the command to. So in order for +the node to force the receiver to accept it as a trusted node, it sends a +`MEET` packet instead of a `PING` packet. The two packets have exactly the +same format, but the former forces the receiver to acknowledge the node as +trusted. + +@return + +@simple-string-reply: `OK` if the command was successful. If the address or port specified are invalid an error is returned. diff --git a/iredis/data/commands/cluster-myid.md b/iredis/data/commands/cluster-myid.md new file mode 100644 index 0000000..02e8b1d --- /dev/null +++ b/iredis/data/commands/cluster-myid.md @@ -0,0 +1,7 @@ +Returns the node's id. + +The `CLUSTER MYID` command returns the unique, auto-generated identifier that is associated with the connected cluster node. + +@return + +@bulk-string-reply: The node id.
\ No newline at end of file diff --git a/iredis/data/commands/cluster-nodes.md b/iredis/data/commands/cluster-nodes.md new file mode 100644 index 0000000..2ec706c --- /dev/null +++ b/iredis/data/commands/cluster-nodes.md @@ -0,0 +1,110 @@ +Each node in a Redis Cluster has its view of the current cluster configuration, +given by the set of known nodes, the state of the connection we have with such +nodes, their flags, properties and assigned slots, and so forth. + +`CLUSTER NODES` provides all this information, that is, the current cluster +configuration of the node we are contacting, in a serialization format which +happens to be exactly the same as the one used by Redis Cluster itself in +order to store on disk the cluster state (however the on disk cluster state +has a few additional info appended at the end). + +Note that normally clients willing to fetch the map between Cluster +hash slots and node addresses should use `CLUSTER SLOTS` instead. +`CLUSTER NODES`, that provides more information, should be used for +administrative tasks, debugging, and configuration inspections. +It is also used by `redis-cli` in order to manage a cluster. + +## Serialization format + +The output of the command is just a space-separated CSV string, where +each line represents a node in the cluster. The following is an example +of output: + +``` +07c37dfeb235213a872192d90877d0cd55635b91 127.0.0.1:30004@31004 slave e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca 0 1426238317239 4 connected +67ed2db8d677e59ec4a4cefb06858cf2a1a89fa1 127.0.0.1:30002@31002 master - 0 1426238316232 2 connected 5461-10922 +292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f 127.0.0.1:30003@31003 master - 0 1426238318243 3 connected 10923-16383 +6ec23923021cf3ffec47632106199cb7f496ce01 127.0.0.1:30005@31005 slave 67ed2db8d677e59ec4a4cefb06858cf2a1a89fa1 0 1426238316232 5 connected +824fe116063bc5fcf9f4ffd895bc17aee7731ac3 127.0.0.1:30006@31006 slave 292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f 0 1426238317741 6 connected +e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca 127.0.0.1:30001@31001 myself,master - 0 0 1 connected 0-5460 +``` + +Each line is composed of the following fields: + +``` +<id> <ip:port@cport> <flags> <master> <ping-sent> <pong-recv> <config-epoch> <link-state> <slot> <slot> ... <slot> +``` + +The meaning of each filed is the following: + +1. `id`: The node ID, a 40 characters random string generated when a node is created and never changed again (unless `CLUSTER RESET HARD` is used). +2. `ip:port@cport`: The node address where clients should contact the node to run queries. +3. `flags`: A list of comma separated flags: `myself`, `master`, `slave`, `fail?`, `fail`, `handshake`, `noaddr`, `nofailover`, `noflags`. Flags are explained in detail in the next section. +4. `master`: If the node is a replica, and the master is known, the master node ID, otherwise the "-" character. +5. `ping-sent`: Milliseconds unix time at which the currently active ping was sent, or zero if there are no pending pings. +6. `pong-recv`: Milliseconds unix time the last pong was received. +7. `config-epoch`: The configuration epoch (or version) of the current node (or of the current master if the node is a replica). Each time there is a failover, a new, unique, monotonically increasing configuration epoch is created. If multiple nodes claim to serve the same hash slots, the one with higher configuration epoch wins. +8. `link-state`: The state of the link used for the node-to-node cluster bus. We use this link to communicate with the node. Can be `connected` or `disconnected`. +9. `slot`: A hash slot number or range. Starting from argument number 9, but there may be up to 16384 entries in total (limit never reached). This is the list of hash slots served by this node. If the entry is just a number, is parsed as such. If it is a range, it is in the form `start-end`, and means that the node is responsible for all the hash slots from `start` to `end` including the start and end values. + +Meaning of the flags (field number 3): + +* `myself`: The node you are contacting. +* `master`: Node is a master. +* `slave`: Node is a replica. +* `fail?`: Node is in `PFAIL` state. Not reachable for the node you are contacting, but still logically reachable (not in `FAIL` state). +* `fail`: Node is in `FAIL` state. It was not reachable for multiple nodes that promoted the `PFAIL` state to `FAIL`. +* `handshake`: Untrusted node, we are handshaking. +* `noaddr`: No address known for this node. +* `nofailover`: Replica will not try to failover. +* `noflags`: No flags at all. + +## Notes on published config epochs + +Replicas broadcast their master's config epochs (in order to get an `UPDATE` +message if they are found to be stale), so the real config epoch of the +replica (which is meaningless more or less, since they don't serve hash slots) +can be only obtained checking the node flagged as `myself`, which is the entry +of the node we are asking to generate `CLUSTER NODES` output. The other +replicas epochs reflect what they publish in heartbeat packets, which is, the +configuration epoch of the masters they are currently replicating. + +## Special slot entries + +Normally hash slots associated to a given node are in one of the following formats, +as already explained above: + +1. Single number: 3894 +2. Range: 3900-4000 + +However node hash slots can be in a special state, used in order to communicate errors after a node restart (mismatch between the keys in the AOF/RDB file, and the node hash slots configuration), or when there is a resharding operation in progress. This two states are **importing** and **migrating**. + +The meaning of the two states is explained in the Redis Specification, however the gist of the two states is the following: + +* **Importing** slots are yet not part of the nodes hash slot, there is a migration in progress. The node will accept queries about these slots only if the `ASK` command is used. +* **Migrating** slots are assigned to the node, but are being migrated to some other node. The node will accept queries if all the keys in the command exist already, otherwise it will emit what is called an **ASK redirection**, to force new keys creation directly in the importing node. + +Importing and migrating slots are emitted in the `CLUSTER NODES` output as follows: + +* **Importing slot:** `[slot_number-<-importing_from_node_id]` +* **Migrating slot:** `[slot_number->-migrating_to_node_id]` + +The following are a few examples of importing and migrating slots: + +* `[93-<-292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f]` +* `[1002-<-67ed2db8d677e59ec4a4cefb06858cf2a1a89fa1]` +* `[77->-e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca]` +* `[16311->-292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f]` + +Note that the format does not have any space, so `CLUSTER NODES` output format is plain CSV with space as separator even when this special slots are emitted. However a complete parser for the format should be able to handle them. + +Note that: + +1. Migration and importing slots are only added to the node flagged as `myself`. This information is local to a node, for its own slots. +2. Importing and migrating slots are provided as **additional info**. If the node has a given hash slot assigned, it will be also a plain number in the list of hash slots, so clients that don't have a clue about hash slots migrations can just skip this special fields. + +@return + +@bulk-string-reply: The serialized cluster configuration. + +**A note about the word slave used in this man page and command name**: Starting with Redis 5, if not for backward compatibility, the Redis project no longer uses the word slave. Unfortunately in this command the word slave is part of the protocol, so we'll be able to remove such occurrences only when this API will be naturally deprecated. diff --git a/iredis/data/commands/cluster-replicas.md b/iredis/data/commands/cluster-replicas.md new file mode 100644 index 0000000..4e6192e --- /dev/null +++ b/iredis/data/commands/cluster-replicas.md @@ -0,0 +1,15 @@ +The command provides a list of replica nodes replicating from the specified +master node. The list is provided in the same format used by `CLUSTER NODES` (please refer to its documentation for the specification of the format). + +The command will fail if the specified node is not known or if it is not +a master according to the node table of the node receiving the command. + +Note that if a replica is added, moved, or removed from a given master node, +and we ask `CLUSTER REPLICAS` to a node that has not yet received the +configuration update, it may show stale information. However eventually +(in a matter of seconds if there are no network partitions) all the nodes +will agree about the set of nodes associated with a given master. + +@return + +The command returns data in the same format as `CLUSTER NODES`. diff --git a/iredis/data/commands/cluster-replicate.md b/iredis/data/commands/cluster-replicate.md new file mode 100644 index 0000000..5b403aa --- /dev/null +++ b/iredis/data/commands/cluster-replicate.md @@ -0,0 +1,26 @@ +The command reconfigures a node as a replica of the specified master. +If the node receiving the command is an *empty master*, as a side effect +of the command, the node role is changed from master to replica. + +Once a node is turned into the replica of another master node, there is no need +to inform the other cluster nodes about the change: heartbeat packets exchanged +between nodes will propagate the new configuration automatically. + +A replica will always accept the command, assuming that: + +1. The specified node ID exists in its nodes table. +2. The specified node ID does not identify the instance we are sending the command to. +3. The specified node ID is a master. + +If the node receiving the command is not already a replica, but is a master, +the command will only succeed, and the node will be converted into a replica, +only if the following additional conditions are met: + +1. The node is not serving any hash slots. +2. The node is empty, no keys are stored at all in the key space. + +If the command succeeds the new replica will immediately try to contact its master in order to replicate from it. + +@return + +@simple-string-reply: `OK` if the command was executed successfully, otherwise an error is returned. diff --git a/iredis/data/commands/cluster-reset.md b/iredis/data/commands/cluster-reset.md new file mode 100644 index 0000000..02ffe9e --- /dev/null +++ b/iredis/data/commands/cluster-reset.md @@ -0,0 +1,25 @@ +Reset a Redis Cluster node, in a more or less drastic way depending on the +reset type, that can be **hard** or **soft**. Note that this command +**does not work for masters if they hold one or more keys**, in that case +to completely reset a master node keys must be removed first, e.g. by using `FLUSHALL` first, +and then `CLUSTER RESET`. + +Effects on the node: + +1. All the other nodes in the cluster are forgotten. +2. All the assigned / open slots are reset, so the slots-to-nodes mapping is totally cleared. +3. If the node is a replica it is turned into an (empty) master. Its dataset is flushed, so at the end the node will be an empty master. +4. **Hard reset only**: a new Node ID is generated. +5. **Hard reset only**: `currentEpoch` and `configEpoch` vars are set to 0. +6. The new configuration is persisted on disk in the node cluster configuration file. + +This command is mainly useful to re-provision a Redis Cluster node +in order to be used in the context of a new, different cluster. The command +is also extensively used by the Redis Cluster testing framework in order to +reset the state of the cluster every time a new test unit is executed. + +If no reset type is specified, the default is **soft**. + +@return + +@simple-string-reply: `OK` if the command was successful. Otherwise an error is returned. diff --git a/iredis/data/commands/cluster-saveconfig.md b/iredis/data/commands/cluster-saveconfig.md new file mode 100644 index 0000000..31308c2 --- /dev/null +++ b/iredis/data/commands/cluster-saveconfig.md @@ -0,0 +1,15 @@ +Forces a node to save the `nodes.conf` configuration on disk. Before to return +the command calls `fsync(2)` in order to make sure the configuration is +flushed on the computer disk. + +This command is mainly used in the event a `nodes.conf` node state file +gets lost / deleted for some reason, and we want to generate it again from +scratch. It can also be useful in case of mundane alterations of a node cluster +configuration via the `CLUSTER` command in order to ensure the new configuration +is persisted on disk, however all the commands should normally be able to +auto schedule to persist the configuration on disk when it is important +to do so for the correctness of the system in the event of a restart. + +@return + +@simple-string-reply: `OK` or an error if the operation fails. diff --git a/iredis/data/commands/cluster-set-config-epoch.md b/iredis/data/commands/cluster-set-config-epoch.md new file mode 100644 index 0000000..71f458f --- /dev/null +++ b/iredis/data/commands/cluster-set-config-epoch.md @@ -0,0 +1,25 @@ +This command sets a specific *config epoch* in a fresh node. It only works when: + +1. The nodes table of the node is empty. +2. The node current *config epoch* is zero. + +These prerequisites are needed since usually, manually altering the +configuration epoch of a node is unsafe, we want to be sure that the node with +the higher configuration epoch value (that is the last that failed over) wins +over other nodes in claiming the hash slots ownership. + +However there is an exception to this rule, and it is when a new +cluster is created from scratch. Redis Cluster *config epoch collision +resolution* algorithm can deal with new nodes all configured with the +same configuration at startup, but this process is slow and should be +the exception, only to make sure that whatever happens, two more +nodes eventually always move away from the state of having the same +configuration epoch. + +So, using `CLUSTER SET-CONFIG-EPOCH`, when a new cluster is created, we can +assign a different progressive configuration epoch to each node before +joining the cluster together. + +@return + +@simple-string-reply: `OK` if the command was executed successfully, otherwise an error is returned. diff --git a/iredis/data/commands/cluster-setslot.md b/iredis/data/commands/cluster-setslot.md new file mode 100644 index 0000000..e712d36 --- /dev/null +++ b/iredis/data/commands/cluster-setslot.md @@ -0,0 +1,85 @@ +`CLUSTER SETSLOT` is responsible of changing the state of a hash slot in the receiving node in different ways. It can, depending on the subcommand used: + +1. `MIGRATING` subcommand: Set a hash slot in *migrating* state. +2. `IMPORTING` subcommand: Set a hash slot in *importing* state. +3. `STABLE` subcommand: Clear any importing / migrating state from hash slot. +4. `NODE` subcommand: Bind the hash slot to a different node. + +The command with its set of subcommands is useful in order to start and end cluster live resharding operations, which are accomplished by setting a hash slot in migrating state in the source node, and importing state in the destination node. + +Each subcommand is documented below. At the end you'll find a description of +how live resharding is performed using this command and other related commands. + +## CLUSTER SETSLOT `<slot>` MIGRATING `<destination-node-id>` + +This subcommand sets a slot to *migrating* state. In order to set a slot +in this state, the node receiving the command must be the hash slot owner, +otherwise an error is returned. + +When a slot is set in migrating state, the node changes behavior in the +following way: + +1. If a command is received about an existing key, the command is processed as usually. +2. If a command is received about a key that does not exists, an `ASK` redirection is emitted by the node, asking the client to retry only that specific query into `destination-node`. In this case the client should not update its hash slot to node mapping. +3. If the command contains multiple keys, in case none exist, the behavior is the same as point 2, if all exist, it is the same as point 1, however if only a partial number of keys exist, the command emits a `TRYAGAIN` error in order for the keys interested to finish being migrated to the target node, so that the multi keys command can be executed. + +## CLUSTER SETSLOT `<slot>` IMPORTING `<source-node-id>` + +This subcommand is the reverse of `MIGRATING`, and prepares the destination +node to import keys from the specified source node. The command only works if +the node is not already owner of the specified hash slot. + +When a slot is set in importing state, the node changes behavior in the following way: + +1. Commands about this hash slot are refused and a `MOVED` redirection is generated as usually, but in the case the command follows an `ASKING` command, in this case the command is executed. + +In this way when a node in migrating state generates an `ASK` redirection, the client contacts the target node, sends `ASKING`, and immediately after sends the command. This way commands about non-existing keys in the old node or keys already migrated to the target node are executed in the target node, so that: + +1. New keys are always created in the target node. During a hash slot migration we'll have to move only old keys, not new ones. +2. Commands about keys already migrated are correctly processed in the context of the node which is the target of the migration, the new hash slot owner, in order to guarantee consistency. +3. Without `ASKING` the behavior is the same as usually. This guarantees that clients with a broken hash slots mapping will not write for error in the target node, creating a new version of a key that has yet to be migrated. + +## CLUSTER SETSLOT `<slot>` STABLE + +This subcommand just clears migrating / importing state from the slot. It is +mainly used to fix a cluster stuck in a wrong state by `redis-cli --cluster fix`. +Normally the two states are cleared automatically at the end of the migration +using the `SETSLOT ... NODE ...` subcommand as explained in the next section. + +## CLUSTER SETSLOT `<slot>` NODE `<node-id>` + +The `NODE` subcommand is the one with the most complex semantics. It +associates the hash slot with the specified node, however the command works +only in specific situations and has different side effects depending on the +slot state. The following is the set of pre-conditions and side effects of the +command: + +1. If the current hash slot owner is the node receiving the command, but for effect of the command the slot would be assigned to a different node, the command will return an error if there are still keys for that hash slot in the node receiving the command. +2. If the slot is in *migrating* state, the state gets cleared when the slot is assigned to another node. +3. If the slot was in *importing* state in the node receiving the command, and the command assigns the slot to this node (which happens in the target node at the end of the resharding of a hash slot from one node to another), the command has the following side effects: A) the *importing* state is cleared. B) If the node config epoch is not already the greatest of the cluster, it generates a new one and assigns the new config epoch to itself. This way its new hash slot ownership will win over any past configuration created by previous failovers or slot migrations. + +It is important to note that step 3 is the only time when a Redis Cluster node will create a new config epoch without agreement from other nodes. This only happens when a manual configuration is operated. However it is impossible that this creates a non-transient setup where two nodes have the same config epoch, since Redis Cluster uses a config epoch collision resolution algorithm. + +@return + +@simple-string-reply: All the subcommands return `OK` if the command was successful. Otherwise an error is returned. + +## Redis Cluster live resharding explained + +The `CLUSTER SETSLOT` command is an important piece used by Redis Cluster in order to migrate all the keys contained in one hash slot from one node to another. This is how the migration is orchestrated, with the help of other commands as well. We'll call the node that has the current ownership of the hash slot the `source` node, and the node where we want to migrate the `destination` node. + +1. Set the destination node slot to *importing* state using `CLUSTER SETSLOT <slot> IMPORTING <source-node-id>`. +2. Set the source node slot to *migrating* state using `CLUSTER SETSLOT <slot> MIGRATING <destination-node-id>`. +3. Get keys from the source node with `CLUSTER GETKEYSINSLOT` command and move them into the destination node using the `MIGRATE` command. +4. Send `CLUSTER SETSLOT <slot> NODE <destination-node-id>` to the destination node. +5. Send `CLUSTER SETSLOT <slot> NODE <destination-node-id>` to the source node. +6. Send `CLUSTER SETSLOT <slot> NODE <destination-node-id>` to the other master nodes (optional). + +Notes: + +* The order of step 1 and 2 is important. We want the destination node to be ready to accept `ASK` redirections when the source node is configured to redirect. +* The order of step 4 and 5 is important. + The destination node is responsible for propagating the change to the rest of the cluster. + If the source node is informed before the destination node and the destination node crashes before it is set as new slot owner, the slot is left with no owner, even after a successful failover. +* Step 6, sending `SETSLOT` to the nodes not involved in the resharding, is not technically necessary since the configuration will eventually propagate itself. + However, it is a good idea to do so in order to stop nodes from pointing to the wrong node for the hash slot moved as soon as possible, resulting in less redirections to find the right node. diff --git a/iredis/data/commands/cluster-shards.md b/iredis/data/commands/cluster-shards.md new file mode 100644 index 0000000..bca6d1c --- /dev/null +++ b/iredis/data/commands/cluster-shards.md @@ -0,0 +1,153 @@ +`CLUSTER SHARDS` returns details about the shards of the cluster. +A shard is defined as a collection of nodes that serve the same set of slots and that replicate from each other. +A shard may only have a single master at a given time, but may have multiple or no replicas. +It is possible for a shard to not be serving any slots while still having replicas. + +This command replaces the `CLUSTER SLOTS` command, by providing a more efficient and extensible representation of the cluster. + +The command is suitable to be used by Redis Cluster client libraries in order to understand the topology of the cluster. +A client should issue this command on startup in order to retrieve the map associating cluster *hash slots* with actual node information. +This map should be used to direct commands to the node that is likely serving the slot associated with a given command. +In the event the command is sent to the wrong node, in that it received a '-MOVED' redirect, this command can then be used to update the topology of the cluster. + +The command returns an array of shards, with each shard containing two fields, 'slots' and 'nodes'. + +The 'slots' field is a list of slot ranges served by this shard, stored as pair of integers representing the inclusive start and end slots of the ranges. +For example, if a node owns the slots 1, 2, 3, 5, 7, 8 and 9, the slots ranges would be stored as [1-3], [5-5], [7-9]. +The slots field would therefor be represented by the following list of integers. + +``` +1) 1) "slots" + 2) 1) (integer) 1 + 2) (integer) 3 + 3) (integer) 5 + 4) (integer) 5 + 5) (integer) 7 + 6) (integer) 9 +``` + +The 'nodes' field contains a list of all nodes within the shard. +Each individual node is a map of attributes that describe the node. +Some attributes are optional and more attributes may be added in the future. +The current list of attributes: + +* id: The unique node id for this particular node. +* endpoint: The preferred endpoint to reach the node, see below for more information about the possible values of this field. +* ip: The IP address to send requests to for this node. +* hostname (optional): The announced hostname to send requests to for this node. +* port (optional): The TCP (non-TLS) port of the node. At least one of port or tls-port will be present. +* tls-port (optional): The TLS port of the node. At least one of port or tls-port will be present. +* role: The replication role of this node. +* replication-offset: The replication offset of this node. This information can be used to send commands to the most up to date replicas. +* health: Either `online`, `failed`, or `loading`. This information should be used to determine which nodes should be sent traffic. The `loading` health state should be used to know that a node is not currently eligible to serve traffic, but may be eligible in the future. + +The endpoint, along with the port, defines the location that clients should use to send requests for a given slot. +A NULL value for the endpoint indicates the node has an unknown endpoint and the client should connect to the same endpoint it used to send the `CLUSTER SHARDS` command but with the port returned from the command. +This unknown endpoint configuration is useful when the Redis nodes are behind a load balancer that Redis doesn't know the endpoint of. +Which endpoint is set is determined by the `cluster-preferred-endpoint-type` config. + +@return + +@array-reply: nested list of a map of hash ranges and shard nodes. + +@examples + +``` +> CLUSTER SHARDS +1) 1) "slots" + 2) 1) (integer) 10923 + 2) (integer) 11110 + 3) (integer) 11113 + 4) (integer) 16111 + 5) (integer) 16113 + 6) (integer) 16383 + 3) "nodes" + 4) 1) 1) "id" + 2) "71f058078c142a73b94767a4e78e9033d195dfb4" + 3) "port" + 4) (integer) 6381 + 5) "ip" + 6) "127.0.0.1" + 7) "role" + 8) "primary" + 9) "replication-offset" + 10) (integer) 1500 + 11) "health" + 12) "online" + 2) 1) "id" + 2) "1461967c62eab0e821ed54f2c98e594fccfd8736" + 3) "port" + 4) (integer) 7381 + 5) "ip" + 6) "127.0.0.1" + 7) "role" + 8) "replica" + 9) "replication-offset" + 10) (integer) 700 + 11) "health" + 12) "fail" +2) 1) "slots" + 2) 1) (integer) 5461 + 2) (integer) 10922 + 3) "nodes" + 4) 1) 1) "id" + 2) "9215e30cd4a71070088778080565de6ef75fd459" + 3) "port" + 4) (integer) 6380 + 5) "ip" + 6) "127.0.0.1" + 7) "role" + 8) "primary" + 9) "replication-offset" + 10) (integer) 1200 + 11) "health" + 12) "online" + 2) 1) "id" + 2) "877fa59da72cb902d0563d3d8def3437fc3a0196" + 3) "port" + 4) (integer) 7380 + 5) "ip" + 6) "127.0.0.1" + 7) "role" + 8) "replica" + 9) "replication-offset" + 10) (integer) 1100 + 11) "health" + 12) "loading" +3) 1) "slots" + 2) 1) (integer) 0 + 2) (integer) 5460 + 3) (integer) 11111 + 4) (integer) 11112 + 3) (integer) 16112 + 4) (integer) 16112 + 3) "nodes" + 4) 1) 1) "id" + 2) "b7e9acc0def782aabe6b596f67f06c73c2ffff93" + 3) "port" + 4) (integer) 7379 + 5) "ip" + 6) "127.0.0.1" + 7) "hostname" + 8) "example.com" + 9) "role" + 10) "replica" + 11) "replication-offset" + 12) "primary" + 13) "health" + 14) "online" + 2) 1) "id" + 2) "e2acf1a97c055fd09dcc2c0dcc62b19a6905dbc8" + 3) "port" + 4) (integer) 6379 + 5) "ip" + 6) "127.0.0.1" + 7) "hostname" + 8) "example.com" + 9) "role" + 10) "replica" + 11) "replication-offset" + 12) (integer) 0 + 13) "health" + 14) "loading" +```
\ No newline at end of file diff --git a/iredis/data/commands/cluster-slaves.md b/iredis/data/commands/cluster-slaves.md new file mode 100644 index 0000000..d90eaf3 --- /dev/null +++ b/iredis/data/commands/cluster-slaves.md @@ -0,0 +1,17 @@ +**A note about the word slave used in this man page and command name**: starting with Redis version 5, if not for backward compatibility, the Redis project no longer uses the word slave. Please use the new command `CLUSTER REPLICAS`. The command `CLUSTER SLAVES` will continue to work for backward compatibility. + +The command provides a list of replica nodes replicating from the specified +master node. The list is provided in the same format used by `CLUSTER NODES` (please refer to its documentation for the specification of the format). + +The command will fail if the specified node is not known or if it is not +a master according to the node table of the node receiving the command. + +Note that if a replica is added, moved, or removed from a given master node, +and we ask `CLUSTER SLAVES` to a node that has not yet received the +configuration update, it may show stale information. However eventually +(in a matter of seconds if there are no network partitions) all the nodes +will agree about the set of nodes associated with a given master. + +@return + +The command returns data in the same format as `CLUSTER NODES`. diff --git a/iredis/data/commands/cluster-slots.md b/iredis/data/commands/cluster-slots.md new file mode 100644 index 0000000..68901fe --- /dev/null +++ b/iredis/data/commands/cluster-slots.md @@ -0,0 +1,92 @@ +`CLUSTER SLOTS` returns details about which cluster slots map to which Redis instances. +The command is suitable to be used by Redis Cluster client libraries implementations in order to retrieve (or update when a redirection is received) the map associating cluster *hash slots* with actual nodes network information, so that when a command is received, it can be sent to what is likely the right instance for the keys specified in the command. + +The networking information for each node is an array containing the following elements: + +* Preferred endpoint (Either an IP address, hostname, or NULL) +* Port number +* The node ID +* A map of additional networking metadata + +The preferred endpoint, along with the port, defines the location that clients should use to send requests for a given slot. +A NULL value for the endpoint indicates the node has an unknown endpoint and the client should connect to the same endpoint it used to send the `CLUSTER SLOTS` command but with the port returned from the command. +This unknown endpoint configuration is useful when the Redis nodes are behind a load balancer that Redis doesn't know the endpoint of. +Which endpoint is set as preferred is determined by the `cluster-preferred-endpoint-type` config. + +Additional networking metadata is provided as a map on the fourth argument for each node. +The following networking metadata may be returned: + +* IP: When the preferred endpoint is not set to IP. +* Hostname: When a node has an announced hostname but the primary endpoint is not set to hostname. + +## Nested Result Array +Each nested result is: + + - Start slot range + - End slot range + - Master for slot range represented as nested networking information + - First replica of master for slot range + - Second replica + - ...continues until all replicas for this master are returned. + +Each result includes all active replicas of the master instance +for the listed slot range. Failed replicas are not returned. + +The third nested reply is guaranteed to be the networking information of the master instance for the slot range. +All networking information after the third nested reply are replicas of the master. + +If a cluster instance has non-contiguous slots (e.g. 1-400,900,1800-6000) then master and replica networking information results will be duplicated for each top-level slot range reply. + +@return + +@array-reply: nested list of slot ranges with networking information. + +@examples + +``` +> CLUSTER SLOTS +1) 1) (integer) 0 + 2) (integer) 5460 + 3) 1) "127.0.0.1" + 2) (integer) 30001 + 3) "09dbe9720cda62f7865eabc5fd8857c5d2678366" + 4) 1) hostname + 2) "host-1.redis.example.com" + 4) 1) "127.0.0.1" + 2) (integer) 30004 + 3) "821d8ca00d7ccf931ed3ffc7e3db0599d2271abf" + 4) 1) hostname + 2) "host-2.redis.example.com" +2) 1) (integer) 5461 + 2) (integer) 10922 + 3) 1) "127.0.0.1" + 2) (integer) 30002 + 3) "c9d93d9f2c0c524ff34cc11838c2003d8c29e013" + 4) 1) hostname + 2) "host-3.redis.example.com" + 4) 1) "127.0.0.1" + 2) (integer) 30005 + 3) "faadb3eb99009de4ab72ad6b6ed87634c7ee410f" + 4) 1) hostname + 2) "host-4.redis.example.com" +3) 1) (integer) 10923 + 2) (integer) 16383 + 3) 1) "127.0.0.1" + 2) (integer) 30003 + 3) "044ec91f325b7595e76dbcb18cc688b6a5b434a1" + 4) 1) hostname + 2) "host-5.redis.example.com" + 4) 1) "127.0.0.1" + 2) (integer) 30006 + 3) "58e6e48d41228013e5d9c1c37c5060693925e97e" + 4) 1) hostname + 2) "host-6.redis.example.com" +``` + +**Warning:** In future versions there could be more elements describing the node better. +In general a client implementation should just rely on the fact that certain parameters are at fixed positions as specified, but more parameters may follow and should be ignored. +Similarly a client library should try if possible to cope with the fact that older versions may just have the primary endpoint and port parameter. + +## Behavior change history + +* `>= 7.0.0`: Added support for hostnames and unknown endpoints in first field of node response.
\ No newline at end of file diff --git a/iredis/data/commands/cluster.md b/iredis/data/commands/cluster.md new file mode 100644 index 0000000..86d5c00 --- /dev/null +++ b/iredis/data/commands/cluster.md @@ -0,0 +1,3 @@ +This is a container command for Redis Cluster commands. + +To see the list of available commands you can call `CLUSTER HELP`. diff --git a/iredis/data/commands/command-count.md b/iredis/data/commands/command-count.md new file mode 100644 index 0000000..a198dd3 --- /dev/null +++ b/iredis/data/commands/command-count.md @@ -0,0 +1,11 @@ +Returns @integer-reply of number of total commands in this Redis server. + +@return + +@integer-reply: number of commands returned by `COMMAND` + +@examples + +```cli +COMMAND COUNT +``` diff --git a/iredis/data/commands/command-docs.md b/iredis/data/commands/command-docs.md new file mode 100644 index 0000000..35ea017 --- /dev/null +++ b/iredis/data/commands/command-docs.md @@ -0,0 +1,55 @@ +Return documentary information about commands. + +By default, the reply includes all of the server's commands. +You can use the optional _command-name_ argument to specify the names of one or more commands. + +The reply includes a map for each returned command. +The following keys may be included in the mapped reply: + +* **summary:** short command description. +* **since:** the Redis version that added the command (or for module commands, the module version). +* **group:** the functional group to which the command belongs. + Possible values are: + - _bitmap_ + - _cluster_ + - _connection_ + - _generic_ + - _geo_ + - _hash_ + - _hyperloglog_ + - _list_ + - _module_ + - _pubsub_ + - _scripting_ + - _sentinel_ + - _server_ + - _set_ + - _sorted-set_ + - _stream_ + - _string_ + - _transactions_ +* **complexity:** a short explanation about the command's time complexity. +* **doc_flags:** an array of documentation flags. + Possible values are: + - _deprecated:_ the command is deprecated. + - _syscmd:_ a system command that isn't meant to be called by users. +* **deprecated_since:** the Redis version that deprecated the command (or for module commands, the module version).. +* **replaced_by:** the alternative for a deprecated command. +* **history:** an array of historical notes describing changes to the command's behavior or arguments. + Each entry is an array itself, made up of two elements: + 1. The Redis version that the entry applies to. + 2. The description of the change. +* **arguments:** an array of maps that describe the command's arguments. + Please refer to the [Redis command arguments][td] page for more information. + +[td]: /topics/command-arguments + +@return + +@array-reply: a map as a flattened array as described above. + +@examples + +```cli +COMMAND DOCS SET +``` diff --git a/iredis/data/commands/command-getkeys.md b/iredis/data/commands/command-getkeys.md new file mode 100644 index 0000000..6b8f300 --- /dev/null +++ b/iredis/data/commands/command-getkeys.md @@ -0,0 +1,21 @@ +Returns @array-reply of keys from a full Redis command. + +`COMMAND GETKEYS` is a helper command to let you find the keys +from a full Redis command. + +`COMMAND` provides information on how to find the key names of each command (see `firstkey`, [key specifications](/topics/key-specs#logical-operation-flags), and `movablekeys`), +but in some cases it's not possible to find keys of certain commands and then the entire command must be parsed to discover some / all key names. +You can use `COMMAND GETKEYS` or `COMMAND GETKEYSANDFLAGS` to discover key names directly from how Redis parses the commands. + + +@return + +@array-reply: list of keys from your command. + +@examples + +```cli +COMMAND GETKEYS MSET a b c d e f +COMMAND GETKEYS EVAL "not consulted" 3 key1 key2 key3 arg1 arg2 arg3 argN +COMMAND GETKEYS SORT mylist ALPHA STORE outlist +``` diff --git a/iredis/data/commands/command-getkeysandflags.md b/iredis/data/commands/command-getkeysandflags.md new file mode 100644 index 0000000..3fa479d --- /dev/null +++ b/iredis/data/commands/command-getkeysandflags.md @@ -0,0 +1,22 @@ +Returns @array-reply of keys from a full Redis command and their usage flags. + +`COMMAND GETKEYSANDFLAGS` is a helper command to let you find the keys from a full Redis command together with flags indicating what each key is used for. + +`COMMAND` provides information on how to find the key names of each command (see `firstkey`, [key specifications](/topics/key-specs#logical-operation-flags), and `movablekeys`), +but in some cases it's not possible to find keys of certain commands and then the entire command must be parsed to discover some / all key names. +You can use `COMMAND GETKEYS` or `COMMAND GETKEYSANDFLAGS` to discover key names directly from how Redis parses the commands. + +Refer to [key specifications](/topics/key-specs#logical-operation-flags) for information about the meaning of the key flags. + +@return + +@array-reply: list of keys from your command. +Each element of the array is an array containing key name in the first entry, and flags in the second. + +@examples + +```cli +COMMAND GETKEYS MSET a b c d e f +COMMAND GETKEYS EVAL "not consulted" 3 key1 key2 key3 arg1 arg2 arg3 argN +COMMAND GETKEYSANDFLAGS LMOVE mylist1 mylist2 left left +``` diff --git a/iredis/data/commands/command-help.md b/iredis/data/commands/command-help.md new file mode 100644 index 0000000..73d4cc4 --- /dev/null +++ b/iredis/data/commands/command-help.md @@ -0,0 +1,5 @@ +The `COMMAND HELP` command returns a helpful text describing the different subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/command-info.md b/iredis/data/commands/command-info.md new file mode 100644 index 0000000..e16a555 --- /dev/null +++ b/iredis/data/commands/command-info.md @@ -0,0 +1,19 @@ +Returns @array-reply of details about multiple Redis commands. + +Same result format as `COMMAND` except you can specify which commands +get returned. + +If you request details about non-existing commands, their return +position will be nil. + + +@return + +@array-reply: nested list of command details. + +@examples + +```cli +COMMAND INFO get set eval +COMMAND INFO foo evalsha config bar +``` diff --git a/iredis/data/commands/command-list.md b/iredis/data/commands/command-list.md new file mode 100644 index 0000000..5c0a4a7 --- /dev/null +++ b/iredis/data/commands/command-list.md @@ -0,0 +1,11 @@ +Return an array of the server's command names. + +You can use the optional _FILTERBY_ modifier to apply one of the following filters: + + - **MODULE module-name**: get the commands that belong to the module specified by _module-name_. + - **ACLCAT category**: get the commands in the [ACL category](/docs/manual/security/acl/#command-categories) specified by _category_. + - **PATTERN pattern**: get the commands that match the given glob-like _pattern_. + +@return + +@array-reply: a list of command names. diff --git a/iredis/data/commands/command.md b/iredis/data/commands/command.md new file mode 100644 index 0000000..37545f9 --- /dev/null +++ b/iredis/data/commands/command.md @@ -0,0 +1,241 @@ +Return an array with details about every Redis command. + +The `COMMAND` command is introspective. +Its reply describes all commands that the server can process. +Redis clients can call it to obtain the server's runtime capabilities during the handshake. + +`COMMAND` also has several subcommands. +Please refer to its subcommands for further details. + +**Cluster note:** +this command is especially beneficial for cluster-aware clients. +Such clients must identify the names of keys in commands to route requests to the correct shard. +Although most commands accept a single key as their first argument, there are many exceptions to this rule. +You can call `COMMAND` and then keep the mapping between commands and their respective key specification rules cached in the client. + +The reply it returns is an array with an element per command. +Each element that describes a Redis command is represented as an array by itself. + +The command's array consists of a fixed number of elements. +The exact number of elements in the array depends on the server's version. + +1. Name +1. Arity +1. Flags +1. First key +1. Last key +1. Step +1. [ACL categories][ta] (as of Redis 6.0) +1. [Tips][tb] (as of Redis 7.0) +1. [Key specifications][td] (as of Redis 7.0) +1. Subcommands (as of Redis 7.0) + +## Name + +This is the command's name in lowercase. + +**Note:** +Redis command names are case-insensitive. + +## Arity + +Arity is the number of arguments a command expects. +It follows a simple pattern: + +* A positive integer means a fixed number of arguments. +* A negative integer means a minimal number of arguments. + +Command arity _always includes_ the command's name itself (and the subcommand when applicable). + +Examples: + +* `GET`'s arity is _2_ since the command only accepts one argument and always has the format `GET _key_`. +* `MGET`'s arity is _-2_ since the command accepts at least one argument, but possibly multiple ones: `MGET _key1_ [key2] [key3] ...`. + +## Flags + +Command flags are an array. It can contain the following simple strings (status reply): + +* **admin:** the command is an administrative command. +* **asking:** the command is allowed even during hash slot migration. + This flag is relevant in Redis Cluster deployments. +* **blocking:** the command may block the requesting client. +* **denyoom**: the command is rejected if the server's memory usage is too high (see the _maxmemory_ configuration directive). +* **fast:** the command operates in constant or log(N) time. + This flag is used for monitoring latency with the `LATENCY` command. +* **loading:** the command is allowed while the database is loading. +* **movablekeys:** the _first key_, _last key_, and _step_ values don't determine all key positions. + Clients need to use `COMMAND GETKEYS` or [key specifications][td] in this case. + See below for more details. +* **no_auth:** executing the command doesn't require authentication. +* **no_async_loading:** the command is denied during asynchronous loading (that is when a replica uses disk-less `SWAPDB SYNC`, and allows access to the old dataset). +* **no_mandatory_keys:** the command may accept key name arguments, but these aren't mandatory. +* **no_multi:** the command isn't allowed inside the context of a [transaction](/topics/transactions). +* **noscript:** the command can't be called from [scripts](/topics/eval-intro) or [functions](/topics/functions-intro). +* **pubsub:** the command is related to [Redis Pub/Sub](/topics/pubsub). +* **random**: the command returns random results, which is a concern with verbatim script replication. + As of Redis 7.0, this flag is a [command tip][tb]. +* **readonly:** the command doesn't modify data. +* **sort_for_script:** the command's output is sorted when called from a script. +* **skip_monitor:** the command is not shown in `MONITOR`'s output. +* **skip_slowlog:** the command is not shown in `SLOWLOG`'s output. + As of Redis 7.0, this flag is a [command tip][tb]. +* **stale:** the command is allowed while a replica has stale data. +* **write:** the command may modify data. + +### Movablekeys + +Consider `SORT`: + +``` +1) 1) "sort" + 2) (integer) -2 + 3) 1) write + 2) denyoom + 3) movablekeys + 4) (integer) 1 + 5) (integer) 1 + 6) (integer) 1 + ... +``` + +Some Redis commands have no predetermined key locations or are not easy to find. +For those commands, the _movablekeys_ flag indicates that the _first key_, _last key_, and _step_ values are insufficient to find all the keys. + +Here are several examples of commands that have the _movablekeys_ flag: + +* `SORT`: the optional _STORE_, _BY_, and _GET_ modifiers are followed by names of keys. +* `ZUNION`: the _numkeys_ argument specifies the number key name arguments. +* `MIGRATE`: the keys appear _KEYS_ keyword and only when the second argument is the empty string. + +Redis Cluster clients need to use other measures, as follows, to locate the keys for such commands. + +You can use the `COMMAND GETKEYS` command and have your Redis server report all keys of a given command's invocation. + +As of Redis 7.0, clients can use the [key specifications](#key-specifications) to identify the positions of key names. +The only commands that require using `COMMAND GETKEYS` are `SORT` and `MIGRATE` for clients that parse keys' specifications. + +For more information, please refer to the [key specifications page][tr]. + +## First key + +The position of the command's first key name argument. +For most commands, the first key's position is 1. +Position 0 is always the command name itself. + +## Last key + +The position of the command's last key name argument. +Redis commands usually accept one, two or multiple number of keys. + +Commands that accept a single key have both _first key_ and _last key_ set to 1. + +Commands that accept two key name arguments, e.g. `BRPOPLPUSH`, `SMOVE` and `RENAME`, have this value set to the position of their second key. + +Multi-key commands that accept an arbitrary number of keys, such as `MSET`, use the value -1. + +## Step + +The step, or increment, between the _first key_ and the position of the next key. + +Consider the following two examples: + +``` +1) 1) "mset" + 2) (integer) -3 + 3) 1) write + 2) denyoom + 4) (integer) 1 + 5) (integer) -1 + 6) (integer) 2 + ... +``` + +``` +1) 1) "mget" + 2) (integer) -2 + 3) 1) readonly + 2) fast + 4) (integer) 1 + 5) (integer) -1 + 6) (integer) 1 + ... +``` + +The step count allows us to find keys' positions. +For example `MSET`: Its syntax is `MSET _key1_ _val1_ [key2] [val2] [key3] [val3]...`, so the keys are at every other position (step value of _2_). +Unlike `MGET`, which uses a step value of _1_. + +## ACL categories + +This is an array of simple strings that are the ACL categories to which the command belongs. +Please refer to the [Access Control List][ta] page for more information. + +## Command tips + +Helpful information about the command. +To be used by clients/proxies. + +Please check the [Command tips][tb] page for more information. + +## Key specifications + +This is an array consisting of the command's key specifications. +Each element in the array is a map describing a method for locating keys in the command's arguments. + +For more information please check the [key specifications page][td]. + +## Subcommands + +This is an array containing all of the command's subcommands, if any. +Some Redis commands have subcommands (e.g., the `REWRITE` subcommand of `CONFIG`). +Each element in the array represents one subcommand and follows the same specifications as those of `COMMAND`'s reply. + +[ta]: /topics/acl +[tb]: /topics/command-tips +[td]: /topics/key-specs +[tr]: /topics/key-specs + +@return + +@array-reply: a nested list of command details. + +The order of commands in the array is random. + +@examples + +The following is `COMMAND`'s output for the `GET` command: + +``` +1) 1) "get" + 2) (integer) 2 + 3) 1) readonly + 2) fast + 4) (integer) 1 + 5) (integer) 1 + 6) (integer) 1 + 7) 1) @read + 2) @string + 3) @fast + 8) (empty array) + 9) 1) 1) "flags" + 2) 1) read + 3) "begin_search" + 4) 1) "type" + 2) "index" + 3) "spec" + 4) 1) "index" + 2) (integer) 1 + 5) "find_keys" + 6) 1) "type" + 2) "range" + 3) "spec" + 4) 1) "lastkey" + 2) (integer) 0 + 3) "keystep" + 4) (integer) 1 + 5) "limit" + 6) (integer) 0 + 10) (empty array) +... +``` diff --git a/iredis/data/commands/config-get.md b/iredis/data/commands/config-get.md new file mode 100644 index 0000000..d2e85a3 --- /dev/null +++ b/iredis/data/commands/config-get.md @@ -0,0 +1,45 @@ +The `CONFIG GET` command is used to read the configuration parameters of a +running Redis server. +Not all the configuration parameters are supported in Redis 2.4, while Redis 2.6 +can read the whole configuration of a server using this command. + +The symmetric command used to alter the configuration at run time is `CONFIG +SET`. + +`CONFIG GET` takes multiple arguments, which are glob-style patterns. +Any configuration parameter matching any of the patterns are reported as a list +of key-value pairs. +Example: + +``` +redis> config get *max-*-entries* maxmemory + 1) "maxmemory" + 2) "0" + 3) "hash-max-listpack-entries" + 4) "512" + 5) "hash-max-ziplist-entries" + 6) "512" + 7) "set-max-intset-entries" + 8) "512" + 9) "zset-max-listpack-entries" +10) "128" +11) "zset-max-ziplist-entries" +12) "128" +``` + +You can obtain a list of all the supported configuration parameters by typing +`CONFIG GET *` in an open `redis-cli` prompt. + +All the supported parameters have the same meaning of the equivalent +configuration parameter used in the [redis.conf][hgcarr22rc] file: + +[hgcarr22rc]: http://github.com/redis/redis/raw/unstable/redis.conf + +Note that you should look at the redis.conf file relevant to the version you're +working with as configuration options might change between versions. The link +above is to the latest development version. + + +@return + +The return type of the command is a @array-reply. diff --git a/iredis/data/commands/config-help.md b/iredis/data/commands/config-help.md new file mode 100644 index 0000000..5f8bc48 --- /dev/null +++ b/iredis/data/commands/config-help.md @@ -0,0 +1,5 @@ +The `CONFIG HELP` command returns a helpful text describing the different subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/config-resetstat.md b/iredis/data/commands/config-resetstat.md new file mode 100644 index 0000000..cb0232b --- /dev/null +++ b/iredis/data/commands/config-resetstat.md @@ -0,0 +1,16 @@ +Resets the statistics reported by Redis using the `INFO` command. + +These are the counters that are reset: + +* Keyspace hits +* Keyspace misses +* Number of commands processed +* Number of connections received +* Number of expired keys +* Number of rejected connections +* Latest fork(2) time +* The `aof_delayed_fsync` counter + +@return + +@simple-string-reply: always `OK`. diff --git a/iredis/data/commands/config-rewrite.md b/iredis/data/commands/config-rewrite.md new file mode 100644 index 0000000..c103156 --- /dev/null +++ b/iredis/data/commands/config-rewrite.md @@ -0,0 +1,20 @@ +The `CONFIG REWRITE` command rewrites the `redis.conf` file the server was started with, applying the minimal changes needed to make it reflect the configuration currently used by the server, which may be different compared to the original one because of the use of the `CONFIG SET` command. + +The rewrite is performed in a very conservative way: + +* Comments and the overall structure of the original redis.conf are preserved as much as possible. +* If an option already exists in the old redis.conf file, it will be rewritten at the same position (line number). +* If an option was not already present, but it is set to its default value, it is not added by the rewrite process. +* If an option was not already present, but it is set to a non-default value, it is appended at the end of the file. +* Non used lines are blanked. For instance if you used to have multiple `save` directives, but the current configuration has fewer or none as you disabled RDB persistence, all the lines will be blanked. + +CONFIG REWRITE is also able to rewrite the configuration file from scratch if the original one no longer exists for some reason. However if the server was started without a configuration file at all, the CONFIG REWRITE will just return an error. + +## Atomic rewrite process + +In order to make sure the redis.conf file is always consistent, that is, on errors or crashes you always end with the old file, or the new one, the rewrite is performed with a single `write(2)` call that has enough content to be at least as big as the old file. Sometimes additional padding in the form of comments is added in order to make sure the resulting file is big enough, and later the file gets truncated to remove the padding at the end. + +@return + +@simple-string-reply: `OK` when the configuration was rewritten properly. +Otherwise an error is returned. diff --git a/iredis/data/commands/config-set.md b/iredis/data/commands/config-set.md new file mode 100644 index 0000000..4b0841e --- /dev/null +++ b/iredis/data/commands/config-set.md @@ -0,0 +1,41 @@ +The `CONFIG SET` command is used in order to reconfigure the server at run time +without the need to restart Redis. +You can change both trivial parameters or switch from one to another persistence +option using this command. + +The list of configuration parameters supported by `CONFIG SET` can be obtained +issuing a `CONFIG GET *` command, that is the symmetrical command used to obtain +information about the configuration of a running Redis instance. + +All the configuration parameters set using `CONFIG SET` are immediately loaded +by Redis and will take effect starting with the next command executed. + +All the supported parameters have the same meaning of the equivalent +configuration parameter used in the [redis.conf][hgcarr22rc] file. + +[hgcarr22rc]: http://github.com/redis/redis/raw/unstable/redis.conf + +Note that you should look at the redis.conf file relevant to the version you're +working with as configuration options might change between versions. The link +above is to the latest development version. + +It is possible to switch persistence from RDB snapshotting to append-only file +(and the other way around) using the `CONFIG SET` command. +For more information about how to do that please check the [persistence +page][tp]. + +[tp]: /topics/persistence + +In general what you should know is that setting the `appendonly` parameter to +`yes` will start a background process to save the initial append-only file +(obtained from the in memory data set), and will append all the subsequent +commands on the append-only file, thus obtaining exactly the same effect of a +Redis server that started with AOF turned on since the start. + +You can have both the AOF enabled with RDB snapshotting if you want, the two +options are not mutually exclusive. + +@return + +@simple-string-reply: `OK` when the configuration was set properly. +Otherwise an error is returned. diff --git a/iredis/data/commands/config.md b/iredis/data/commands/config.md new file mode 100644 index 0000000..d4b37e9 --- /dev/null +++ b/iredis/data/commands/config.md @@ -0,0 +1,3 @@ +This is a container command for runtime configuration commands. + +To see the list of available commands you can call `CONFIG HELP`. diff --git a/iredis/data/commands/copy.md b/iredis/data/commands/copy.md new file mode 100644 index 0000000..2803d2a --- /dev/null +++ b/iredis/data/commands/copy.md @@ -0,0 +1,24 @@ +This command copies the value stored at the `source` key to the `destination` +key. + +By default, the `destination` key is created in the logical database used by the +connection. The `DB` option allows specifying an alternative logical database +index for the destination key. + +The command returns an error when the `destination` key already exists. The +`REPLACE` option removes the `destination` key before copying the value to it. + +@return + +@integer-reply, specifically: + +* `1` if `source` was copied. +* `0` if `source` was not copied. + +@examples + +``` +SET dolly "sheep" +COPY dolly clone +GET clone +```
\ No newline at end of file diff --git a/iredis/data/commands/dbsize.md b/iredis/data/commands/dbsize.md new file mode 100644 index 0000000..fe82aa7 --- /dev/null +++ b/iredis/data/commands/dbsize.md @@ -0,0 +1,5 @@ +Return the number of keys in the currently-selected database. + +@return + +@integer-reply diff --git a/iredis/data/commands/debug-object.md b/iredis/data/commands/debug-object.md new file mode 100644 index 0000000..15a4780 --- /dev/null +++ b/iredis/data/commands/debug-object.md @@ -0,0 +1,6 @@ +`DEBUG OBJECT` is a debugging command that should not be used by clients. Check +the `OBJECT` command instead. + +@return + +@simple-string-reply diff --git a/iredis/data/commands/debug-segfault.md b/iredis/data/commands/debug-segfault.md new file mode 100644 index 0000000..4e21b9c --- /dev/null +++ b/iredis/data/commands/debug-segfault.md @@ -0,0 +1,6 @@ +`DEBUG SEGFAULT` performs an invalid memory access that crashes Redis. It is +used to simulate bugs during the development. + +@return + +@simple-string-reply diff --git a/iredis/data/commands/debug.md b/iredis/data/commands/debug.md new file mode 100644 index 0000000..fc3c3f3 --- /dev/null +++ b/iredis/data/commands/debug.md @@ -0,0 +1,2 @@ +The `DEBUG` command is an internal command. +It is meant to be used for developing and testing Redis.
\ No newline at end of file diff --git a/iredis/data/commands/decr.md b/iredis/data/commands/decr.md new file mode 100644 index 0000000..cda121a --- /dev/null +++ b/iredis/data/commands/decr.md @@ -0,0 +1,20 @@ +Decrements the number stored at `key` by one. +If the key does not exist, it is set to `0` before performing the operation. +An error is returned if the key contains a value of the wrong type or contains a +string that can not be represented as integer. +This operation is limited to **64 bit signed integers**. + +See `INCR` for extra information on increment/decrement operations. + +@return + +@integer-reply: the value of `key` after the decrement + +@examples + +```cli +SET mykey "10" +DECR mykey +SET mykey "234293482390480948029348230948" +DECR mykey +``` diff --git a/iredis/data/commands/decrby.md b/iredis/data/commands/decrby.md new file mode 100644 index 0000000..b2e823b --- /dev/null +++ b/iredis/data/commands/decrby.md @@ -0,0 +1,18 @@ +Decrements the number stored at `key` by `decrement`. +If the key does not exist, it is set to `0` before performing the operation. +An error is returned if the key contains a value of the wrong type or contains a +string that can not be represented as integer. +This operation is limited to 64 bit signed integers. + +See `INCR` for extra information on increment/decrement operations. + +@return + +@integer-reply: the value of `key` after the decrement + +@examples + +```cli +SET mykey "10" +DECRBY mykey 3 +``` diff --git a/iredis/data/commands/del.md b/iredis/data/commands/del.md new file mode 100644 index 0000000..d5fcbac --- /dev/null +++ b/iredis/data/commands/del.md @@ -0,0 +1,14 @@ +Removes the specified keys. +A key is ignored if it does not exist. + +@return + +@integer-reply: The number of keys that were removed. + +@examples + +```cli +SET key1 "Hello" +SET key2 "World" +DEL key1 key2 key3 +``` diff --git a/iredis/data/commands/discard.md b/iredis/data/commands/discard.md new file mode 100644 index 0000000..d84b503 --- /dev/null +++ b/iredis/data/commands/discard.md @@ -0,0 +1,10 @@ +Flushes all previously queued commands in a [transaction][tt] and restores the +connection state to normal. + +[tt]: /topics/transactions + +If `WATCH` was used, `DISCARD` unwatches all keys watched by the connection. + +@return + +@simple-string-reply: always `OK`. diff --git a/iredis/data/commands/dump.md b/iredis/data/commands/dump.md new file mode 100644 index 0000000..d740033 --- /dev/null +++ b/iredis/data/commands/dump.md @@ -0,0 +1,33 @@ +Serialize the value stored at key in a Redis-specific format and return it to +the user. +The returned value can be synthesized back into a Redis key using the `RESTORE` +command. + +The serialization format is opaque and non-standard, however it has a few +semantic characteristics: + +* It contains a 64-bit checksum that is used to make sure errors will be + detected. + The `RESTORE` command makes sure to check the checksum before synthesizing a + key using the serialized value. +* Values are encoded in the same format used by RDB. +* An RDB version is encoded inside the serialized value, so that different Redis + versions with incompatible RDB formats will refuse to process the serialized + value. + +The serialized value does NOT contain expire information. +In order to capture the time to live of the current value the `PTTL` command +should be used. + +If `key` does not exist a nil bulk reply is returned. + +@return + +@bulk-string-reply: the serialized value. + +@examples + +```cli +SET mykey 10 +DUMP mykey +``` diff --git a/iredis/data/commands/echo.md b/iredis/data/commands/echo.md new file mode 100644 index 0000000..642d0f3 --- /dev/null +++ b/iredis/data/commands/echo.md @@ -0,0 +1,11 @@ +Returns `message`. + +@return + +@bulk-string-reply + +@examples + +```cli +ECHO "Hello World!" +``` diff --git a/iredis/data/commands/eval.md b/iredis/data/commands/eval.md new file mode 100644 index 0000000..079edeb --- /dev/null +++ b/iredis/data/commands/eval.md @@ -0,0 +1,24 @@ +Invoke the execution of a server-side Lua script. + +The first argument is the script's source code. +Scripts are written in [Lua](https://lua.org) and executed by the embedded [Lua 5.1](/topics/lua-api) interpreter in Redis. + +The second argument is the number of input key name arguments, followed by all the keys accessed by the script. +These names of input keys are available to the script as the [_KEYS_ global runtime variable](/topics/lua-api#the-keys-global-variable) +Any additional input arguments **should not** represent names of keys. + +**Important:** +to ensure the correct execution of scripts, both in standalone and clustered deployments, all names of keys that a script accesses must be explicitly provided as input key arguments. +The script **should only** access keys whose names are given as input arguments. +Scripts **should never** access keys with programmatically-generated names or based on the contents of data structures stored in the database. + +Please refer to the [Redis Programmability](/topics/programmability) and [Introduction to Eval Scripts](/topics/eval-intro) for more information about Lua scripts. + +@examples + +The following example will run a script that returns the first argument that it gets. + +``` +> EVAL "return ARGV[1]" 0 hello +"hello" +``` diff --git a/iredis/data/commands/eval_ro.md b/iredis/data/commands/eval_ro.md new file mode 100644 index 0000000..bbbdb8d --- /dev/null +++ b/iredis/data/commands/eval_ro.md @@ -0,0 +1,18 @@ +This is a read-only variant of the `EVAL` command that cannot execute commands that modify data. + +For more information about when to use this command vs `EVAL`, please refer to [Read-only scripts](/docs/manual/programmability/#read-only_scripts). + +For more information about `EVAL` scripts please refer to [Introduction to Eval Scripts](/topics/eval-intro). + +@examples + +``` +> SET mykey "Hello" +OK + +> EVAL_RO "return redis.call('GET', KEYS[1])" 1 mykey +"Hello" + +> EVAL_RO "return redis.call('DEL', KEYS[1])" 1 mykey +(error) ERR Error running script (call to b0d697da25b13e49157b2c214a4033546aba2104): @user_script:1: @user_script: 1: Write commands are not allowed from read-only scripts. +``` diff --git a/iredis/data/commands/evalsha.md b/iredis/data/commands/evalsha.md new file mode 100644 index 0000000..c8b2329 --- /dev/null +++ b/iredis/data/commands/evalsha.md @@ -0,0 +1,6 @@ +Evaluate a script from the server's cache by its SHA1 digest. + +The server caches scripts by using the `SCRIPT LOAD` command. +The command is otherwise identical to `EVAL`. + +Please refer to the [Redis Programmability](/topics/programmability) and [Introduction to Eval Scripts](/topics/eval-intro) for more information about Lua scripts. diff --git a/iredis/data/commands/evalsha_ro.md b/iredis/data/commands/evalsha_ro.md new file mode 100644 index 0000000..ccb45d6 --- /dev/null +++ b/iredis/data/commands/evalsha_ro.md @@ -0,0 +1,5 @@ +This is a read-only variant of the `EVALSHA` command that cannot execute commands that modify data. + +For more information about when to use this command vs `EVALSHA`, please refer to [Read-only scripts](/docs/manual/programmability/#read-only_scripts). + +For more information about `EVALSHA` scripts please refer to [Introduction to Eval Scripts](/topics/eval-intro). diff --git a/iredis/data/commands/exec.md b/iredis/data/commands/exec.md new file mode 100644 index 0000000..b2f58fe --- /dev/null +++ b/iredis/data/commands/exec.md @@ -0,0 +1,16 @@ +Executes all previously queued commands in a [transaction][tt] and restores the +connection state to normal. + +[tt]: /topics/transactions + +When using `WATCH`, `EXEC` will execute commands only if the watched keys were +not modified, allowing for a [check-and-set mechanism][ttc]. + +[ttc]: /topics/transactions#cas + +@return + +@array-reply: each element being the reply to each of the commands in the +atomic transaction. + +When using `WATCH`, `EXEC` can return a @nil-reply if the execution was aborted. diff --git a/iredis/data/commands/exists.md b/iredis/data/commands/exists.md new file mode 100644 index 0000000..a9a89af --- /dev/null +++ b/iredis/data/commands/exists.md @@ -0,0 +1,17 @@ +Returns if `key` exists. + +The user should be aware that if the same existing key is mentioned in the arguments multiple times, it will be counted multiple times. So if `somekey` exists, `EXISTS somekey somekey` will return 2. + +@return + +@integer-reply, specifically the number of keys that exist from those specified as arguments. + +@examples + +```cli +SET key1 "Hello" +EXISTS key1 +EXISTS nosuchkey +SET key2 "World" +EXISTS key1 key2 nosuchkey +``` diff --git a/iredis/data/commands/expire.md b/iredis/data/commands/expire.md new file mode 100644 index 0000000..ddb4c9a --- /dev/null +++ b/iredis/data/commands/expire.md @@ -0,0 +1,189 @@ +Set a timeout on `key`. +After the timeout has expired, the key will automatically be deleted. +A key with an associated timeout is often said to be _volatile_ in Redis +terminology. + +The timeout will only be cleared by commands that delete or overwrite the +contents of the key, including `DEL`, `SET`, `GETSET` and all the `*STORE` +commands. +This means that all the operations that conceptually _alter_ the value stored at +the key without replacing it with a new one will leave the timeout untouched. +For instance, incrementing the value of a key with `INCR`, pushing a new value +into a list with `LPUSH`, or altering the field value of a hash with `HSET` are +all operations that will leave the timeout untouched. + +The timeout can also be cleared, turning the key back into a persistent key, +using the `PERSIST` command. + +If a key is renamed with `RENAME`, the associated time to live is transferred to +the new key name. + +If a key is overwritten by `RENAME`, like in the case of an existing key `Key_A` +that is overwritten by a call like `RENAME Key_B Key_A`, it does not matter if +the original `Key_A` had a timeout associated or not, the new key `Key_A` will +inherit all the characteristics of `Key_B`. + +Note that calling `EXPIRE`/`PEXPIRE` with a non-positive timeout or +`EXPIREAT`/`PEXPIREAT` with a time in the past will result in the key being +[deleted][del] rather than expired (accordingly, the emitted [key event][ntf] +will be `del`, not `expired`). + +[del]: /commands/del +[ntf]: /topics/notifications + +## Options + +The `EXPIRE` command supports a set of options: + +* `NX` -- Set expiry only when the key has no expiry +* `XX` -- Set expiry only when the key has an existing expiry +* `GT` -- Set expiry only when the new expiry is greater than current one +* `LT` -- Set expiry only when the new expiry is less than current one + +A non-volatile key is treated as an infinite TTL for the purpose of `GT` and `LT`. +The `GT`, `LT` and `NX` options are mutually exclusive. + +## Refreshing expires + +It is possible to call `EXPIRE` using as argument a key that already has an +existing expire set. +In this case the time to live of a key is _updated_ to the new value. +There are many useful applications for this, an example is documented in the +_Navigation session_ pattern section below. + +## Differences in Redis prior 2.1.3 + +In Redis versions prior **2.1.3** altering a key with an expire set using a +command altering its value had the effect of removing the key entirely. +This semantics was needed because of limitations in the replication layer that +are now fixed. + +`EXPIRE` would return 0 and not alter the timeout for a key with a timeout set. + +@return + +@integer-reply, specifically: + +* `1` if the timeout was set. +* `0` if the timeout was not set. e.g. key doesn't exist, or operation skipped due to the provided arguments. + +@examples + +```cli +SET mykey "Hello" +EXPIRE mykey 10 +TTL mykey +SET mykey "Hello World" +TTL mykey +EXPIRE mykey 10 XX +TTL mykey +EXPIRE mykey 10 NX +TTL mykey +``` + +## Pattern: Navigation session + +Imagine you have a web service and you are interested in the latest N pages +_recently_ visited by your users, such that each adjacent page view was not +performed more than 60 seconds after the previous. +Conceptually you may consider this set of page views as a _Navigation session_ +of your user, that may contain interesting information about what kind of +products he or she is looking for currently, so that you can recommend related +products. + +You can easily model this pattern in Redis using the following strategy: every +time the user does a page view you call the following commands: + +``` +MULTI +RPUSH pagewviews.user:<userid> http://..... +EXPIRE pagewviews.user:<userid> 60 +EXEC +``` + +If the user will be idle more than 60 seconds, the key will be deleted and only +subsequent page views that have less than 60 seconds of difference will be +recorded. + +This pattern is easily modified to use counters using `INCR` instead of lists +using `RPUSH`. + +# Appendix: Redis expires + +## Keys with an expire + +Normally Redis keys are created without an associated time to live. +The key will simply live forever, unless it is removed by the user in an +explicit way, for instance using the `DEL` command. + +The `EXPIRE` family of commands is able to associate an expire to a given key, +at the cost of some additional memory used by the key. +When a key has an expire set, Redis will make sure to remove the key when the +specified amount of time elapsed. + +The key time to live can be updated or entirely removed using the `EXPIRE` and +`PERSIST` command (or other strictly related commands). + +## Expire accuracy + +In Redis 2.4 the expire might not be pin-point accurate, and it could be between +zero to one seconds out. + +Since Redis 2.6 the expire error is from 0 to 1 milliseconds. + +## Expires and persistence + +Keys expiring information is stored as absolute Unix timestamps (in milliseconds +in case of Redis version 2.6 or greater). +This means that the time is flowing even when the Redis instance is not active. + +For expires to work well, the computer time must be taken stable. +If you move an RDB file from two computers with a big desync in their clocks, +funny things may happen (like all the keys loaded to be expired at loading +time). + +Even running instances will always check the computer clock, so for instance if +you set a key with a time to live of 1000 seconds, and then set your computer +time 2000 seconds in the future, the key will be expired immediately, instead of +lasting for 1000 seconds. + +## How Redis expires keys + +Redis keys are expired in two ways: a passive way, and an active way. + +A key is passively expired simply when some client tries to access it, and the +key is found to be timed out. + +Of course this is not enough as there are expired keys that will never be +accessed again. +These keys should be expired anyway, so periodically Redis tests a few keys at +random among keys with an expire set. +All the keys that are already expired are deleted from the keyspace. + +Specifically this is what Redis does 10 times per second: + +1. Test 20 random keys from the set of keys with an associated expire. +2. Delete all the keys found expired. +3. If more than 25% of keys were expired, start again from step 1. + +This is a trivial probabilistic algorithm, basically the assumption is that our +sample is representative of the whole key space, and we continue to expire until +the percentage of keys that are likely to be expired is under 25% + +This means that at any given moment the maximum amount of keys already expired +that are using memory is at max equal to max amount of write operations per +second divided by 4. + +## How expires are handled in the replication link and AOF file + +In order to obtain a correct behavior without sacrificing consistency, when a +key expires, a `DEL` operation is synthesized in both the AOF file and gains all +the attached replicas nodes. +This way the expiration process is centralized in the master instance, and there +is no chance of consistency errors. + +However while the replicas connected to a master will not expire keys +independently (but will wait for the `DEL` coming from the master), they'll +still take the full state of the expires existing in the dataset, so when a +replica is elected to master it will be able to expire the keys independently, +fully acting as a master. diff --git a/iredis/data/commands/expireat.md b/iredis/data/commands/expireat.md new file mode 100644 index 0000000..cbc10c6 --- /dev/null +++ b/iredis/data/commands/expireat.md @@ -0,0 +1,44 @@ +`EXPIREAT` has the same effect and semantic as `EXPIRE`, but instead of +specifying the number of seconds representing the TTL (time to live), it takes +an absolute [Unix timestamp][hewowu] (seconds since January 1, 1970). A +timestamp in the past will delete the key immediately. + +[hewowu]: http://en.wikipedia.org/wiki/Unix_time + +Please for the specific semantics of the command refer to the documentation of +`EXPIRE`. + +## Background + +`EXPIREAT` was introduced in order to convert relative timeouts to absolute +timeouts for the AOF persistence mode. +Of course, it can be used directly to specify that a given key should expire at +a given time in the future. + +## Options + +The `EXPIREAT` command supports a set of options: + +* `NX` -- Set expiry only when the key has no expiry +* `XX` -- Set expiry only when the key has an existing expiry +* `GT` -- Set expiry only when the new expiry is greater than current one +* `LT` -- Set expiry only when the new expiry is less than current one + +A non-volatile key is treated as an infinite TTL for the purpose of `GT` and `LT`. +The `GT`, `LT` and `NX` options are mutually exclusive. + +@return + +@integer-reply, specifically: + +* `1` if the timeout was set. +* `0` if the timeout was not set. e.g. key doesn't exist, or operation skipped due to the provided arguments. + +@examples + +```cli +SET mykey "Hello" +EXISTS mykey +EXPIREAT mykey 1293840000 +EXISTS mykey +``` diff --git a/iredis/data/commands/expiretime.md b/iredis/data/commands/expiretime.md new file mode 100644 index 0000000..b524dcc --- /dev/null +++ b/iredis/data/commands/expiretime.md @@ -0,0 +1,18 @@ +Returns the absolute Unix timestamp (since January 1, 1970) in seconds at which the given key will expire. + +See also the `PEXPIRETIME` command which returns the same information with milliseconds resolution. + +@return + +@integer-reply: Expiration Unix timestamp in seconds, or a negative value in order to signal an error (see the description below). + +* The command returns `-1` if the key exists but has no associated expiration time. +* The command returns `-2` if the key does not exist. + +@examples + +```cli +SET mykey "Hello" +EXPIREAT mykey 33177117420 +EXPIRETIME mykey +``` diff --git a/iredis/data/commands/failover.md b/iredis/data/commands/failover.md new file mode 100644 index 0000000..719d199 --- /dev/null +++ b/iredis/data/commands/failover.md @@ -0,0 +1,48 @@ +This command will start a coordinated failover between the currently-connected-to master and one of its replicas. +The failover is not synchronous, instead a background task will handle coordinating the failover. +It is designed to limit data loss and unavailability of the cluster during the failover. +This command is analogous to the `CLUSTER FAILOVER` command for non-clustered Redis and is similar to the failover support provided by sentinel. + +The specific details of the default failover flow are as follows: + +1. The master will internally start a `CLIENT PAUSE WRITE`, which will pause incoming writes and prevent the accumulation of new data in the replication stream. +2. The master will monitor its replicas, waiting for a replica to indicate that it has fully consumed the replication stream. If the master has multiple replicas, it will only wait for the first replica to catch up. +3. The master will then demote itself to a replica. This is done to prevent any dual master scenarios. NOTE: The master will not discard its data, so it will be able to rollback if the replica rejects the failover request in the next step. +4. The previous master will send a special PSYNC request to the target replica, `PSYNC FAILOVER`, instructing the target replica to become a master. +5. Once the previous master receives acknowledgement the `PSYNC FAILOVER` was accepted it will unpause its clients. If the PSYNC request is rejected, the master will abort the failover and return to normal. + +The field `master_failover_state` in `INFO replication` can be used to track the current state of the failover, which has the following values: + +* `no-failover`: There is no ongoing coordinated failover. +* `waiting-for-sync`: The master is waiting for the replica to catch up to its replication offset. +* `failover-in-progress`: The master has demoted itself, and is attempting to hand off ownership to a target replica. + +If the previous master had additional replicas attached to it, they will continue replicating from it as chained replicas. You will need to manually execute a `REPLICAOF` on these replicas to start replicating directly from the new master. + +## Optional arguments +The following optional arguments exist to modify the behavior of the failover flow: + +* `TIMEOUT` *milliseconds* -- This option allows specifying a maximum time a master will wait in the `waiting-for-sync` state before aborting the failover attempt and rolling back. +This is intended to set an upper bound on the write outage the Redis cluster can experience. +Failovers typically happen in less than a second, but could take longer if there is a large amount of write traffic or the replica is already behind in consuming the replication stream. +If this value is not specified, the timeout can be considered to be "infinite". + +* `TO` *HOST* *PORT* -- This option allows designating a specific replica, by its host and port, to failover to. The master will wait specifically for this replica to catch up to its replication offset, and then failover to it. + +* `FORCE` -- If both the `TIMEOUT` and `TO` options are set, the force flag can also be used to designate that that once the timeout has elapsed, the master should failover to the target replica instead of rolling back. +This can be used for a best-effort attempt at a failover without data loss, but limiting write outage. + +NOTE: The master will always rollback if the `PSYNC FAILOVER` request is rejected by the target replica. + +## Failover abort + +The failover command is intended to be safe from data loss and corruption, but can encounter some scenarios it can not automatically remediate from and may get stuck. +For this purpose, the `FAILOVER ABORT` command exists, which will abort an ongoing failover and return the master to its normal state. +The command has no side effects if issued in the `waiting-for-sync` state but can introduce multi-master scenarios in the `failover-in-progress` state. +If a multi-master scenario is encountered, you will need to manually identify which master has the latest data and designate it as the master and have the other replicas. + +NOTE: `REPLICAOF` is disabled while a failover is in progress, this is to prevent unintended interactions with the failover that might cause data loss. + +@return + +@simple-string-reply: `OK` if the command was accepted and a coordinated failover is in progress. An error if the operation cannot be executed. diff --git a/iredis/data/commands/fcall.md b/iredis/data/commands/fcall.md new file mode 100644 index 0000000..30e1751 --- /dev/null +++ b/iredis/data/commands/fcall.md @@ -0,0 +1,28 @@ +Invoke a function. + +Functions are loaded to the server with the `FUNCTION LOAD` command. +The first argument is the name of a loaded function. + +The second argument is the number of input key name arguments, followed by all the keys accessed by the function. +In Lua, these names of input keys are available to the function as a table that is the callback's first argument. + +**Important:** +To ensure the correct execution of functions, both in standalone and clustered deployments, all names of keys that a function accesses must be explicitly provided as input key arguments. +The function **should only** access keys whose names are given as input arguments. +Functions **should never** access keys with programmatically-generated names or based on the contents of data structures stored in the database. + +Any additional input argument **should not** represent names of keys. +These are regular arguments and are passed in a Lua table as the callback's second argument. + +For more information please refer to the [Redis Programmability](/topics/programmability) and [Introduction to Redis Functions](/topics/functions-intro) pages. + +@examples + +The following example will create a library named `mylib` with a single function, `myfunc`, that returns the first argument it gets. + +``` +redis> FUNCTION LOAD "#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return args[1] end)" +"mylib" +redis> FCALL myfunc 0 hello +"hello" +``` diff --git a/iredis/data/commands/fcall_ro.md b/iredis/data/commands/fcall_ro.md new file mode 100644 index 0000000..576b140 --- /dev/null +++ b/iredis/data/commands/fcall_ro.md @@ -0,0 +1,5 @@ +This is a read-only variant of the `FCALL` command that cannot execute commands that modify data. + +For more information about when to use this command vs `FCALL`, please refer to [Read-only scripts](/docs/manual/programmability/#read-only_scripts). + +For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). diff --git a/iredis/data/commands/flushall.md b/iredis/data/commands/flushall.md new file mode 100644 index 0000000..5a562d0 --- /dev/null +++ b/iredis/data/commands/flushall.md @@ -0,0 +1,20 @@ +Delete all the keys of all the existing databases, not just the currently selected one. +This command never fails. + +By default, `FLUSHALL` will synchronously flush all the databases. +Starting with Redis 6.2, setting the **lazyfree-lazy-user-flush** configuration directive to "yes" changes the default flush mode to asynchronous. + +It is possible to use one of the following modifiers to dictate the flushing mode explicitly: + +* `ASYNC`: flushes the databases asynchronously +* `!SYNC`: flushes the databases synchronously + +Note: an asynchronous `FLUSHALL` command only deletes keys that were present at the time the command was invoked. Keys created during an asynchronous flush will be unaffected. + +@return + +@simple-string-reply + +## Behavior change history + +* `>= 6.2.0`: Default flush behavior now configurable by the **lazyfree-lazy-user-flush** configuration directive.
\ No newline at end of file diff --git a/iredis/data/commands/flushdb.md b/iredis/data/commands/flushdb.md new file mode 100644 index 0000000..f823563 --- /dev/null +++ b/iredis/data/commands/flushdb.md @@ -0,0 +1,20 @@ +Delete all the keys of the currently selected DB. +This command never fails. + +By default, `FLUSHDB` will synchronously flush all keys from the database. +Starting with Redis 6.2, setting the **lazyfree-lazy-user-flush** configuration directive to "yes" changes the default flush mode to asynchronous. + +It is possible to use one of the following modifiers to dictate the flushing mode explicitly: + +* `ASYNC`: flushes the database asynchronously +* `!SYNC`: flushes the database synchronously + +Note: an asynchronous `FLUSHDB` command only deletes keys that were present at the time the command was invoked. Keys created during an asynchronous flush will be unaffected. + +@return + +@simple-string-reply + +## Behavior change history + +* `>= 6.2.0`: Default flush behavior now configurable by the **lazyfree-lazy-user-flush** configuration directive.
\ No newline at end of file diff --git a/iredis/data/commands/function-delete.md b/iredis/data/commands/function-delete.md new file mode 100644 index 0000000..5b90f81 --- /dev/null +++ b/iredis/data/commands/function-delete.md @@ -0,0 +1,23 @@ +Delete a library and all its functions. + +This command deletes the library called _library-name_ and all functions in it. +If the library doesn't exist, the server returns an error. + +For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). + +@return + +@simple-string-reply + +@examples + +``` +redis> FUNCTION LOAD Lua mylib "redis.register_function('myfunc', function(keys, args) return 'hello' end)" +OK +redis> FCALL myfunc 0 +"hello" +redis> FUNCTION DELETE mylib +OK +redis> FCALL myfunc 0 +(error) ERR Function not found +``` diff --git a/iredis/data/commands/function-dump.md b/iredis/data/commands/function-dump.md new file mode 100644 index 0000000..cf144bc --- /dev/null +++ b/iredis/data/commands/function-dump.md @@ -0,0 +1,34 @@ +Return the serialized payload of loaded libraries. +You can restore the serialized payload later with the `FUNCTION RESTORE` command. + +For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). + +@return + +@bulk-string-reply: the serialized payload + +@examples + +The following example shows how to dump loaded libraries using `FUNCTION DUMP` and then it calls `FUNCTION FLUSH` deletes all the libraries. +Then, it restores the original libraries from the serialized payload with `FUNCTION RESTORE`. + +``` +redis> FUNCTION DUMP +"\xf6\x05mylib\x03LUA\x00\xc3@D@J\x1aredis.register_function('my@\x0b\x02', @\x06`\x12\x11keys, args) return`\x0c\a[1] end)\n\x00@\n)\x11\xc8|\x9b\xe4" +redis> FUNCTION FLUSH +OK +redis> FUNCTION RESTORE "\xf6\x05mylib\x03LUA\x00\xc3@D@J\x1aredis.register_function('my@\x0b\x02', @\x06`\x12\x11keys, args) return`\x0c\a[1] end)\n\x00@\n)\x11\xc8|\x9b\xe4" +OK +redis> FUNCTION LIST +1) 1) "library_name" + 2) "mylib" + 3) "engine" + 4) "LUA" + 5) "description" + 6) (nil) + 7) "functions" + 8) 1) 1) "name" + 2) "myfunc" + 3) "description" + 4) (nil) +``` diff --git a/iredis/data/commands/function-flush.md b/iredis/data/commands/function-flush.md new file mode 100644 index 0000000..38c412a --- /dev/null +++ b/iredis/data/commands/function-flush.md @@ -0,0 +1,12 @@ +Deletes all the libraries. + +Unless called with the optional mode argument, the `lazyfree-lazy-user-flush` configuration directive sets the effective behavior. Valid modes are: + +* `ASYNC`: Asynchronously flush the libraries. +* `!SYNC`: Synchronously flush the libraries. + +For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). + +@return + +@simple-string-reply diff --git a/iredis/data/commands/function-help.md b/iredis/data/commands/function-help.md new file mode 100644 index 0000000..38c300d --- /dev/null +++ b/iredis/data/commands/function-help.md @@ -0,0 +1,5 @@ +The `FUNCTION HELP` command returns a helpful text describing the different subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/function-kill.md b/iredis/data/commands/function-kill.md new file mode 100644 index 0000000..2db5ea5 --- /dev/null +++ b/iredis/data/commands/function-kill.md @@ -0,0 +1,10 @@ +Kill a function that is currently executing. + + +The `FUNCTION KILL` command can be used only on functions that did not modify the dataset during their execution (since stopping a read-only function does not violate the scripting engine's guaranteed atomicity). + +For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). + +@return + +@simple-string-reply diff --git a/iredis/data/commands/function-list.md b/iredis/data/commands/function-list.md new file mode 100644 index 0000000..bb66dba --- /dev/null +++ b/iredis/data/commands/function-list.md @@ -0,0 +1,21 @@ +Return information about the functions and libraries. + +You can use the optional `LIBRARYNAME` argument to specify a pattern for matching library names. +The optional `WITHCODE` modifier will cause the server to include the libraries source implementation in the reply. + +The following information is provided for each of the libraries in the response: + +* **library_name:** the name of the library. +* **engine:** the engine of the library. +* **functions:** the list of functions in the library. + Each function has the following fields: + * **name:** the name of the function. + * **description:** the function's description. + * **flags:** an array of [function flags](/docs/manual/programmability/functions-intro/#function-flags). +* **library_code:** the library's source code (when given the `WITHCODE` modifier). + +For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). + +@return + +@array-reply diff --git a/iredis/data/commands/function-load.md b/iredis/data/commands/function-load.md new file mode 100644 index 0000000..16f125b --- /dev/null +++ b/iredis/data/commands/function-load.md @@ -0,0 +1,36 @@ +Load a library to Redis. + +The command's gets a single mandatory parameter which is the source code that implements the library. +The library payload must start with Shebang statement that provides a metadata about the library (like the engine to use and the library name). +Shebang format: `#!<engine name> name=<library name>`. Currently engine name must be `lua`. + +For the Lua engine, the implementation should declare one or more entry points to the library with the [`redis.register_function()` API](/topics/lua-api#redis.register_function). +Once loaded, you can call the functions in the library with the `FCALL` (or `FCALL_RO` when applicable) command. + +When attempting to load a library with a name that already exists, the Redis server returns an error. +The `REPLACE` modifier changes this behavior and overwrites the existing library with the new contents. + +The command will return an error in the following circumstances: + +* An invalid _engine-name_ was provided. +* The library's name already exists without the `REPLACE` modifier. +* A function in the library is created with a name that already exists in another library (even when `REPLACE` is specified). +* The engine failed in creating the library's functions (due to a compilation error, for example). +* No functions were declared by the library. + +For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). + +@return + +@string - the library name that was loaded + +@examples + +The following example will create a library named `mylib` with a single function, `myfunc`, that returns the first argument it gets. + +``` +redis> FUNCTION LOAD "#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return args[1] end)" +mylib +redis> FCALL myfunc 0 hello +"hello" +``` diff --git a/iredis/data/commands/function-restore.md b/iredis/data/commands/function-restore.md new file mode 100644 index 0000000..2868d16 --- /dev/null +++ b/iredis/data/commands/function-restore.md @@ -0,0 +1,15 @@ +Restore libraries from the serialized payload. + +You can use the optional _policy_ argument to provide a policy for handling existing libraries. +The following policies are allowed: + +* **APPEND:** appends the restored libraries to the existing libraries and aborts on collision. + This is the default policy. +* **FLUSH:** deletes all existing libraries before restoring the payload. +* **REPLACE:** appends the restored libraries to the existing libraries, replacing any existing ones in case of name collisions. Note that this policy doesn't prevent function name collisions, only libraries. + +For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). + +@return + +@simple-string-reply diff --git a/iredis/data/commands/function-stats.md b/iredis/data/commands/function-stats.md new file mode 100644 index 0000000..005b47b --- /dev/null +++ b/iredis/data/commands/function-stats.md @@ -0,0 +1,21 @@ +Return information about the function that's currently running and information about the available execution engines. + +The reply is map with two keys: + +1. `running_script`: information about the running script. + If there's no in-flight function, the server replies with a _nil_. + Otherwise, this is a map with the following keys: + * **name:** the name of the function. + * **command:** the command and arguments used for invoking the function. + * **duration_ms:** the function's runtime duration in milliseconds. +2. `engines`: this is a map of maps. Each entry in the map represent a single engine. + Engine map contains statistics about the engine like number of functions and number of libraries. + + +You can use this command to inspect the invocation of a long-running function and decide whether kill it with the `FUNCTION KILL` command. + +For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). + +@return + +@array-reply
\ No newline at end of file diff --git a/iredis/data/commands/function.md b/iredis/data/commands/function.md new file mode 100644 index 0000000..36ccd9b --- /dev/null +++ b/iredis/data/commands/function.md @@ -0,0 +1,3 @@ +This is a container command for function commands. + +To see the list of available commands you can call `FUNCTION HELP`.
\ No newline at end of file diff --git a/iredis/data/commands/geoadd.md b/iredis/data/commands/geoadd.md new file mode 100644 index 0000000..ecdd6e8 --- /dev/null +++ b/iredis/data/commands/geoadd.md @@ -0,0 +1,56 @@ +Adds the specified geospatial items (longitude, latitude, name) to the specified key. Data is stored into the key as a sorted set, in a way that makes it possible to query the items with the `GEOSEARCH` command. + +The command takes arguments in the standard format x,y so the longitude must be specified before the latitude. There are limits to the coordinates that can be indexed: areas very near to the poles are not indexable. + +The exact limits, as specified by EPSG:900913 / EPSG:3785 / OSGEO:41001 are the following: + +* Valid longitudes are from -180 to 180 degrees. +* Valid latitudes are from -85.05112878 to 85.05112878 degrees. + +The command will report an error when the user attempts to index coordinates outside the specified ranges. + +**Note:** there is no **GEODEL** command because you can use `ZREM` to remove elements. The Geo index structure is just a sorted set. + +## GEOADD options + +`GEOADD` also provides the following options: + +* **XX**: Only update elements that already exist. Never add elements. +* **NX**: Don't update already existing elements. Always add new elements. +* **CH**: Modify the return value from the number of new elements added, to the total number of elements changed (CH is an abbreviation of *changed*). Changed elements are **new elements added** and elements already existing for which **the coordinates was updated**. So elements specified in the command line having the same score as they had in the past are not counted. Note: normally, the return value of `GEOADD` only counts the number of new elements added. + +Note: The **XX** and **NX** options are mutually exclusive. + +How does it work? +--- + +The way the sorted set is populated is using a technique called +[Geohash](https://en.wikipedia.org/wiki/Geohash). Latitude and Longitude +bits are interleaved to form a unique 52-bit integer. We know +that a sorted set double score can represent a 52-bit integer without losing +precision. + +This format allows for bounding box and radius querying by checking the 1+8 areas needed to cover the whole shape and discarding elements outside it. The areas are checked by calculating the range of the box covered, removing enough bits from the less significant part of the sorted set score, and computing the score range to query in the sorted set for each area. + +What Earth model does it use? +--- + +The model assumes that the Earth is a sphere since it uses the Haversine formula to calculate distance. This formula is only an approximation when applied to the Earth, which is not a perfect sphere. +The introduced errors are not an issue when used, for example, by social networks and similar applications requiring this type of querying. +However, in the worst case, the error may be up to 0.5%, so you may want to consider other systems for error-critical applications. + +@return + +@integer-reply, specifically: + +* When used without optional arguments, the number of elements added to the sorted set (excluding score updates). +* If the `CH` option is specified, the number of elements that were changed (added or updated). + +@examples + +```cli +GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" +GEODIST Sicily Palermo Catania +GEORADIUS Sicily 15 37 100 km +GEORADIUS Sicily 15 37 200 km +``` diff --git a/iredis/data/commands/geodecode.md b/iredis/data/commands/geodecode.md new file mode 100644 index 0000000..f083fd9 --- /dev/null +++ b/iredis/data/commands/geodecode.md @@ -0,0 +1,34 @@ +Geospatial Redis commands encode positions of objects in a single 52 bit +integer, using a technique called geohash. Those 52 bit integers are: + +1. Returned by `GEOAENCODE` as return value. +2. Used by `GEOADD` as sorted set scores of members. + +The `GEODECODE` command is able to translate the 52 bit integers back into a +position expressed as longitude and latitude. The command also returns the +corners of the box that the 52 bit integer identifies on the earth surface, +since each 52 integer actually represent not a single point, but a small area. + +This command usefulness is limited to the rare situations where you want to +fetch raw data from the sorted set, for example with `ZRANGE`, and later need to +decode the scores into positions. The other obvious use is debugging. + +@return + +@array-reply, specifically: + +The command returns an array of three elements. Each element of the main array +is an array of two elements, specifying a longitude and a latitude. So the +returned value is in the following form: + +- center-longitude, center-latitude +- min-longitude, min-latitude +- max-longitude, max-latitude + +@examples + +```cli +GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" +ZSCORE Sicily "Palermo" +GEODECODE 3479099956230698 +``` diff --git a/iredis/data/commands/geodist.md b/iredis/data/commands/geodist.md new file mode 100644 index 0000000..af78cdf --- /dev/null +++ b/iredis/data/commands/geodist.md @@ -0,0 +1,31 @@ +Return the distance between two members in the geospatial index represented by the sorted set. + +Given a sorted set representing a geospatial index, populated using the `GEOADD` command, the command returns the distance between the two specified members in the specified unit. + +If one or both the members are missing, the command returns NULL. + +The unit must be one of the following, and defaults to meters: + +* **m** for meters. +* **km** for kilometers. +* **mi** for miles. +* **ft** for feet. + +The distance is computed assuming that the Earth is a perfect sphere, so errors up to 0.5% are possible in edge cases. + +@return + +@bulk-string-reply, specifically: + +The command returns the distance as a double (represented as a string) +in the specified unit, or NULL if one or both the elements are missing. + +@examples + +```cli +GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" +GEODIST Sicily Palermo Catania +GEODIST Sicily Palermo Catania km +GEODIST Sicily Palermo Catania mi +GEODIST Sicily Foo Bar +``` diff --git a/iredis/data/commands/geoencode.md b/iredis/data/commands/geoencode.md new file mode 100644 index 0000000..5e10af6 --- /dev/null +++ b/iredis/data/commands/geoencode.md @@ -0,0 +1,57 @@ +Geospatial Redis commands encode positions of objects in a single 52 bit +integer, using a technique called geohash. The encoding is further explained in +the `GEODECODE` and `GEOADD` documentation. The `GEOENCODE` command, documented +in this page, is able to convert a longitude and latitude pair into such 52 bit +integer, which is used as the _score_ for the sorted set members representing +geopositional information. + +Normally you don't need to use this command, unless you plan to implement low +level code in the client side interacting with the Redis geo commands. This +command may also be useful for debugging purposes. + +`GEOENCODE` takes as input: + +1. The longitude and latitude of a point on the Earth surface. +2. Optionally a radius represented by an integer and an unit. + +And returns a set of information, including the representation of the position +as a 52 bit integer, the min and max corners of the bounding box represented by +the geo hash, the center point in the area covered by the geohash integer, and +finally the two sorted set scores to query in order to retrieve all the elements +included in the geohash area. + +The radius optionally provided to the command is used in order to compute the +two scores returned by the command for range query purposes. Moreover the +returned geohash integer will only have the most significant bits set, according +to the number of bits needed to approximate the specified radius. + +## Use case + +As already specified this command is mostly not needed if not for debugging. +However there are actual use cases, which is, when there is to query for the +same areas multiple times, or with a different granularity or area shape +compared to what Redis `GEORADIUS` is able to provide, the client may implement +using this command part of the logic on the client side. Score ranges +representing given areas can be cached client side and used to retrieve elements +directly using `ZRANGEBYSCORE`. + +@return + +@array-reply, specifically: + +The command returns an array of give elements in the following order: + +- The 52 bit geohash +- min-longitude, min-latitude of the area identified +- max-longitude, max-latitude of the area identified +- center-longitude, center-latitude +- min-score and max-score of the sorted set to retrieve the members inside the + area + +@examples + +```cli +GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" +ZSCORE Sicily "Palermo" +GEOENCODE 13.361389 38.115556 100 km +``` diff --git a/iredis/data/commands/geohash.md b/iredis/data/commands/geohash.md new file mode 100644 index 0000000..a99ade2 --- /dev/null +++ b/iredis/data/commands/geohash.md @@ -0,0 +1,33 @@ +Return valid [Geohash](https://en.wikipedia.org/wiki/Geohash) strings representing the position of one or more elements in a sorted set value representing a geospatial index (where elements were added using `GEOADD`). + +Normally Redis represents positions of elements using a variation of the Geohash +technique where positions are encoded using 52 bit integers. The encoding is +also different compared to the standard because the initial min and max +coordinates used during the encoding and decoding process are different. This +command however **returns a standard Geohash** in the form of a string as +described in the [Wikipedia article](https://en.wikipedia.org/wiki/Geohash) and compatible with the [geohash.org](http://geohash.org) web site. + +Geohash string properties +--- + +The command returns 11 characters Geohash strings, so no precision is lost +compared to the Redis internal 52 bit representation. The returned Geohashes +have the following properties: + +1. They can be shortened removing characters from the right. It will lose precision but will still point to the same area. +2. It is possible to use them in `geohash.org` URLs such as `http://geohash.org/<geohash-string>`. This is an [example of such URL](http://geohash.org/sqdtr74hyu0). +3. Strings with a similar prefix are nearby, but the contrary is not true, it is possible that strings with different prefixes are nearby too. + +@return + +@array-reply, specifically: + +The command returns an array where each element is the Geohash corresponding to +each member name passed as argument to the command. + +@examples + +```cli +GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" +GEOHASH Sicily Palermo Catania +``` diff --git a/iredis/data/commands/geopos.md b/iredis/data/commands/geopos.md new file mode 100644 index 0000000..19dd377 --- /dev/null +++ b/iredis/data/commands/geopos.md @@ -0,0 +1,22 @@ +Return the positions (longitude,latitude) of all the specified members of the geospatial index represented by the sorted set at *key*. + +Given a sorted set representing a geospatial index, populated using the `GEOADD` command, it is often useful to obtain back the coordinates of specified members. When the geospatial index is populated via `GEOADD` the coordinates are converted into a 52 bit geohash, so the coordinates returned may not be exactly the ones used in order to add the elements, but small errors may be introduced. + +The command can accept a variable number of arguments so it always returns an array of positions even when a single element is specified. + +@return + +@array-reply, specifically: + +The command returns an array where each element is a two elements array +representing longitude and latitude (x,y) of each member name passed as +argument to the command. + +Non existing elements are reported as NULL elements of the array. + +@examples + +```cli +GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" +GEOPOS Sicily Palermo Catania NonExisting +``` diff --git a/iredis/data/commands/georadius.md b/iredis/data/commands/georadius.md new file mode 100644 index 0000000..3d0bba4 --- /dev/null +++ b/iredis/data/commands/georadius.md @@ -0,0 +1,66 @@ +Return the members of a sorted set populated with geospatial information using `GEOADD`, which are within the borders of the area specified with the center location and the maximum distance from the center (the radius). + +This manual page also covers the `GEORADIUS_RO` and `GEORADIUSBYMEMBER_RO` variants (see the section below for more information). + +The common use case for this command is to retrieve geospatial items near a specified point not farther than a given amount of meters (or other units). This allows, for example, to suggest mobile users of an application nearby places. + +The radius is specified in one of the following units: + +* **m** for meters. +* **km** for kilometers. +* **mi** for miles. +* **ft** for feet. + +The command optionally returns additional information using the following options: + +* `WITHDIST`: Also return the distance of the returned items from the specified center. The distance is returned in the same unit as the unit specified as the radius argument of the command. +* `WITHCOORD`: Also return the longitude,latitude coordinates of the matching items. +* `WITHHASH`: Also return the raw geohash-encoded sorted set score of the item, in the form of a 52 bit unsigned integer. This is only useful for low level hacks or debugging and is otherwise of little interest for the general user. + +The command default is to return unsorted items. Two different sorting methods can be invoked using the following two options: + +* `ASC`: Sort returned items from the nearest to the farthest, relative to the center. +* `DESC`: Sort returned items from the farthest to the nearest, relative to the center. + +By default all the matching items are returned. It is possible to limit the results to the first N matching items by using the **COUNT `<count>`** option. +When `ANY` is provided the command will return as soon as enough matches are found, +so the results may not be the ones closest to the specified point, but on the other hand, the effort invested by the server is significantly lower. +When `ANY` is not provided, the command will perform an effort that is proportional to the number of items matching the specified area and sort them, +so to query very large areas with a very small `COUNT` option may be slow even if just a few results are returned. + +By default the command returns the items to the client. It is possible to store the results with one of these options: + +* `!STORE`: Store the items in a sorted set populated with their geospatial information. +* `!STOREDIST`: Store the items in a sorted set populated with their distance from the center as a floating point number, in the same unit specified in the radius. + +@return + +@array-reply, specifically: + +* Without any `WITH` option specified, the command just returns a linear array like ["New York","Milan","Paris"]. +* If `WITHCOORD`, `WITHDIST` or `WITHHASH` options are specified, the command returns an array of arrays, where each sub-array represents a single item. + +When additional information is returned as an array of arrays for each item, the first item in the sub-array is always the name of the returned item. The other information is returned in the following order as successive elements of the sub-array. + +1. The distance from the center as a floating point number, in the same unit specified in the radius. +2. The geohash integer. +3. The coordinates as a two items x,y array (longitude,latitude). + +So for example the command `GEORADIUS Sicily 15 37 200 km WITHCOORD WITHDIST` will return each item in the following way: + + ["Palermo","190.4424",["13.361389338970184","38.115556395496299"]] + +## Read-only variants + +Since `GEORADIUS` and `GEORADIUSBYMEMBER` have a `STORE` and `STOREDIST` option they are technically flagged as writing commands in the Redis command table. For this reason read-only replicas will flag them, and Redis Cluster replicas will redirect them to the master instance even if the connection is in read-only mode (see the `READONLY` command of Redis Cluster). + +Breaking the compatibility with the past was considered but rejected, at least for Redis 4.0, so instead two read-only variants of the commands were added. They are exactly like the original commands but refuse the `STORE` and `STOREDIST` options. The two variants are called `GEORADIUS_RO` and `GEORADIUSBYMEMBER_RO`, and can safely be used in replicas. + +@examples + +```cli +GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" +GEORADIUS Sicily 15 37 200 km WITHDIST +GEORADIUS Sicily 15 37 200 km WITHCOORD +GEORADIUS Sicily 15 37 200 km WITHDIST WITHCOORD +``` diff --git a/iredis/data/commands/georadius_ro.md b/iredis/data/commands/georadius_ro.md new file mode 100644 index 0000000..d2e3399 --- /dev/null +++ b/iredis/data/commands/georadius_ro.md @@ -0,0 +1,7 @@ +Read-only variant of the `GEORADIUS` command. + +This command is identical to the `GEORADIUS` command, except that it doesn't support the optional `STORE` and `STOREDIST` parameters. + +@return + +@array-reply: An array with each entry being the corresponding result of the subcommand given at the same position. diff --git a/iredis/data/commands/georadiusbymember.md b/iredis/data/commands/georadiusbymember.md new file mode 100644 index 0000000..5eab55d --- /dev/null +++ b/iredis/data/commands/georadiusbymember.md @@ -0,0 +1,16 @@ +This command is exactly like `GEORADIUS` with the sole difference that instead +of taking, as the center of the area to query, a longitude and latitude value, it takes the name of a member already existing inside the geospatial index represented by the sorted set. + +The position of the specified member is used as the center of the query. + +Please check the example below and the `GEORADIUS` documentation for more information about the command and its options. + +Note that `GEORADIUSBYMEMBER_RO` is also available since Redis 3.2.10 and Redis 4.0.0 in order to provide a read-only command that can be used in replicas. See the `GEORADIUS` page for more information. + +@examples + +```cli +GEOADD Sicily 13.583333 37.316667 "Agrigento" +GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" +GEORADIUSBYMEMBER Sicily Agrigento 100 km +``` diff --git a/iredis/data/commands/georadiusbymember_ro.md b/iredis/data/commands/georadiusbymember_ro.md new file mode 100644 index 0000000..94a57a8 --- /dev/null +++ b/iredis/data/commands/georadiusbymember_ro.md @@ -0,0 +1,3 @@ +Read-only variant of the `GEORADIUSBYMEMBER` command. + +This command is identical to the `GEORADIUSBYMEMBER` command, except that it doesn't support the optional `STORE` and `STOREDIST` parameters. diff --git a/iredis/data/commands/geosearch.md b/iredis/data/commands/geosearch.md new file mode 100644 index 0000000..972c1c9 --- /dev/null +++ b/iredis/data/commands/geosearch.md @@ -0,0 +1,51 @@ +Return the members of a sorted set populated with geospatial information using `GEOADD`, which are within the borders of the area specified by a given shape. This command extends the `GEORADIUS` command, so in addition to searching within circular areas, it supports searching within rectangular areas. + +This command should be used in place of the deprecated `GEORADIUS` and `GEORADIUSBYMEMBER` commands. + +The query's center point is provided by one of these mandatory options: + +* `FROMMEMBER`: Use the position of the given existing `<member>` in the sorted set. +* `FROMLONLAT`: Use the given `<longitude>` and `<latitude>` position. + +The query's shape is provided by one of these mandatory options: + +* `BYRADIUS`: Similar to `GEORADIUS`, search inside circular area according to given `<radius>`. +* `BYBOX`: Search inside an axis-aligned rectangle, determined by `<height>` and `<width>`. + +The command optionally returns additional information using the following options: + +* `WITHDIST`: Also return the distance of the returned items from the specified center point. The distance is returned in the same unit as specified for the radius or height and width arguments. +* `WITHCOORD`: Also return the longitude and latitude of the matching items. +* `WITHHASH`: Also return the raw geohash-encoded sorted set score of the item, in the form of a 52 bit unsigned integer. This is only useful for low level hacks or debugging and is otherwise of little interest for the general user. + +Matching items are returned unsorted by default. To sort them, use one of the following two options: + +* `ASC`: Sort returned items from the nearest to the farthest, relative to the center point. +* `DESC`: Sort returned items from the farthest to the nearest, relative to the center point. + +All matching items are returned by default. To limit the results to the first N matching items, use the **COUNT `<count>`** option. +When the `ANY` option is used, the command returns as soon as enough matches are found. This means that the results returned may not be the ones closest to the specified point, but the effort invested by the server to generate them is significantly less. +When `ANY` is not provided, the command will perform an effort that is proportional to the number of items matching the specified area and sort them, +so to query very large areas with a very small `COUNT` option may be slow even if just a few results are returned. + +@return + +@array-reply, specifically: + +* Without any `WITH` option specified, the command just returns a linear array like ["New York","Milan","Paris"]. +* If `WITHCOORD`, `WITHDIST` or `WITHHASH` options are specified, the command returns an array of arrays, where each sub-array represents a single item. + +When additional information is returned as an array of arrays for each item, the first item in the sub-array is always the name of the returned item. The other information is returned in the following order as successive elements of the sub-array. + +1. The distance from the center as a floating point number, in the same unit specified in the shape. +2. The geohash integer. +3. The coordinates as a two items x,y array (longitude,latitude). + +@examples + +```cli +GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" +GEOADD Sicily 12.758489 38.788135 "edge1" 17.241510 38.788135 "edge2" +GEOSEARCH Sicily FROMLONLAT 15 37 BYRADIUS 200 km ASC +GEOSEARCH Sicily FROMLONLAT 15 37 BYBOX 400 400 km ASC WITHCOORD WITHDIST +``` diff --git a/iredis/data/commands/geosearchstore.md b/iredis/data/commands/geosearchstore.md new file mode 100644 index 0000000..2a4fc38 --- /dev/null +++ b/iredis/data/commands/geosearchstore.md @@ -0,0 +1,22 @@ +This command is like `GEOSEARCH`, but stores the result in destination key. + +This command comes in place of the now deprecated `GEORADIUS` and `GEORADIUSBYMEMBER`. + +By default, it stores the results in the `destination` sorted set with their geospatial information. + +When using the `STOREDIST` option, the command stores the items in a sorted set populated with their distance from the center of the circle or box, as a floating-point number, in the same unit specified for that shape. + +@return + +@integer-reply: the number of elements in the resulting set. + +@examples + +```cli +GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" +GEOADD Sicily 12.758489 38.788135 "edge1" 17.241510 38.788135 "edge2" +GEOSEARCHSTORE key1 Sicily FROMLONLAT 15 37 BYBOX 400 400 km ASC COUNT 3 +GEOSEARCH key1 FROMLONLAT 15 37 BYBOX 400 400 km ASC WITHCOORD WITHDIST WITHHASH +GEOSEARCHSTORE key2 Sicily FROMLONLAT 15 37 BYBOX 400 400 km ASC COUNT 3 STOREDIST +ZRANGE key2 0 -1 WITHSCORES +```
\ No newline at end of file diff --git a/iredis/data/commands/get.md b/iredis/data/commands/get.md new file mode 100644 index 0000000..20a3feb --- /dev/null +++ b/iredis/data/commands/get.md @@ -0,0 +1,16 @@ +Get the value of `key`. +If the key does not exist the special value `nil` is returned. +An error is returned if the value stored at `key` is not a string, because `GET` +only handles string values. + +@return + +@bulk-string-reply: the value of `key`, or `nil` when `key` does not exist. + +@examples + +```cli +GET nonexisting +SET mykey "Hello" +GET mykey +``` diff --git a/iredis/data/commands/getbit.md b/iredis/data/commands/getbit.md new file mode 100644 index 0000000..1506af3 --- /dev/null +++ b/iredis/data/commands/getbit.md @@ -0,0 +1,20 @@ +Returns the bit value at _offset_ in the string value stored at _key_. + +When _offset_ is beyond the string length, the string is assumed to be a +contiguous space with 0 bits. +When _key_ does not exist it is assumed to be an empty string, so _offset_ is +always out of range and the value is also assumed to be a contiguous space with +0 bits. + +@return + +@integer-reply: the bit value stored at _offset_. + +@examples + +```cli +SETBIT mykey 7 1 +GETBIT mykey 0 +GETBIT mykey 7 +GETBIT mykey 100 +``` diff --git a/iredis/data/commands/getdel.md b/iredis/data/commands/getdel.md new file mode 100644 index 0000000..8474e93 --- /dev/null +++ b/iredis/data/commands/getdel.md @@ -0,0 +1,14 @@ +Get the value of `key` and delete the key. +This command is similar to `GET`, except for the fact that it also deletes the key on success (if and only if the key's value type is a string). + +@return + +@bulk-string-reply: the value of `key`, `nil` when `key` does not exist, or an error if the key's value type isn't a string. + +@examples + +```cli +SET mykey "Hello" +GETDEL mykey +GET mykey +``` diff --git a/iredis/data/commands/getex.md b/iredis/data/commands/getex.md new file mode 100644 index 0000000..89ce809 --- /dev/null +++ b/iredis/data/commands/getex.md @@ -0,0 +1,26 @@ +Get the value of `key` and optionally set its expiration. +`GETEX` is similar to `GET`, but is a write command with additional options. + +## Options + +The `GETEX` command supports a set of options that modify its behavior: + +* `EX` *seconds* -- Set the specified expire time, in seconds. +* `PX` *milliseconds* -- Set the specified expire time, in milliseconds. +* `EXAT` *timestamp-seconds* -- Set the specified Unix time at which the key will expire, in seconds. +* `PXAT` *timestamp-milliseconds* -- Set the specified Unix time at which the key will expire, in milliseconds. +* `PERSIST` -- Remove the time to live associated with the key. + +@return + +@bulk-string-reply: the value of `key`, or `nil` when `key` does not exist. + +@examples + +```cli +SET mykey "Hello" +GETEX mykey +TTL mykey +GETEX mykey EX 60 +TTL mykey +``` diff --git a/iredis/data/commands/getrange.md b/iredis/data/commands/getrange.md new file mode 100644 index 0000000..7283def --- /dev/null +++ b/iredis/data/commands/getrange.md @@ -0,0 +1,22 @@ +Returns the substring of the string value stored at `key`, determined by the +offsets `start` and `end` (both are inclusive). +Negative offsets can be used in order to provide an offset starting from the end +of the string. +So -1 means the last character, -2 the penultimate and so forth. + +The function handles out of range requests by limiting the resulting range to +the actual length of the string. + +@return + +@bulk-string-reply + +@examples + +```cli +SET mykey "This is a string" +GETRANGE mykey 0 3 +GETRANGE mykey -3 -1 +GETRANGE mykey 0 -1 +GETRANGE mykey 10 100 +``` diff --git a/iredis/data/commands/getset.md b/iredis/data/commands/getset.md new file mode 100644 index 0000000..dd7aee7 --- /dev/null +++ b/iredis/data/commands/getset.md @@ -0,0 +1,30 @@ +Atomically sets `key` to `value` and returns the old value stored at `key`. +Returns an error when `key` exists but does not hold a string value. Any +previous time to live associated with the key is discarded on successful +`SET` operation. + +## Design pattern + +`GETSET` can be used together with `INCR` for counting with atomic reset. +For example: a process may call `INCR` against the key `mycounter` every time +some event occurs, but from time to time we need to get the value of the counter +and reset it to zero atomically. +This can be done using `GETSET mycounter "0"`: + +```cli +INCR mycounter +GETSET mycounter "0" +GET mycounter +``` + +@return + +@bulk-string-reply: the old value stored at `key`, or `nil` when `key` did not exist. + +@examples + +```cli +SET mykey "Hello" +GETSET mykey "World" +GET mykey +``` diff --git a/iredis/data/commands/hdel.md b/iredis/data/commands/hdel.md new file mode 100644 index 0000000..ab6874e --- /dev/null +++ b/iredis/data/commands/hdel.md @@ -0,0 +1,17 @@ +Removes the specified fields from the hash stored at `key`. +Specified fields that do not exist within this hash are ignored. +If `key` does not exist, it is treated as an empty hash and this command returns +`0`. + +@return + +@integer-reply: the number of fields that were removed from the hash, not +including specified but non existing fields. + +@examples + +```cli +HSET myhash field1 "foo" +HDEL myhash field1 +HDEL myhash field2 +``` diff --git a/iredis/data/commands/hello.md b/iredis/data/commands/hello.md new file mode 100644 index 0000000..3eb6597 --- /dev/null +++ b/iredis/data/commands/hello.md @@ -0,0 +1,61 @@ +Switch to a different protocol, optionally authenticating and setting the +connection's name, or provide a contextual client report. + +Redis version 6 and above supports two protocols: the old protocol, RESP2, and +a new one introduced with Redis 6, RESP3. RESP3 has certain advantages since +when the connection is in this mode, Redis is able to reply with more semantical +replies: for instance, `HGETALL` will return a *map type*, so a client library +implementation no longer requires to know in advance to translate the array into +a hash before returning it to the caller. For a full coverage of RESP3, please +[check this repository](https://github.com/antirez/resp3). + +In Redis 6 connections start in RESP2 mode, so clients implementing RESP2 do +not need to updated or changed. There are no short term plans to drop support for +RESP2, although future version may default to RESP3. + +`HELLO` always replies with a list of current server and connection properties, +such as: versions, modules loaded, client ID, replication role and so forth. +When called without any arguments in Redis 6.2 and its default use of RESP2 +protocol, the reply looks like this: + + > HELLO + 1) "server" + 2) "redis" + 3) "version" + 4) "255.255.255" + 5) "proto" + 6) (integer) 2 + 7) "id" + 8) (integer) 5 + 9) "mode" + 10) "standalone" + 11) "role" + 12) "master" + 13) "modules" + 14) (empty array) + +Clients that want to handshake using the RESP3 mode need to call the `HELLO` +command and specify the value "3" as the `protover` argument, like so: + + > HELLO 3 + 1# "server" => "redis" + 2# "version" => "6.0.0" + 3# "proto" => (integer) 3 + 4# "id" => (integer) 10 + 5# "mode" => "standalone" + 6# "role" => "master" + 7# "modules" => (empty array) + +Because `HELLO` replies with useful information, and given that `protover` is +optional or can be set to "2", client library authors may consider using this +command instead of the canonical `PING` when setting up the connection. + +When called with the optional `protover` argument, this command switches the +protocol to the specified version and also accepts the following options: + +* `AUTH <username> <password>`: directly authenticate the connection in addition to switching to the specified protocol version. This makes calling `AUTH` before `HELLO` unnecessary when setting up a new connection. Note that the `username` can be set to "default" to authenticate against a server that does not use ACLs, but rather the simpler `requirepass` mechanism of Redis prior to version 6. +* `SETNAME <clientname>`: this is the equivalent of calling `CLIENT SETNAME`. + +@return + +@array-reply: a list of server properties. The reply is a map instead of an array when RESP3 is selected. The command returns an error if the `protover` requested does not exist. diff --git a/iredis/data/commands/hexists.md b/iredis/data/commands/hexists.md new file mode 100644 index 0000000..f27678a --- /dev/null +++ b/iredis/data/commands/hexists.md @@ -0,0 +1,16 @@ +Returns if `field` is an existing field in the hash stored at `key`. + +@return + +@integer-reply, specifically: + +* `1` if the hash contains `field`. +* `0` if the hash does not contain `field`, or `key` does not exist. + +@examples + +```cli +HSET myhash field1 "foo" +HEXISTS myhash field1 +HEXISTS myhash field2 +``` diff --git a/iredis/data/commands/hget.md b/iredis/data/commands/hget.md new file mode 100644 index 0000000..b8d9101 --- /dev/null +++ b/iredis/data/commands/hget.md @@ -0,0 +1,14 @@ +Returns the value associated with `field` in the hash stored at `key`. + +@return + +@bulk-string-reply: the value associated with `field`, or `nil` when `field` is not +present in the hash or `key` does not exist. + +@examples + +```cli +HSET myhash field1 "foo" +HGET myhash field1 +HGET myhash field2 +``` diff --git a/iredis/data/commands/hgetall.md b/iredis/data/commands/hgetall.md new file mode 100644 index 0000000..3717f00 --- /dev/null +++ b/iredis/data/commands/hgetall.md @@ -0,0 +1,16 @@ +Returns all fields and values of the hash stored at `key`. +In the returned value, every field name is followed by its value, so the length +of the reply is twice the size of the hash. + +@return + +@array-reply: list of fields and their values stored in the hash, or an +empty list when `key` does not exist. + +@examples + +```cli +HSET myhash field1 "Hello" +HSET myhash field2 "World" +HGETALL myhash +``` diff --git a/iredis/data/commands/hincrby.md b/iredis/data/commands/hincrby.md new file mode 100644 index 0000000..3d24c25 --- /dev/null +++ b/iredis/data/commands/hincrby.md @@ -0,0 +1,23 @@ +Increments the number stored at `field` in the hash stored at `key` by +`increment`. +If `key` does not exist, a new key holding a hash is created. +If `field` does not exist the value is set to `0` before the operation is +performed. + +The range of values supported by `HINCRBY` is limited to 64 bit signed integers. + +@return + +@integer-reply: the value at `field` after the increment operation. + +@examples + +Since the `increment` argument is signed, both increment and decrement +operations can be performed: + +```cli +HSET myhash field 5 +HINCRBY myhash field 1 +HINCRBY myhash field -1 +HINCRBY myhash field -10 +``` diff --git a/iredis/data/commands/hincrbyfloat.md b/iredis/data/commands/hincrbyfloat.md new file mode 100644 index 0000000..d6eb472 --- /dev/null +++ b/iredis/data/commands/hincrbyfloat.md @@ -0,0 +1,33 @@ +Increment the specified `field` of a hash stored at `key`, and representing a +floating point number, by the specified `increment`. If the increment value +is negative, the result is to have the hash field value **decremented** instead of incremented. +If the field does not exist, it is set to `0` before performing the operation. +An error is returned if one of the following conditions occur: + +* The field contains a value of the wrong type (not a string). +* The current field content or the specified increment are not parsable as a + double precision floating point number. + +The exact behavior of this command is identical to the one of the `INCRBYFLOAT` +command, please refer to the documentation of `INCRBYFLOAT` for further +information. + +@return + +@bulk-string-reply: the value of `field` after the increment. + +@examples + +```cli +HSET mykey field 10.50 +HINCRBYFLOAT mykey field 0.1 +HINCRBYFLOAT mykey field -5 +HSET mykey field 5.0e3 +HINCRBYFLOAT mykey field 2.0e2 +``` + +## Implementation details + +The command is always propagated in the replication link and the Append Only +File as a `HSET` operation, so that differences in the underlying floating point +math implementation will not be sources of inconsistency. diff --git a/iredis/data/commands/hkeys.md b/iredis/data/commands/hkeys.md new file mode 100644 index 0000000..c74b01e --- /dev/null +++ b/iredis/data/commands/hkeys.md @@ -0,0 +1,14 @@ +Returns all field names in the hash stored at `key`. + +@return + +@array-reply: list of fields in the hash, or an empty list when `key` does +not exist. + +@examples + +```cli +HSET myhash field1 "Hello" +HSET myhash field2 "World" +HKEYS myhash +``` diff --git a/iredis/data/commands/hlen.md b/iredis/data/commands/hlen.md new file mode 100644 index 0000000..2c18193 --- /dev/null +++ b/iredis/data/commands/hlen.md @@ -0,0 +1,13 @@ +Returns the number of fields contained in the hash stored at `key`. + +@return + +@integer-reply: number of fields in the hash, or `0` when `key` does not exist. + +@examples + +```cli +HSET myhash field1 "Hello" +HSET myhash field2 "World" +HLEN myhash +``` diff --git a/iredis/data/commands/hmget.md b/iredis/data/commands/hmget.md new file mode 100644 index 0000000..b10c43b --- /dev/null +++ b/iredis/data/commands/hmget.md @@ -0,0 +1,17 @@ +Returns the values associated with the specified `fields` in the hash stored at +`key`. + +For every `field` that does not exist in the hash, a `nil` value is returned. +Because non-existing keys are treated as empty hashes, running `HMGET` against +a non-existing `key` will return a list of `nil` values. + +@return + +@array-reply: list of values associated with the given fields, in the same +order as they are requested. + +```cli +HSET myhash field1 "Hello" +HSET myhash field2 "World" +HMGET myhash field1 field2 nofield +``` diff --git a/iredis/data/commands/hmset.md b/iredis/data/commands/hmset.md new file mode 100644 index 0000000..8cec775 --- /dev/null +++ b/iredis/data/commands/hmset.md @@ -0,0 +1,16 @@ +Sets the specified fields to their respective values in the hash stored at +`key`. +This command overwrites any specified fields already existing in the hash. +If `key` does not exist, a new key holding a hash is created. + +@return + +@simple-string-reply + +@examples + +```cli +HMSET myhash field1 "Hello" field2 "World" +HGET myhash field1 +HGET myhash field2 +``` diff --git a/iredis/data/commands/hrandfield.md b/iredis/data/commands/hrandfield.md new file mode 100644 index 0000000..389a109 --- /dev/null +++ b/iredis/data/commands/hrandfield.md @@ -0,0 +1,39 @@ +When called with just the `key` argument, return a random field from the hash value stored at `key`. + +If the provided `count` argument is positive, return an array of **distinct fields**. +The array's length is either `count` or the hash's number of fields (`HLEN`), whichever is lower. + +If called with a negative `count`, the behavior changes and the command is allowed to return the **same field multiple times**. +In this case, the number of returned fields is the absolute value of the specified `count`. + +The optional `WITHVALUES` modifier changes the reply so it includes the respective values of the randomly selected hash fields. + +@return + +@bulk-string-reply: without the additional `count` argument, the command returns a Bulk Reply with the randomly selected field, or `nil` when `key` does not exist. + +@array-reply: when the additional `count` argument is passed, the command returns an array of fields, or an empty array when `key` does not exist. +If the `WITHVALUES` modifier is used, the reply is a list fields and their values from the hash. + +@examples + +```cli +HMSET coin heads obverse tails reverse edge null +HRANDFIELD coin +HRANDFIELD coin +HRANDFIELD coin -5 WITHVALUES +``` + +## Specification of the behavior when count is passed + +When the `count` argument is a positive value this command behaves as follows: + +* No repeated fields are returned. +* If `count` is bigger than the number of fields in the hash, the command will only return the whole hash without additional fields. +* The order of fields in the reply is not truly random, so it is up to the client to shuffle them if needed. + +When the `count` is a negative value, the behavior changes as follows: + +* Repeating fields are possible. +* Exactly `count` fields, or an empty array if the hash is empty (non-existing key), are always returned. +* The order of fields in the reply is truly random. diff --git a/iredis/data/commands/hscan.md b/iredis/data/commands/hscan.md new file mode 100644 index 0000000..9ab2616 --- /dev/null +++ b/iredis/data/commands/hscan.md @@ -0,0 +1 @@ +See `SCAN` for `HSCAN` documentation. diff --git a/iredis/data/commands/hset.md b/iredis/data/commands/hset.md new file mode 100644 index 0000000..42e15c1 --- /dev/null +++ b/iredis/data/commands/hset.md @@ -0,0 +1,14 @@ +Sets `field` in the hash stored at `key` to `value`. +If `key` does not exist, a new key holding a hash is created. +If `field` already exists in the hash, it is overwritten. + +@return + +@integer-reply: The number of fields that were added. + +@examples + +```cli +HSET myhash field1 "Hello" +HGET myhash field1 +``` diff --git a/iredis/data/commands/hsetnx.md b/iredis/data/commands/hsetnx.md new file mode 100644 index 0000000..c60eaa0 --- /dev/null +++ b/iredis/data/commands/hsetnx.md @@ -0,0 +1,19 @@ +Sets `field` in the hash stored at `key` to `value`, only if `field` does not +yet exist. +If `key` does not exist, a new key holding a hash is created. +If `field` already exists, this operation has no effect. + +@return + +@integer-reply, specifically: + +* `1` if `field` is a new field in the hash and `value` was set. +* `0` if `field` already exists in the hash and no operation was performed. + +@examples + +```cli +HSETNX myhash field "Hello" +HSETNX myhash field "World" +HGET myhash field +``` diff --git a/iredis/data/commands/hstrlen.md b/iredis/data/commands/hstrlen.md new file mode 100644 index 0000000..b187f75 --- /dev/null +++ b/iredis/data/commands/hstrlen.md @@ -0,0 +1,14 @@ +Returns the string length of the value associated with `field` in the hash stored at `key`. If the `key` or the `field` do not exist, 0 is returned. + +@return + +@integer-reply: the string length of the value associated with `field`, or zero when `field` is not present in the hash or `key` does not exist at all. + +@examples + +```cli +HMSET myhash f1 HelloWorld f2 99 f3 -256 +HSTRLEN myhash f1 +HSTRLEN myhash f2 +HSTRLEN myhash f3 +``` diff --git a/iredis/data/commands/hvals.md b/iredis/data/commands/hvals.md new file mode 100644 index 0000000..5526959 --- /dev/null +++ b/iredis/data/commands/hvals.md @@ -0,0 +1,14 @@ +Returns all values in the hash stored at `key`. + +@return + +@array-reply: list of values in the hash, or an empty list when `key` does +not exist. + +@examples + +```cli +HSET myhash field1 "Hello" +HSET myhash field2 "World" +HVALS myhash +``` diff --git a/iredis/data/commands/incr.md b/iredis/data/commands/incr.md new file mode 100644 index 0000000..6abee16 --- /dev/null +++ b/iredis/data/commands/incr.md @@ -0,0 +1,163 @@ +Increments the number stored at `key` by one. +If the key does not exist, it is set to `0` before performing the operation. +An error is returned if the key contains a value of the wrong type or contains a +string that can not be represented as integer. +This operation is limited to 64 bit signed integers. + +**Note**: this is a string operation because Redis does not have a dedicated +integer type. +The string stored at the key is interpreted as a base-10 **64 bit signed +integer** to execute the operation. + +Redis stores integers in their integer representation, so for string values +that actually hold an integer, there is no overhead for storing the string +representation of the integer. + +@return + +@integer-reply: the value of `key` after the increment + +@examples + +```cli +SET mykey "10" +INCR mykey +GET mykey +``` + +## Pattern: Counter + +The counter pattern is the most obvious thing you can do with Redis atomic +increment operations. +The idea is simply send an `INCR` command to Redis every time an operation +occurs. +For instance in a web application we may want to know how many page views this +user did every day of the year. + +To do so the web application may simply increment a key every time the user +performs a page view, creating the key name concatenating the User ID and a +string representing the current date. + +This simple pattern can be extended in many ways: + +* It is possible to use `INCR` and `EXPIRE` together at every page view to have + a counter counting only the latest N page views separated by less than the + specified amount of seconds. +* A client may use GETSET in order to atomically get the current counter value + and reset it to zero. +* Using other atomic increment/decrement commands like `DECR` or `INCRBY` it + is possible to handle values that may get bigger or smaller depending on the + operations performed by the user. + Imagine for instance the score of different users in an online game. + +## Pattern: Rate limiter + +The rate limiter pattern is a special counter that is used to limit the rate at +which an operation can be performed. +The classical materialization of this pattern involves limiting the number of +requests that can be performed against a public API. + +We provide two implementations of this pattern using `INCR`, where we assume +that the problem to solve is limiting the number of API calls to a maximum of +_ten requests per second per IP address_. + +## Pattern: Rate limiter 1 + +The more simple and direct implementation of this pattern is the following: + +``` +FUNCTION LIMIT_API_CALL(ip) +ts = CURRENT_UNIX_TIME() +keyname = ip+":"+ts +MULTI + INCR(keyname) + EXPIRE(keyname,10) +EXEC +current = RESPONSE_OF_INCR_WITHIN_MULTI +IF current > 10 THEN + ERROR "too many requests per second" +ELSE + PERFORM_API_CALL() +END +``` + +Basically we have a counter for every IP, for every different second. +But this counters are always incremented setting an expire of 10 seconds so that +they'll be removed by Redis automatically when the current second is a different +one. + +Note the used of `MULTI` and `EXEC` in order to make sure that we'll both +increment and set the expire at every API call. + +## Pattern: Rate limiter 2 + +An alternative implementation uses a single counter, but is a bit more complex +to get it right without race conditions. +We'll examine different variants. + +``` +FUNCTION LIMIT_API_CALL(ip): +current = GET(ip) +IF current != NULL AND current > 10 THEN + ERROR "too many requests per second" +ELSE + value = INCR(ip) + IF value == 1 THEN + EXPIRE(ip,1) + END + PERFORM_API_CALL() +END +``` + +The counter is created in a way that it only will survive one second, starting +from the first request performed in the current second. +If there are more than 10 requests in the same second the counter will reach a +value greater than 10, otherwise it will expire and start again from 0. + +**In the above code there is a race condition**. +If for some reason the client performs the `INCR` command but does not perform +the `EXPIRE` the key will be leaked until we'll see the same IP address again. + +This can be fixed easily turning the `INCR` with optional `EXPIRE` into a Lua +script that is send using the `EVAL` command (only available since Redis version +2.6). + +``` +local current +current = redis.call("incr",KEYS[1]) +if current == 1 then + redis.call("expire",KEYS[1],1) +end +``` + +There is a different way to fix this issue without using scripting, by using +Redis lists instead of counters. +The implementation is more complex and uses more advanced features but has the +advantage of remembering the IP addresses of the clients currently performing an +API call, that may be useful or not depending on the application. + +``` +FUNCTION LIMIT_API_CALL(ip) +current = LLEN(ip) +IF current > 10 THEN + ERROR "too many requests per second" +ELSE + IF EXISTS(ip) == FALSE + MULTI + RPUSH(ip,ip) + EXPIRE(ip,1) + EXEC + ELSE + RPUSHX(ip,ip) + END + PERFORM_API_CALL() +END +``` + +The `RPUSHX` command only pushes the element if the key already exists. + +Note that we have a race here, but it is not a problem: `EXISTS` may return +false but the key may be created by another client before we create it inside +the `MULTI` / `EXEC` block. +However this race will just miss an API call under rare conditions, so the rate +limiting will still work correctly. diff --git a/iredis/data/commands/incrby.md b/iredis/data/commands/incrby.md new file mode 100644 index 0000000..9734351 --- /dev/null +++ b/iredis/data/commands/incrby.md @@ -0,0 +1,18 @@ +Increments the number stored at `key` by `increment`. +If the key does not exist, it is set to `0` before performing the operation. +An error is returned if the key contains a value of the wrong type or contains a +string that can not be represented as integer. +This operation is limited to 64 bit signed integers. + +See `INCR` for extra information on increment/decrement operations. + +@return + +@integer-reply: the value of `key` after the increment + +@examples + +```cli +SET mykey "10" +INCRBY mykey 5 +``` diff --git a/iredis/data/commands/incrbyfloat.md b/iredis/data/commands/incrbyfloat.md new file mode 100644 index 0000000..9efca1d --- /dev/null +++ b/iredis/data/commands/incrbyfloat.md @@ -0,0 +1,44 @@ +Increment the string representing a floating point number stored at `key` by the +specified `increment`. By using a negative `increment` value, the result is +that the value stored at the key is decremented (by the obvious properties +of addition). +If the key does not exist, it is set to `0` before performing the operation. +An error is returned if one of the following conditions occur: + +* The key contains a value of the wrong type (not a string). +* The current key content or the specified increment are not parsable as a + double precision floating point number. + +If the command is successful the new incremented value is stored as the new +value of the key (replacing the old one), and returned to the caller as a +string. + +Both the value already contained in the string key and the increment argument +can be optionally provided in exponential notation, however the value computed +after the increment is stored consistently in the same format, that is, an +integer number followed (if needed) by a dot, and a variable number of digits +representing the decimal part of the number. +Trailing zeroes are always removed. + +The precision of the output is fixed at 17 digits after the decimal point +regardless of the actual internal precision of the computation. + +@return + +@bulk-string-reply: the value of `key` after the increment. + +@examples + +```cli +SET mykey 10.50 +INCRBYFLOAT mykey 0.1 +INCRBYFLOAT mykey -5 +SET mykey 5.0e3 +INCRBYFLOAT mykey 2.0e2 +``` + +## Implementation details + +The command is always propagated in the replication link and the Append Only +File as a `SET` operation, so that differences in the underlying floating point +math implementation will not be sources of inconsistency. diff --git a/iredis/data/commands/info.md b/iredis/data/commands/info.md new file mode 100644 index 0000000..be9b318 --- /dev/null +++ b/iredis/data/commands/info.md @@ -0,0 +1,426 @@ +The `INFO` command returns information and statistics about the server in a +format that is simple to parse by computers and easy to read by humans. + +The optional parameter can be used to select a specific section of information: + +* `server`: General information about the Redis server +* `clients`: Client connections section +* `memory`: Memory consumption related information +* `persistence`: RDB and AOF related information +* `stats`: General statistics +* `replication`: Master/replica replication information +* `cpu`: CPU consumption statistics +* `commandstats`: Redis command statistics +* `latencystats`: Redis command latency percentile distribution statistics +* `cluster`: Redis Cluster section +* `modules`: Modules section +* `keyspace`: Database related statistics +* `modules`: Module related sections +* `errorstats`: Redis error statistics + +It can also take the following values: + +* `all`: Return all sections (excluding module generated ones) +* `default`: Return only the default set of sections +* `everything`: Includes `all` and `modules` + +When no parameter is provided, the `default` option is assumed. + +@return + +@bulk-string-reply: as a collection of text lines. + +Lines can contain a section name (starting with a # character) or a property. +All the properties are in the form of `field:value` terminated by `\r\n`. + +```cli +INFO +``` + +## Notes + +Please note depending on the version of Redis some of the fields have been +added or removed. A robust client application should therefore parse the +result of this command by skipping unknown properties, and gracefully handle +missing fields. + +Here is the description of fields for Redis >= 2.4. + + +Here is the meaning of all fields in the **server** section: + +* `redis_version`: Version of the Redis server +* `redis_git_sha1`: Git SHA1 +* `redis_git_dirty`: Git dirty flag +* `redis_build_id`: The build id +* `redis_mode`: The server's mode ("standalone", "sentinel" or "cluster") +* `os`: Operating system hosting the Redis server +* `arch_bits`: Architecture (32 or 64 bits) +* `multiplexing_api`: Event loop mechanism used by Redis +* `atomicvar_api`: Atomicvar API used by Redis +* `gcc_version`: Version of the GCC compiler used to compile the Redis server +* `process_id`: PID of the server process +* `process_supervised`: Supervised system ("upstart", "systemd", "unknown" or "no") +* `run_id`: Random value identifying the Redis server (to be used by Sentinel + and Cluster) +* `tcp_port`: TCP/IP listen port +* `server_time_usec`: Epoch-based system time with microsecond precision +* `uptime_in_seconds`: Number of seconds since Redis server start +* `uptime_in_days`: Same value expressed in days +* `hz`: The server's current frequency setting +* `configured_hz`: The server's configured frequency setting +* `lru_clock`: Clock incrementing every minute, for LRU management +* `executable`: The path to the server's executable +* `config_file`: The path to the config file +* `io_threads_active`: Flag indicating if I/O threads are active +* `shutdown_in_milliseconds`: The maximum time remaining for replicas to catch up the replication before completing the shutdown sequence. + This field is only present during shutdown. + +Here is the meaning of all fields in the **clients** section: + +* `connected_clients`: Number of client connections (excluding connections + from replicas) +* `cluster_connections`: An approximation of the number of sockets used by the + cluster's bus +* `maxclients`: The value of the `maxclients` configuration directive. This is + the upper limit for the sum of `connected_clients`, `connected_slaves` and + `cluster_connections`. +* `client_recent_max_input_buffer`: Biggest input buffer among current client connections +* `client_recent_max_output_buffer`: Biggest output buffer among current client connections +* `blocked_clients`: Number of clients pending on a blocking call (`BLPOP`, + `BRPOP`, `BRPOPLPUSH`, `BLMOVE`, `BZPOPMIN`, `BZPOPMAX`) +* `tracking_clients`: Number of clients being tracked (`CLIENT TRACKING`) +* `clients_in_timeout_table`: Number of clients in the clients timeout table + +Here is the meaning of all fields in the **memory** section: + +* `used_memory`: Total number of bytes allocated by Redis using its + allocator (either standard **libc**, **jemalloc**, or an alternative + allocator such as [**tcmalloc**][hcgcpgp]) +* `used_memory_human`: Human readable representation of previous value +* `used_memory_rss`: Number of bytes that Redis allocated as seen by the + operating system (a.k.a resident set size). This is the number reported by + tools such as `top(1)` and `ps(1)` +* `used_memory_rss_human`: Human readable representation of previous value +* `used_memory_peak`: Peak memory consumed by Redis (in bytes) +* `used_memory_peak_human`: Human readable representation of previous value +* `used_memory_peak_perc`: The percentage of `used_memory_peak` out of + `used_memory` +* `used_memory_overhead`: The sum in bytes of all overheads that the server + allocated for managing its internal data structures +* `used_memory_startup`: Initial amount of memory consumed by Redis at startup + in bytes +* `used_memory_dataset`: The size in bytes of the dataset + (`used_memory_overhead` subtracted from `used_memory`) +* `used_memory_dataset_perc`: The percentage of `used_memory_dataset` out of + the net memory usage (`used_memory` minus `used_memory_startup`) +* `total_system_memory`: The total amount of memory that the Redis host has +* `total_system_memory_human`: Human readable representation of previous value +* `used_memory_lua`: Number of bytes used by the Lua engine +* `used_memory_lua_human`: Human readable representation of previous value +* `used_memory_scripts`: Number of bytes used by cached Lua scripts +* `used_memory_scripts_human`: Human readable representation of previous value +* `maxmemory`: The value of the `maxmemory` configuration directive +* `maxmemory_human`: Human readable representation of previous value +* `maxmemory_policy`: The value of the `maxmemory-policy` configuration + directive +* `mem_fragmentation_ratio`: Ratio between `used_memory_rss` and `used_memory`. + Note that this doesn't only includes fragmentation, but also other process overheads (see the `allocator_*` metrics), and also overheads like code, shared libraries, stack, etc. +* `mem_fragmentation_bytes`: Delta between `used_memory_rss` and `used_memory`. + Note that when the total fragmentation bytes is low (few megabytes), a high ratio (e.g. 1.5 and above) is not an indication of an issue. +* `allocator_frag_ratio:`: Ratio between `allocator_active` and `allocator_allocated`. This is the true (external) fragmentation metric (not `mem_fragmentation_ratio`). +* `allocator_frag_bytes` Delta between `allocator_active` and `allocator_allocated`. See note about `mem_fragmentation_bytes`. +* `allocator_rss_ratio`: Ratio between `allocator_resident` and `allocator_active`. This usually indicates pages that the allocator can and probably will soon release back to the OS. +* `allocator_rss_bytes`: Delta between `allocator_resident` and `allocator_active` +* `rss_overhead_ratio`: Ratio between `used_memory_rss` (the process RSS) and `allocator_resident`. This includes RSS overheads that are not allocator or heap related. +* `rss_overhead_bytes`: Delta between `used_memory_rss` (the process RSS) and `allocator_resident` +* `allocator_allocated`: Total bytes allocated form the allocator, including internal-fragmentation. Normally the same as `used_memory`. +* `allocator_active`: Total bytes in the allocator active pages, this includes external-fragmentation. +* `allocator_resident`: Total bytes resident (RSS) in the allocator, this includes pages that can be released to the OS (by `MEMORY PURGE`, or just waiting). +* `mem_not_counted_for_evict`: Used memory that's not counted for key eviction. This is basically transient replica and AOF buffers. +* `mem_clients_slaves`: Memory used by replica clients - Starting Redis 7.0, replica buffers share memory with the replication backlog, so this field can show 0 when replicas don't trigger an increase of memory usage. +* `mem_clients_normal`: Memory used by normal clients +* `mem_cluster_links`: Memory used by links to peers on the cluster bus when cluster mode is enabled. +* `mem_aof_buffer`: Transient memory used for AOF and AOF rewrite buffers +* `mem_replication_backlog`: Memory used by replication backlog +* `mem_total_replication_buffers`: Total memory consumed for replication buffers - Added in Redis 7.0. +* `mem_allocator`: Memory allocator, chosen at compile time. +* `active_defrag_running`: When `activedefrag` is enabled, this indicates whether defragmentation is currently active, and the CPU percentage it intends to utilize. +* `lazyfree_pending_objects`: The number of objects waiting to be freed (as a + result of calling `UNLINK`, or `FLUSHDB` and `FLUSHALL` with the **ASYNC** + option) +* `lazyfreed_objects`: The number of objects that have been lazy freed. + +Ideally, the `used_memory_rss` value should be only slightly higher than +`used_memory`. +When rss >> used, a large difference may mean there is (external) memory fragmentation, which can be evaluated by checking +`allocator_frag_ratio`, `allocator_frag_bytes`. +When used >> rss, it means part of Redis memory has been swapped off by the +operating system: expect some significant latencies. + +Because Redis does not have control over how its allocations are mapped to +memory pages, high `used_memory_rss` is often the result of a spike in memory +usage. + +When Redis frees memory, the memory is given back to the allocator, and the +allocator may or may not give the memory back to the system. There may be +a discrepancy between the `used_memory` value and memory consumption as +reported by the operating system. It may be due to the fact memory has been +used and released by Redis, but not given back to the system. The +`used_memory_peak` value is generally useful to check this point. + +Additional introspective information about the server's memory can be obtained +by referring to the `MEMORY STATS` command and the `MEMORY DOCTOR`. + +Here is the meaning of all fields in the **persistence** section: + +* `loading`: Flag indicating if the load of a dump file is on-going +* `async_loading`: Currently loading replication data-set asynchronously while serving old data. This means `repl-diskless-load` is enabled and set to `swapdb`. Added in Redis 7.0. +* `current_cow_peak`: The peak size in bytes of copy-on-write memory + while a child fork is running +* `current_cow_size`: The size in bytes of copy-on-write memory + while a child fork is running +* `current_cow_size_age`: The age, in seconds, of the `current_cow_size` value. +* `current_fork_perc`: The percentage of progress of the current fork process. For AOF and RDB forks it is the percentage of `current_save_keys_processed` out of `current_save_keys_total`. +* `current_save_keys_processed`: Number of keys processed by the current save operation +* `current_save_keys_total`: Number of keys at the beginning of the current save operation +* `rdb_changes_since_last_save`: Number of changes since the last dump +* `rdb_bgsave_in_progress`: Flag indicating a RDB save is on-going +* `rdb_last_save_time`: Epoch-based timestamp of last successful RDB save +* `rdb_last_bgsave_status`: Status of the last RDB save operation +* `rdb_last_bgsave_time_sec`: Duration of the last RDB save operation in + seconds +* `rdb_current_bgsave_time_sec`: Duration of the on-going RDB save operation + if any +* `rdb_last_cow_size`: The size in bytes of copy-on-write memory during + the last RDB save operation +* `rdb_last_load_keys_expired`: Number volatile keys deleted during the last RDB loading. Added in Redis 7.0. +* `rdb_last_load_keys_loaded`: Number of keys loaded during the last RDB loading. Added in Redis 7.0. +* `aof_enabled`: Flag indicating AOF logging is activated +* `aof_rewrite_in_progress`: Flag indicating a AOF rewrite operation is + on-going +* `aof_rewrite_scheduled`: Flag indicating an AOF rewrite operation + will be scheduled once the on-going RDB save is complete. +* `aof_last_rewrite_time_sec`: Duration of the last AOF rewrite operation in + seconds +* `aof_current_rewrite_time_sec`: Duration of the on-going AOF rewrite + operation if any +* `aof_last_bgrewrite_status`: Status of the last AOF rewrite operation +* `aof_last_write_status`: Status of the last write operation to the AOF +* `aof_last_cow_size`: The size in bytes of copy-on-write memory during + the last AOF rewrite operation +* `module_fork_in_progress`: Flag indicating a module fork is on-going +* `module_fork_last_cow_size`: The size in bytes of copy-on-write memory + during the last module fork operation +* `aof_rewrites`: Number of AOF rewrites performed since startup +* `rdb_saves`: Number of RDB snapshots performed since startup + +`rdb_changes_since_last_save` refers to the number of operations that produced +some kind of changes in the dataset since the last time either `SAVE` or +`BGSAVE` was called. + +If AOF is activated, these additional fields will be added: + +* `aof_current_size`: AOF current file size +* `aof_base_size`: AOF file size on latest startup or rewrite +* `aof_pending_rewrite`: Flag indicating an AOF rewrite operation + will be scheduled once the on-going RDB save is complete. +* `aof_buffer_length`: Size of the AOF buffer +* `aof_rewrite_buffer_length`: Size of the AOF rewrite buffer. Note this field was removed in Redis 7.0 +* `aof_pending_bio_fsync`: Number of fsync pending jobs in background I/O + queue +* `aof_delayed_fsync`: Delayed fsync counter + +If a load operation is on-going, these additional fields will be added: + +* `loading_start_time`: Epoch-based timestamp of the start of the load + operation +* `loading_total_bytes`: Total file size +* `loading_rdb_used_mem`: The memory usage of the server that had generated + the RDB file at the time of the file's creation +* `loading_loaded_bytes`: Number of bytes already loaded +* `loading_loaded_perc`: Same value expressed as a percentage +* `loading_eta_seconds`: ETA in seconds for the load to be complete + +Here is the meaning of all fields in the **stats** section: + +* `total_connections_received`: Total number of connections accepted by the + server +* `total_commands_processed`: Total number of commands processed by the server +* `instantaneous_ops_per_sec`: Number of commands processed per second +* `total_net_input_bytes`: The total number of bytes read from the network +* `total_net_output_bytes`: The total number of bytes written to the network +* `total_net_repl_input_bytes`: The total number of bytes read from the network for replication purposes +* `total_net_repl_output_bytes`: The total number of bytes written to the network for replication purposes +* `instantaneous_input_kbps`: The network's read rate per second in KB/sec +* `instantaneous_output_kbps`: The network's write rate per second in KB/sec +* `instantaneous_input_repl_kbps`: The network's read rate per second in KB/sec for replication purposes +* `instantaneous_output_repl_kbps`: The network's write rate per second in KB/sec for replication purposes +* `rejected_connections`: Number of connections rejected because of + `maxclients` limit +* `sync_full`: The number of full resyncs with replicas +* `sync_partial_ok`: The number of accepted partial resync requests +* `sync_partial_err`: The number of denied partial resync requests +* `expired_keys`: Total number of key expiration events +* `expired_stale_perc`: The percentage of keys probably expired +* `expired_time_cap_reached_count`: The count of times that active expiry cycles have stopped early +* `expire_cycle_cpu_milliseconds`: The cumulative amount of time spend on active expiry cycles +* `evicted_keys`: Number of evicted keys due to `maxmemory` limit +* `evicted_clients`: Number of evicted clients due to `maxmemory-clients` limit. Added in Redis 7.0. +* `total_eviction_exceeded_time`: Total time `used_memory` was greater than `maxmemory` since server startup, in milliseconds +* `current_eviction_exceeded_time`: The time passed since `used_memory` last rose above `maxmemory`, in milliseconds +* `keyspace_hits`: Number of successful lookup of keys in the main dictionary +* `keyspace_misses`: Number of failed lookup of keys in the main dictionary +* `pubsub_channels`: Global number of pub/sub channels with client + subscriptions +* `pubsub_patterns`: Global number of pub/sub pattern with client + subscriptions +* `pubsubshard_channels`: Global number of pub/sub shard channels with client subscriptions. Added in Redis 7.0.3 +* `latest_fork_usec`: Duration of the latest fork operation in microseconds +* `total_forks`: Total number of fork operations since the server start +* `migrate_cached_sockets`: The number of sockets open for `MIGRATE` purposes +* `slave_expires_tracked_keys`: The number of keys tracked for expiry purposes + (applicable only to writable replicas) +* `active_defrag_hits`: Number of value reallocations performed by active the + defragmentation process +* `active_defrag_misses`: Number of aborted value reallocations started by the + active defragmentation process +* `active_defrag_key_hits`: Number of keys that were actively defragmented +* `active_defrag_key_misses`: Number of keys that were skipped by the active + defragmentation process +* `total_active_defrag_time`: Total time memory fragmentation was over the limit, in milliseconds +* `current_active_defrag_time`: The time passed since memory fragmentation last was over the limit, in milliseconds +* `tracking_total_keys`: Number of keys being tracked by the server +* `tracking_total_items`: Number of items, that is the sum of clients number for + each key, that are being tracked +* `tracking_total_prefixes`: Number of tracked prefixes in server's prefix table + (only applicable for broadcast mode) +* `unexpected_error_replies`: Number of unexpected error replies, that are types + of errors from an AOF load or replication +* `total_error_replies`: Total number of issued error replies, that is the sum of + rejected commands (errors prior command execution) and + failed commands (errors within the command execution) +* `dump_payload_sanitizations`: Total number of dump payload deep integrity validations (see `sanitize-dump-payload` config). +* `total_reads_processed`: Total number of read events processed +* `total_writes_processed`: Total number of write events processed +* `io_threaded_reads_processed`: Number of read events processed by the main and I/O threads +* `io_threaded_writes_processed`: Number of write events processed by the main and I/O threads + +Here is the meaning of all fields in the **replication** section: + +* `role`: Value is "master" if the instance is replica of no one, or "slave" if the instance is a replica of some master instance. + Note that a replica can be master of another replica (chained replication). +* `master_failover_state`: The state of an ongoing failover, if any. +* `master_replid`: The replication ID of the Redis server. +* `master_replid2`: The secondary replication ID, used for PSYNC after a failover. +* `master_repl_offset`: The server's current replication offset +* `second_repl_offset`: The offset up to which replication IDs are accepted +* `repl_backlog_active`: Flag indicating replication backlog is active +* `repl_backlog_size`: Total size in bytes of the replication backlog buffer +* `repl_backlog_first_byte_offset`: The master offset of the replication + backlog buffer +* `repl_backlog_histlen`: Size in bytes of the data in the replication backlog + buffer + +If the instance is a replica, these additional fields are provided: + +* `master_host`: Host or IP address of the master +* `master_port`: Master listening TCP port +* `master_link_status`: Status of the link (up/down) +* `master_last_io_seconds_ago`: Number of seconds since the last interaction + with master +* `master_sync_in_progress`: Indicate the master is syncing to the replica +* `slave_read_repl_offset`: The read replication offset of the replica instance. +* `slave_repl_offset`: The replication offset of the replica instance +* `slave_priority`: The priority of the instance as a candidate for failover +* `slave_read_only`: Flag indicating if the replica is read-only +* `replica_announced`: Flag indicating if the replica is announced by Sentinel. + +If a SYNC operation is on-going, these additional fields are provided: + +* `master_sync_total_bytes`: Total number of bytes that need to be + transferred. this may be 0 when the size is unknown (for example, when + the `repl-diskless-sync` configuration directive is used) +* `master_sync_read_bytes`: Number of bytes already transferred +* `master_sync_left_bytes`: Number of bytes left before syncing is complete + (may be negative when `master_sync_total_bytes` is 0) +* `master_sync_perc`: The percentage `master_sync_read_bytes` from + `master_sync_total_bytes`, or an approximation that uses + `loading_rdb_used_mem` when `master_sync_total_bytes` is 0 +* `master_sync_last_io_seconds_ago`: Number of seconds since last transfer I/O + during a SYNC operation + +If the link between master and replica is down, an additional field is provided: + +* `master_link_down_since_seconds`: Number of seconds since the link is down + +The following field is always provided: + +* `connected_slaves`: Number of connected replicas + +If the server is configured with the `min-slaves-to-write` (or starting with Redis 5 with the `min-replicas-to-write`) directive, an additional field is provided: + +* `min_slaves_good_slaves`: Number of replicas currently considered good + +For each replica, the following line is added: + +* `slaveXXX`: id, IP address, port, state, offset, lag + +Here is the meaning of all fields in the **cpu** section: + +* `used_cpu_sys`: System CPU consumed by the Redis server, which is the sum of system CPU consumed by all threads of the server process (main thread and background threads) +* `used_cpu_user`: User CPU consumed by the Redis server, which is the sum of user CPU consumed by all threads of the server process (main thread and background threads) +* `used_cpu_sys_children`: System CPU consumed by the background processes +* `used_cpu_user_children`: User CPU consumed by the background processes +* `used_cpu_sys_main_thread`: System CPU consumed by the Redis server main thread +* `used_cpu_user_main_thread`: User CPU consumed by the Redis server main thread + +The **commandstats** section provides statistics based on the command type, + including the number of calls that reached command execution (not rejected), + the total CPU time consumed by these commands, the average CPU consumed + per command execution, the number of rejected calls + (errors prior command execution), and the number of failed calls + (errors within the command execution). + +For each command type, the following line is added: + +* `cmdstat_XXX`: `calls=XXX,usec=XXX,usec_per_call=XXX,rejected_calls=XXX,failed_calls=XXX` + +The **latencystats** section provides latency percentile distribution statistics based on the command type. + + By default, the exported latency percentiles are the p50, p99, and p999. + If you need to change the exported percentiles, use `CONFIG SET latency-tracking-info-percentiles "50.0 99.0 99.9"`. + + This section requires the extended latency monitoring feature to be enabled (by default it's enabled). + If you need to enable it, use `CONFIG SET latency-tracking yes`. + +For each command type, the following line is added: + +* `latency_percentiles_usec_XXX: p<percentile 1>=<percentile 1 value>,p<percentile 2>=<percentile 2 value>,...` + +The **errorstats** section enables keeping track of the different errors that occurred within Redis, + based upon the reply error prefix ( The first word after the "-", up to the first space. Example: `ERR` ). + +For each error type, the following line is added: + +* `errorstat_XXX`: `count=XXX` + +The **cluster** section currently only contains a unique field: + +* `cluster_enabled`: Indicate Redis cluster is enabled + +The **modules** section contains additional information about loaded modules if the modules provide it. The field part of properties lines in this section is always prefixed with the module's name. + +The **keyspace** section provides statistics on the main dictionary of each +database. +The statistics are the number of keys, and the number of keys with an expiration. + +For each database, the following line is added: + +* `dbXXX`: `keys=XXX,expires=XXX` + +[hcgcpgp]: http://code.google.com/p/google-perftools/ + +**A note about the word slave used in this man page**: Starting with Redis 5, if not for backward compatibility, the Redis project no longer uses the word slave. Unfortunately in this command the word slave is part of the protocol, so we'll be able to remove such occurrences only when this API will be naturally deprecated. + +**Modules generated sections**: Starting with Redis 6, modules can inject their info into the `INFO` command, these are excluded by default even when the `all` argument is provided (it will include a list of loaded modules but not their generated info fields). To get these you must use either the `modules` argument or `everything`., diff --git a/iredis/data/commands/keys.md b/iredis/data/commands/keys.md new file mode 100644 index 0000000..186caca --- /dev/null +++ b/iredis/data/commands/keys.md @@ -0,0 +1,40 @@ +Returns all keys matching `pattern`. + +While the time complexity for this operation is O(N), the constant times are +fairly low. +For example, Redis running on an entry level laptop can scan a 1 million key +database in 40 milliseconds. + +**Warning**: consider `KEYS` as a command that should only be used in production +environments with extreme care. +It may ruin performance when it is executed against large databases. +This command is intended for debugging and special operations, such as changing +your keyspace layout. +Don't use `KEYS` in your regular application code. +If you're looking for a way to find keys in a subset of your keyspace, consider +using `SCAN` or [sets][tdts]. + +[tdts]: /topics/data-types#sets + +Supported glob-style patterns: + +* `h?llo` matches `hello`, `hallo` and `hxllo` +* `h*llo` matches `hllo` and `heeeello` +* `h[ae]llo` matches `hello` and `hallo,` but not `hillo` +* `h[^e]llo` matches `hallo`, `hbllo`, ... but not `hello` +* `h[a-b]llo` matches `hallo` and `hbllo` + +Use `\` to escape special characters if you want to match them verbatim. + +@return + +@array-reply: list of keys matching `pattern`. + +@examples + +```cli +MSET firstname Jack lastname Stuntman age 35 +KEYS *name* +KEYS a?? +KEYS * +``` diff --git a/iredis/data/commands/lastsave.md b/iredis/data/commands/lastsave.md new file mode 100644 index 0000000..cfec625 --- /dev/null +++ b/iredis/data/commands/lastsave.md @@ -0,0 +1,8 @@ +Return the UNIX TIME of the last DB save executed with success. +A client may check if a `BGSAVE` command succeeded reading the `LASTSAVE` value, +then issuing a `BGSAVE` command and checking at regular intervals every N +seconds if `LASTSAVE` changed. + +@return + +@integer-reply: an UNIX time stamp. diff --git a/iredis/data/commands/latency-doctor.md b/iredis/data/commands/latency-doctor.md new file mode 100644 index 0000000..8f493aa --- /dev/null +++ b/iredis/data/commands/latency-doctor.md @@ -0,0 +1,45 @@ +The `LATENCY DOCTOR` command reports about different latency-related issues and advises about possible remedies. + +This command is the most powerful analysis tool in the latency monitoring +framework, and is able to provide additional statistical data like the average +period between latency spikes, the median deviation, and a human-readable +analysis of the event. For certain events, like `fork`, additional information +is provided, like the rate at which the system forks processes. + +This is the output you should post in the Redis mailing list if you are +looking for help about Latency related issues. + +@examples + +``` +127.0.0.1:6379> latency doctor + +Dave, I have observed latency spikes in this Redis instance. +You don't mind talking about it, do you Dave? + +1. command: 5 latency spikes (average 300ms, mean deviation 120ms, + period 73.40 sec). Worst all time event 500ms. + +I have a few advices for you: + +- Your current Slow Log configuration only logs events that are + slower than your configured latency monitor threshold. Please + use 'CONFIG SET slowlog-log-slower-than 1000'. +- Check your Slow Log to understand what are the commands you are + running which are too slow to execute. Please check + http://redis.io/commands/slowlog for more information. +- Deleting, expiring or evicting (because of maxmemory policy) + large objects is a blocking operation. If you have very large + objects that are often deleted, expired, or evicted, try to + fragment those objects into multiple smaller objects. +``` + +**Note:** the doctor has erratic psychological behaviors, so we recommend interacting with it carefully. + +For more information refer to the [Latency Monitoring Framework page][lm]. + +[lm]: /topics/latency-monitor + +@return + +@bulk-string-reply diff --git a/iredis/data/commands/latency-graph.md b/iredis/data/commands/latency-graph.md new file mode 100644 index 0000000..f1cfa5e --- /dev/null +++ b/iredis/data/commands/latency-graph.md @@ -0,0 +1,64 @@ +Produces an ASCII-art style graph for the specified event. + +`LATENCY GRAPH` lets you intuitively understand the latency trend of an `event` via state-of-the-art visualization. It can be used for quickly grasping the situation before resorting to means such parsing the raw data from `LATENCY HISTORY` or external tooling. + +Valid values for `event` are: +* `active-defrag-cycle` +* `aof-fsync-always` +* `aof-stat` +* `aof-rewrite-diff-write` +* `aof-rename` +* `aof-write` +* `aof-write-active-child` +* `aof-write-alone` +* `aof-write-pending-fsync` +* `command` +* `expire-cycle` +* `eviction-cycle` +* `eviction-del` +* `fast-command` +* `fork` +* `rdb-unlink-temp-file` + +@examples + +``` +127.0.0.1:6379> latency reset command +(integer) 0 +127.0.0.1:6379> debug sleep .1 +OK +127.0.0.1:6379> debug sleep .2 +OK +127.0.0.1:6379> debug sleep .3 +OK +127.0.0.1:6379> debug sleep .5 +OK +127.0.0.1:6379> debug sleep .4 +OK +127.0.0.1:6379> latency graph command +command - high 500 ms, low 101 ms (all time high 500 ms) +-------------------------------------------------------------------------------- + #_ + _|| + _||| +_|||| + +11186 +542ss +sss +``` + +The vertical labels under each graph column represent the amount of seconds, +minutes, hours or days ago the event happened. For example "15s" means that the +first graphed event happened 15 seconds ago. + +The graph is normalized in the min-max scale so that the zero (the underscore +in the lower row) is the minimum, and a # in the higher row is the maximum. + +For more information refer to the [Latency Monitoring Framework page][lm]. + +[lm]: /topics/latency-monitor + +@return + +@bulk-string-reply
\ No newline at end of file diff --git a/iredis/data/commands/latency-help.md b/iredis/data/commands/latency-help.md new file mode 100644 index 0000000..8077bf0 --- /dev/null +++ b/iredis/data/commands/latency-help.md @@ -0,0 +1,10 @@ +The `LATENCY HELP` command returns a helpful text describing the different +subcommands. + +For more information refer to the [Latency Monitoring Framework page][lm]. + +[lm]: /topics/latency-monitor + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/latency-histogram.md b/iredis/data/commands/latency-histogram.md new file mode 100644 index 0000000..a97928b --- /dev/null +++ b/iredis/data/commands/latency-histogram.md @@ -0,0 +1,38 @@ +The `LATENCY HISTOGRAM` command reports a cumulative distribution of latencies in the format of a histogram for each of the specified command names. +If no command names are specified then all commands that contain latency information will be replied. + +Each reported histogram has the following fields: + +* Command name. +* The total calls for that command. +* A map of time buckets: + * Each bucket represents a latency range. + * Each bucket covers twice the previous bucket's range. + * Empty buckets are not printed. + * The tracked latencies are between 1 microsecond and roughly 1 second. + * Everything above 1 sec is considered +Inf. + * At max there will be log2(1000000000)=30 buckets. + +This command requires the extended latency monitoring feature to be enabled (by default it's enabled). +If you need to enable it, use `CONFIG SET latency-tracking yes`. + +@examples + +``` +127.0.0.1:6379> LATENCY HISTOGRAM set +1# "set" => + 1# "calls" => (integer) 100000 + 2# "histogram_usec" => + 1# (integer) 1 => (integer) 99583 + 2# (integer) 2 => (integer) 99852 + 3# (integer) 4 => (integer) 99914 + 4# (integer) 8 => (integer) 99940 + 5# (integer) 16 => (integer) 99968 + 6# (integer) 33 => (integer) 100000 +``` + +@return + +@array-reply: specifically: + +The command returns a map where each key is a command name, and each value is a map with the total calls, and an inner map of the histogram time buckets. diff --git a/iredis/data/commands/latency-history.md b/iredis/data/commands/latency-history.md new file mode 100644 index 0000000..815e644 --- /dev/null +++ b/iredis/data/commands/latency-history.md @@ -0,0 +1,44 @@ +The `LATENCY HISTORY` command returns the raw data of the `event`'s latency spikes time series. + +This is useful to an application that wants to fetch raw data in order to perform monitoring, display graphs, and so forth. + +The command will return up to 160 timestamp-latency pairs for the `event`. + +Valid values for `event` are: +* `active-defrag-cycle` +* `aof-fsync-always` +* `aof-stat` +* `aof-rewrite-diff-write` +* `aof-rename` +* `aof-write` +* `aof-write-active-child` +* `aof-write-alone` +* `aof-write-pending-fsync` +* `command` +* `expire-cycle` +* `eviction-cycle` +* `eviction-del` +* `fast-command` +* `fork` +* `rdb-unlink-temp-file` + +@examples + +``` +127.0.0.1:6379> latency history command +1) 1) (integer) 1405067822 + 2) (integer) 251 +2) 1) (integer) 1405067941 + 2) (integer) 1001 +``` + +For more information refer to the [Latency Monitoring Framework page][lm]. + +[lm]: /topics/latency-monitor + +@return + +@array-reply: specifically: + +The command returns an array where each element is a two elements array +representing the timestamp and the latency of the event.
\ No newline at end of file diff --git a/iredis/data/commands/latency-latest.md b/iredis/data/commands/latency-latest.md new file mode 100644 index 0000000..918435b --- /dev/null +++ b/iredis/data/commands/latency-latest.md @@ -0,0 +1,37 @@ +The `LATENCY LATEST` command reports the latest latency events logged. + +Each reported event has the following fields: + +* Event name. +* Unix timestamp of the latest latency spike for the event. +* Latest event latency in millisecond. +* All-time maximum latency for this event. + +"All-time" means the maximum latency since the Redis instance was +started, or the time that events were reset `LATENCY RESET`. + +@examples + +``` +127.0.0.1:6379> debug sleep 1 +OK +(1.00s) +127.0.0.1:6379> debug sleep .25 +OK +127.0.0.1:6379> latency latest +1) 1) "command" + 2) (integer) 1405067976 + 3) (integer) 251 + 4) (integer) 1001 +``` + +For more information refer to the [Latency Monitoring Framework page][lm]. + +[lm]: /topics/latency-monitor + +@return + +@array-reply: specifically: + +The command returns an array where each element is a four elements array +representing the event's name, timestamp, latest and all-time latency measurements. diff --git a/iredis/data/commands/latency-reset.md b/iredis/data/commands/latency-reset.md new file mode 100644 index 0000000..9762869 --- /dev/null +++ b/iredis/data/commands/latency-reset.md @@ -0,0 +1,34 @@ +The `LATENCY RESET` command resets the latency spikes time series of all, or only some, events. + +When the command is called without arguments, it resets all the +events, discarding the currently logged latency spike events, and resetting +the maximum event time register. + +It is possible to reset only specific events by providing the `event` names +as arguments. + +Valid values for `event` are: +* `active-defrag-cycle` +* `aof-fsync-always` +* `aof-stat` +* `aof-rewrite-diff-write` +* `aof-rename` +* `aof-write` +* `aof-write-active-child` +* `aof-write-alone` +* `aof-write-pending-fsync` +* `command` +* `expire-cycle` +* `eviction-cycle` +* `eviction-del` +* `fast-command` +* `fork` +* `rdb-unlink-temp-file` + +For more information refer to the [Latency Monitoring Framework page][lm]. + +[lm]: /topics/latency-monitor + +@return + +@integer-reply: the number of event time series that were reset. diff --git a/iredis/data/commands/latency.md b/iredis/data/commands/latency.md new file mode 100644 index 0000000..fd5c95d --- /dev/null +++ b/iredis/data/commands/latency.md @@ -0,0 +1,3 @@ +This is a container command for latency diagnostics commands. + +To see the list of available commands you can call `LATENCY HELP`.
\ No newline at end of file diff --git a/iredis/data/commands/lcs.md b/iredis/data/commands/lcs.md new file mode 100644 index 0000000..b554686 --- /dev/null +++ b/iredis/data/commands/lcs.md @@ -0,0 +1,79 @@ + +The LCS command implements the longest common subsequence algorithm. Note that this is different than the longest common string algorithm, since matching characters in the string does not need to be contiguous. + +For instance the LCS between "foo" and "fao" is "fo", since scanning the two strings from left to right, the longest common set of characters is composed of the first "f" and then the "o". + +LCS is very useful in order to evaluate how similar two strings are. Strings can represent many things. For instance if two strings are DNA sequences, the LCS will provide a measure of similarity between the two DNA sequences. If the strings represent some text edited by some user, the LCS could represent how different the new text is compared to the old one, and so forth. + +Note that this algorithm runs in `O(N*M)` time, where N is the length of the first string and M is the length of the second string. So either spin a different Redis instance in order to run this algorithm, or make sure to run it against very small strings. + +``` +> MSET key1 ohmytext key2 mynewtext +OK +> LCS key1 key2 +"mytext" +``` + +Sometimes we need just the length of the match: + +``` +> LCS key1 key2 LEN +(integer) 6 +``` + +However what is often very useful, is to know the match position in each strings: + +``` +> LCS key1 key2 IDX +1) "matches" +2) 1) 1) 1) (integer) 4 + 2) (integer) 7 + 2) 1) (integer) 5 + 2) (integer) 8 + 2) 1) 1) (integer) 2 + 2) (integer) 3 + 2) 1) (integer) 0 + 2) (integer) 1 +3) "len" +4) (integer) 6 +``` + +Matches are produced from the last one to the first one, since this is how +the algorithm works, and it more efficient to emit things in the same order. +The above array means that the first match (second element of the array) +is between positions 2-3 of the first string and 0-1 of the second. +Then there is another match between 4-7 and 5-8. + +To restrict the list of matches to the ones of a given minimal length: + +``` +> LCS key1 key2 IDX MINMATCHLEN 4 +1) "matches" +2) 1) 1) 1) (integer) 4 + 2) (integer) 7 + 2) 1) (integer) 5 + 2) (integer) 8 +3) "len" +4) (integer) 6 +``` + +Finally to also have the match len: + +``` +> LCS key1 key2 IDX MINMATCHLEN 4 WITHMATCHLEN +1) "matches" +2) 1) 1) 1) (integer) 4 + 2) (integer) 7 + 2) 1) (integer) 5 + 2) (integer) 8 + 3) (integer) 4 +3) "len" +4) (integer) 6 +``` + +@return + +* Without modifiers the string representing the longest common substring is returned. +* When `LEN` is given the command returns the length of the longest common substring. +* When `IDX` is given the command returns an array with the LCS length and all the ranges in both the strings, start and end offset for each string, where there are matches. When `WITHMATCHLEN` is given each array representing a match will also have the length of the match (see examples). + diff --git a/iredis/data/commands/lindex.md b/iredis/data/commands/lindex.md new file mode 100644 index 0000000..229c63d --- /dev/null +++ b/iredis/data/commands/lindex.md @@ -0,0 +1,22 @@ +Returns the element at index `index` in the list stored at `key`. +The index is zero-based, so `0` means the first element, `1` the second element +and so on. +Negative indices can be used to designate elements starting at the tail of the +list. +Here, `-1` means the last element, `-2` means the penultimate and so forth. + +When the value at `key` is not a list, an error is returned. + +@return + +@bulk-string-reply: the requested element, or `nil` when `index` is out of range. + +@examples + +```cli +LPUSH mylist "World" +LPUSH mylist "Hello" +LINDEX mylist 0 +LINDEX mylist -1 +LINDEX mylist 3 +``` diff --git a/iredis/data/commands/linsert.md b/iredis/data/commands/linsert.md new file mode 100644 index 0000000..9fe8f61 --- /dev/null +++ b/iredis/data/commands/linsert.md @@ -0,0 +1,21 @@ +Inserts `element` in the list stored at `key` either before or after the reference +value `pivot`. + +When `key` does not exist, it is considered an empty list and no operation is +performed. + +An error is returned when `key` exists but does not hold a list value. + +@return + +@integer-reply: the length of the list after the insert operation, or `-1` when +the value `pivot` was not found. + +@examples + +```cli +RPUSH mylist "Hello" +RPUSH mylist "World" +LINSERT mylist BEFORE "World" "There" +LRANGE mylist 0 -1 +``` diff --git a/iredis/data/commands/llen.md b/iredis/data/commands/llen.md new file mode 100644 index 0000000..8c7c70f --- /dev/null +++ b/iredis/data/commands/llen.md @@ -0,0 +1,15 @@ +Returns the length of the list stored at `key`. +If `key` does not exist, it is interpreted as an empty list and `0` is returned. +An error is returned when the value stored at `key` is not a list. + +@return + +@integer-reply: the length of the list at `key`. + +@examples + +```cli +LPUSH mylist "World" +LPUSH mylist "Hello" +LLEN mylist +``` diff --git a/iredis/data/commands/lmove.md b/iredis/data/commands/lmove.md new file mode 100644 index 0000000..ec62ced --- /dev/null +++ b/iredis/data/commands/lmove.md @@ -0,0 +1,81 @@ +Atomically returns and removes the first/last element (head/tail depending on +the `wherefrom` argument) of the list stored at `source`, and pushes the +element at the first/last element (head/tail depending on the `whereto` +argument) of the list stored at `destination`. + +For example: consider `source` holding the list `a,b,c`, and `destination` +holding the list `x,y,z`. +Executing `LMOVE source destination RIGHT LEFT` results in `source` holding +`a,b` and `destination` holding `c,x,y,z`. + +If `source` does not exist, the value `nil` is returned and no operation is +performed. +If `source` and `destination` are the same, the operation is equivalent to +removing the first/last element from the list and pushing it as first/last +element of the list, so it can be considered as a list rotation command (or a +no-op if `wherefrom` is the same as `whereto`). + +This command comes in place of the now deprecated `RPOPLPUSH`. Doing +`LMOVE RIGHT LEFT` is equivalent. + +@return + +@bulk-string-reply: the element being popped and pushed. + +@examples + +```cli +RPUSH mylist "one" +RPUSH mylist "two" +RPUSH mylist "three" +LMOVE mylist myotherlist RIGHT LEFT +LMOVE mylist myotherlist LEFT RIGHT +LRANGE mylist 0 -1 +LRANGE myotherlist 0 -1 +``` + +## Pattern: Reliable queue + +Redis is often used as a messaging server to implement processing of background +jobs or other kinds of messaging tasks. +A simple form of queue is often obtained pushing values into a list in the +producer side, and waiting for this values in the consumer side using `RPOP` +(using polling), or `BRPOP` if the client is better served by a blocking +operation. + +However in this context the obtained queue is not _reliable_ as messages can +be lost, for example in the case there is a network problem or if the consumer +crashes just after the message is received but it is still to process. + +`LMOVE` (or `BLMOVE` for the blocking variant) offers a way to avoid +this problem: the consumer fetches the message and at the same time pushes it +into a _processing_ list. +It will use the `LREM` command in order to remove the message from the +_processing_ list once the message has been processed. + +An additional client may monitor the _processing_ list for items that remain +there for too much time, and will push those timed out items into the queue +again if needed. + +## Pattern: Circular list + +Using `LMOVE` with the same source and destination key, a client can visit +all the elements of an N-elements list, one after the other, in O(N) without +transferring the full list from the server to the client using a single `LRANGE` +operation. + +The above pattern works even if the following two conditions: + +* There are multiple clients rotating the list: they'll fetch different + elements, until all the elements of the list are visited, and the process + restarts. +* Even if other clients are actively pushing new items at the end of the list. + +The above makes it very simple to implement a system where a set of items must +be processed by N workers continuously as fast as possible. +An example is a monitoring system that must check that a set of web sites are +reachable, with the smallest delay possible, using a number of parallel workers. + +Note that this implementation of workers is trivially scalable and reliable, +because even if a message is lost the item is still in the queue and will be +processed at the next iteration. diff --git a/iredis/data/commands/lmpop.md b/iredis/data/commands/lmpop.md new file mode 100644 index 0000000..aad5b6a --- /dev/null +++ b/iredis/data/commands/lmpop.md @@ -0,0 +1,35 @@ +Pops one or more elements from the first non-empty list key from the list of provided key names. + +`LMPOP` and `BLMPOP` are similar to the following, more limited, commands: + +- `LPOP` or `RPOP` which take only one key, and can return multiple elements. +- `BLPOP` or `BRPOP` which take multiple keys, but return only one element from just one key. + +See `BLMPOP` for the blocking variant of this command. + +Elements are popped from either the left or right of the first non-empty list based on the passed argument. +The number of returned elements is limited to the lower between the non-empty list's length, and the count argument (which defaults to 1). + +@return + +@array-reply: specifically: + +* A `nil` when no element could be popped. +* A two-element array with the first element being the name of the key from which elements were popped, and the second element is an array of elements. + +@examples + +```cli +LMPOP 2 non1 non2 LEFT COUNT 10 +LPUSH mylist "one" "two" "three" "four" "five" +LMPOP 1 mylist LEFT +LRANGE mylist 0 -1 +LMPOP 1 mylist RIGHT COUNT 10 +LPUSH mylist "one" "two" "three" "four" "five" +LPUSH mylist2 "a" "b" "c" "d" "e" +LMPOP 2 mylist mylist2 right count 3 +LRANGE mylist 0 -1 +LMPOP 2 mylist mylist2 right count 5 +LMPOP 2 mylist mylist2 right count 10 +EXISTS mylist mylist2 +``` diff --git a/iredis/data/commands/lolwut.md b/iredis/data/commands/lolwut.md new file mode 100644 index 0000000..a767a38 --- /dev/null +++ b/iredis/data/commands/lolwut.md @@ -0,0 +1,29 @@ +The LOLWUT command displays the Redis version: however as a side effect of +doing so, it also creates a piece of generative computer art that is different +with each version of Redis. The command was introduced in Redis 5 and announced +with this [blog post](http://antirez.com/news/123). + +By default the `LOLWUT` command will display the piece corresponding to the +current Redis version, however it is possible to display a specific version +using the following form: + + LOLWUT VERSION 5 ... other optional arguments ... + +Of course the "5" above is an example. Each LOLWUT version takes a different +set of arguments in order to change the output. The user is encouraged to +play with it to discover how the output changes adding more numerical +arguments. + +LOLWUT wants to be a reminder that there is more in programming than just +putting some code together in order to create something useful. Every +LOLWUT version should have the following properties: + +1. It should display some computer art. There are no limits as long as the output works well in a normal terminal display. However the output should not be limited to graphics (like LOLWUT 5 and 6 actually do), but can be generative poetry and other non graphical things. +2. LOLWUT output should be completely useless. Displaying some useful Redis internal metrics does not count as a valid LOLWUT. +3. LOLWUT output should be fast to generate so that the command can be called in production instances without issues. It should remain fast even when the user experiments with odd parameters. +4. LOLWUT implementations should be safe and carefully checked for security, and resist to untrusted inputs if they take arguments. +5. LOLWUT must always display the Redis version at the end. + +@return + +@bulk-string-reply (or verbatim reply when using the RESP3 protocol): the string containing the generative computer art, and a text with the Redis version. diff --git a/iredis/data/commands/lpop.md b/iredis/data/commands/lpop.md new file mode 100644 index 0000000..c6e77c2 --- /dev/null +++ b/iredis/data/commands/lpop.md @@ -0,0 +1,24 @@ +Removes and returns the first elements of the list stored at `key`. + +By default, the command pops a single element from the beginning of the list. +When provided with the optional `count` argument, the reply will consist of up +to `count` elements, depending on the list's length. + +@return + +When called without the `count` argument: + +@bulk-string-reply: the value of the first element, or `nil` when `key` does not exist. + +When called with the `count` argument: + +@array-reply: list of popped elements, or `nil` when `key` does not exist. + +@examples + +```cli +RPUSH mylist "one" "two" "three" "four" "five" +LPOP mylist +LPOP mylist 2 +LRANGE mylist 0 -1 +``` diff --git a/iredis/data/commands/lpos.md b/iredis/data/commands/lpos.md new file mode 100644 index 0000000..93fe579 --- /dev/null +++ b/iredis/data/commands/lpos.md @@ -0,0 +1,70 @@ +The command returns the index of matching elements inside a Redis list. +By default, when no options are given, it will scan the list from head to tail, +looking for the first match of "element". If the element is found, its index (the zero-based position in the list) is returned. Otherwise, if no match is found, `nil` is returned. + +``` +> RPUSH mylist a b c 1 2 3 c c +> LPOS mylist c +2 +``` + +The optional arguments and options can modify the command's behavior. +The `RANK` option specifies the "rank" of the first element to return, in case there are multiple matches. A rank of 1 means to return the first match, 2 to return the second match, and so forth. + +For instance, in the above example the element "c" is present multiple times, if I want the index of the second match, I'll write: + +``` +> LPOS mylist c RANK 2 +6 +``` + +That is, the second occurrence of "c" is at position 6. +A negative "rank" as the `RANK` argument tells `LPOS` to invert the search direction, starting from the tail to the head. + +So, we want to say, give me the first element starting from the tail of the list: + +``` +> LPOS mylist c RANK -1 +7 +``` + +Note that the indexes are still reported in the "natural" way, that is, considering the first element starting from the head of the list at index 0, the next element at index 1, and so forth. This basically means that the returned indexes are stable whatever the rank is positive or negative. + +Sometimes we want to return not just the Nth matching element, but the position of all the first N matching elements. This can be achieved using the `COUNT` option. + +``` +> LPOS mylist c COUNT 2 +[2,6] +``` + +We can combine `COUNT` and `RANK`, so that `COUNT` will try to return up to the specified number of matches, but starting from the Nth match, as specified by the `RANK` option. + +``` +> LPOS mylist c RANK -1 COUNT 2 +[7,6] +``` + +When `COUNT` is used, it is possible to specify 0 as the number of matches, as a way to tell the command we want all the matches found returned as an array of indexes. This is better than giving a very large `COUNT` option because it is more general. + +``` +> LPOS mylist c COUNT 0 +[2,6,7] +``` + +When `COUNT` is used and no match is found, an empty array is returned. However when `COUNT` is not used and there are no matches, the command returns `nil`. + +Finally, the `MAXLEN` option tells the command to compare the provided element only with a given maximum number of list items. So for instance specifying `MAXLEN 1000` will make sure that the command performs only 1000 comparisons, effectively running the algorithm on a subset of the list (the first part or the last part depending on the fact we use a positive or negative rank). This is useful to limit the maximum complexity of the command. It is also useful when we expect the match to be found very early, but want to be sure that in case this is not true, the command does not take too much time to run. + +When `MAXLEN` is used, it is possible to specify 0 as the maximum number of comparisons, as a way to tell the command we want unlimited comparisons. This is better than giving a very large `MAXLEN` option because it is more general. + +@return + +The command returns the integer representing the matching element, or `nil` if there is no match. However, if the `COUNT` option is given the command returns an array (empty if there are no matches). + +@examples + +```cli +RPUSH mylist a b c d 1 2 3 4 3 3 3 +LPOS mylist 3 +LPOS mylist 3 COUNT 0 RANK 2 +``` diff --git a/iredis/data/commands/lpush.md b/iredis/data/commands/lpush.md new file mode 100644 index 0000000..e8b9720 --- /dev/null +++ b/iredis/data/commands/lpush.md @@ -0,0 +1,23 @@ +Insert all the specified values at the head of the list stored at `key`. +If `key` does not exist, it is created as empty list before performing the push +operations. +When `key` holds a value that is not a list, an error is returned. + +It is possible to push multiple elements using a single command call just +specifying multiple arguments at the end of the command. +Elements are inserted one after the other to the head of the list, from the +leftmost element to the rightmost element. +So for instance the command `LPUSH mylist a b c` will result into a list +containing `c` as first element, `b` as second element and `a` as third element. + +@return + +@integer-reply: the length of the list after the push operations. + +@examples + +```cli +LPUSH mylist "world" +LPUSH mylist "hello" +LRANGE mylist 0 -1 +``` diff --git a/iredis/data/commands/lpushx.md b/iredis/data/commands/lpushx.md new file mode 100644 index 0000000..e98c903 --- /dev/null +++ b/iredis/data/commands/lpushx.md @@ -0,0 +1,18 @@ +Inserts specified values at the head of the list stored at `key`, only if `key` +already exists and holds a list. +In contrary to `LPUSH`, no operation will be performed when `key` does not yet +exist. + +@return + +@integer-reply: the length of the list after the push operation. + +@examples + +```cli +LPUSH mylist "World" +LPUSHX mylist "Hello" +LPUSHX myotherlist "Hello" +LRANGE mylist 0 -1 +LRANGE myotherlist 0 -1 +``` diff --git a/iredis/data/commands/lrange.md b/iredis/data/commands/lrange.md new file mode 100644 index 0000000..7634f3e --- /dev/null +++ b/iredis/data/commands/lrange.md @@ -0,0 +1,40 @@ +Returns the specified elements of the list stored at `key`. +The offsets `start` and `stop` are zero-based indexes, with `0` being the first +element of the list (the head of the list), `1` being the next element and so +on. + +These offsets can also be negative numbers indicating offsets starting at the +end of the list. +For example, `-1` is the last element of the list, `-2` the penultimate, and so +on. + +## Consistency with range functions in various programming languages + +Note that if you have a list of numbers from 0 to 100, `LRANGE list 0 10` will +return 11 elements, that is, the rightmost item is included. +This **may or may not** be consistent with behavior of range-related functions +in your programming language of choice (think Ruby's `Range.new`, `Array#slice` +or Python's `range()` function). + +## Out-of-range indexes + +Out of range indexes will not produce an error. +If `start` is larger than the end of the list, an empty list is returned. +If `stop` is larger than the actual end of the list, Redis will treat it like +the last element of the list. + +@return + +@array-reply: list of elements in the specified range. + +@examples + +```cli +RPUSH mylist "one" +RPUSH mylist "two" +RPUSH mylist "three" +LRANGE mylist 0 0 +LRANGE mylist -3 2 +LRANGE mylist -100 100 +LRANGE mylist 5 10 +``` diff --git a/iredis/data/commands/lrem.md b/iredis/data/commands/lrem.md new file mode 100644 index 0000000..36c0c7d --- /dev/null +++ b/iredis/data/commands/lrem.md @@ -0,0 +1,28 @@ +Removes the first `count` occurrences of elements equal to `element` from the list +stored at `key`. +The `count` argument influences the operation in the following ways: + +* `count > 0`: Remove elements equal to `element` moving from head to tail. +* `count < 0`: Remove elements equal to `element` moving from tail to head. +* `count = 0`: Remove all elements equal to `element`. + +For example, `LREM list -2 "hello"` will remove the last two occurrences of +`"hello"` in the list stored at `list`. + +Note that non-existing keys are treated like empty lists, so when `key` does not +exist, the command will always return `0`. + +@return + +@integer-reply: the number of removed elements. + +@examples + +```cli +RPUSH mylist "hello" +RPUSH mylist "hello" +RPUSH mylist "foo" +RPUSH mylist "hello" +LREM mylist -2 "hello" +LRANGE mylist 0 -1 +``` diff --git a/iredis/data/commands/lset.md b/iredis/data/commands/lset.md new file mode 100644 index 0000000..8f1c391 --- /dev/null +++ b/iredis/data/commands/lset.md @@ -0,0 +1,19 @@ +Sets the list element at `index` to `element`. +For more information on the `index` argument, see `LINDEX`. + +An error is returned for out of range indexes. + +@return + +@simple-string-reply + +@examples + +```cli +RPUSH mylist "one" +RPUSH mylist "two" +RPUSH mylist "three" +LSET mylist 0 "four" +LSET mylist -2 "five" +LRANGE mylist 0 -1 +``` diff --git a/iredis/data/commands/ltrim.md b/iredis/data/commands/ltrim.md new file mode 100644 index 0000000..7cae0c7 --- /dev/null +++ b/iredis/data/commands/ltrim.md @@ -0,0 +1,46 @@ +Trim an existing list so that it will contain only the specified range of +elements specified. +Both `start` and `stop` are zero-based indexes, where `0` is the first element +of the list (the head), `1` the next element and so on. + +For example: `LTRIM foobar 0 2` will modify the list stored at `foobar` so that +only the first three elements of the list will remain. + +`start` and `end` can also be negative numbers indicating offsets from the end +of the list, where `-1` is the last element of the list, `-2` the penultimate +element and so on. + +Out of range indexes will not produce an error: if `start` is larger than the +end of the list, or `start > end`, the result will be an empty list (which +causes `key` to be removed). +If `end` is larger than the end of the list, Redis will treat it like the last +element of the list. + +A common use of `LTRIM` is together with `LPUSH` / `RPUSH`. +For example: + +``` +LPUSH mylist someelement +LTRIM mylist 0 99 +``` + +This pair of commands will push a new element on the list, while making sure +that the list will not grow larger than 100 elements. +This is very useful when using Redis to store logs for example. +It is important to note that when used in this way `LTRIM` is an O(1) operation +because in the average case just one element is removed from the tail of the +list. + +@return + +@simple-string-reply + +@examples + +```cli +RPUSH mylist "one" +RPUSH mylist "two" +RPUSH mylist "three" +LTRIM mylist 1 -1 +LRANGE mylist 0 -1 +``` diff --git a/iredis/data/commands/memory-doctor.md b/iredis/data/commands/memory-doctor.md new file mode 100644 index 0000000..dbb9db3 --- /dev/null +++ b/iredis/data/commands/memory-doctor.md @@ -0,0 +1,6 @@ +The `MEMORY DOCTOR` command reports about different memory-related issues that +the Redis server experiences, and advises about possible remedies. + +@return + +@bulk-string-reply
\ No newline at end of file diff --git a/iredis/data/commands/memory-help.md b/iredis/data/commands/memory-help.md new file mode 100644 index 0000000..c0f4086 --- /dev/null +++ b/iredis/data/commands/memory-help.md @@ -0,0 +1,6 @@ +The `MEMORY HELP` command returns a helpful text describing the different +subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/memory-malloc-stats.md b/iredis/data/commands/memory-malloc-stats.md new file mode 100644 index 0000000..8da8e72 --- /dev/null +++ b/iredis/data/commands/memory-malloc-stats.md @@ -0,0 +1,9 @@ +The `MEMORY MALLOC-STATS` command provides an internal statistics report from +the memory allocator. + +This command is currently implemented only when using **jemalloc** as an +allocator, and evaluates to a benign NOOP for all others. + +@return + +@bulk-string-reply: the memory allocator's internal statistics report diff --git a/iredis/data/commands/memory-purge.md b/iredis/data/commands/memory-purge.md new file mode 100644 index 0000000..5ebe433 --- /dev/null +++ b/iredis/data/commands/memory-purge.md @@ -0,0 +1,9 @@ +The `MEMORY PURGE` command attempts to purge dirty pages so these can be +reclaimed by the allocator. + +This command is currently implemented only when using **jemalloc** as an +allocator, and evaluates to a benign NOOP for all others. + +@return + +@simple-string-reply diff --git a/iredis/data/commands/memory-stats.md b/iredis/data/commands/memory-stats.md new file mode 100644 index 0000000..39cd68e --- /dev/null +++ b/iredis/data/commands/memory-stats.md @@ -0,0 +1,46 @@ +The `MEMORY STATS` command returns an @array-reply about the memory usage of the +server. + +The information about memory usage is provided as metrics and their respective +values. The following metrics are reported: + +* `peak.allocated`: Peak memory consumed by Redis in bytes (see `INFO`'s + `used_memory_peak`) +* `total.allocated`: Total number of bytes allocated by Redis using its + allocator (see `INFO`'s `used_memory`) +* `startup.allocated`: Initial amount of memory consumed by Redis at startup + in bytes (see `INFO`'s `used_memory_startup`) +* `replication.backlog`: Size in bytes of the replication backlog (see + `INFO`'s `repl_backlog_active`) +* `clients.slaves`: The total size in bytes of all replicas overheads (output + and query buffers, connection contexts) +* `clients.normal`: The total size in bytes of all clients overheads (output + and query buffers, connection contexts) +* `cluster.links`: Memory usage by cluster links (Added in Redis 7.0, see `INFO`'s `mem_cluster_links`). +* `aof.buffer`: The summed size in bytes of AOF related buffers. +* `lua.caches`: the summed size in bytes of the overheads of the Lua scripts' + caches +* `dbXXX`: For each of the server's databases, the overheads of the main and + expiry dictionaries (`overhead.hashtable.main` and + `overhead.hashtable.expires`, respectively) are reported in bytes +* `overhead.total`: The sum of all overheads, i.e. `startup.allocated`, + `replication.backlog`, `clients.slaves`, `clients.normal`, `aof.buffer` and + those of the internal data structures that are used in managing the + Redis keyspace (see `INFO`'s `used_memory_overhead`) +* `keys.count`: The total number of keys stored across all databases in the + server +* `keys.bytes-per-key`: The ratio between **net memory usage** (`total.allocated` + minus `startup.allocated`) and `keys.count` +* `dataset.bytes`: The size in bytes of the dataset, i.e. `overhead.total` + subtracted from `total.allocated` (see `INFO`'s `used_memory_dataset`) +* `dataset.percentage`: The percentage of `dataset.bytes` out of the net + memory usage +* `peak.percentage`: The percentage of `peak.allocated` out of + `total.allocated` +* `fragmentation`: See `INFO`'s `mem_fragmentation_ratio` + +@return + +@array-reply: nested list of memory usage metrics and their values + +**A note about the word slave used in this man page**: Starting with Redis 5, if not for backward compatibility, the Redis project no longer uses the word slave. Unfortunately in this command the word slave is part of the protocol, so we'll be able to remove such occurrences only when this API will be naturally deprecated. diff --git a/iredis/data/commands/memory-usage.md b/iredis/data/commands/memory-usage.md new file mode 100644 index 0000000..ae5a4bc --- /dev/null +++ b/iredis/data/commands/memory-usage.md @@ -0,0 +1,40 @@ +The `MEMORY USAGE` command reports the number of bytes that a key and its value +require to be stored in RAM. + +The reported usage is the total of memory allocations for data and +administrative overheads that a key its value require. + +For nested data types, the optional `SAMPLES` option can be provided, where +`count` is the number of sampled nested values. By default, this option is set +to `5`. To sample the all of the nested values, use `SAMPLES 0`. + +@examples + +With Redis v4.0.1 64-bit and **jemalloc**, the empty string measures as follows: + +``` +> SET "" "" +OK +> MEMORY USAGE "" +(integer) 51 +``` + +These bytes are pure overhead at the moment as no actual data is stored, and are +used for maintaining the internal data structures of the server. Longer keys and +values show asymptotically linear usage. + +``` +> SET foo bar +OK +> MEMORY USAGE foo +(integer) 54 +> SET cento 01234567890123456789012345678901234567890123 +45678901234567890123456789012345678901234567890123456789 +OK +127.0.0.1:6379> MEMORY USAGE cento +(integer) 153 +``` + +@return + +@integer-reply: the memory usage in bytes, or `nil` when the key does not exist. diff --git a/iredis/data/commands/memory.md b/iredis/data/commands/memory.md new file mode 100644 index 0000000..46bde8d --- /dev/null +++ b/iredis/data/commands/memory.md @@ -0,0 +1,3 @@ +This is a container command for memory introspection and management commands. + +To see the list of available commands you can call `MEMORY HELP`. diff --git a/iredis/data/commands/mget.md b/iredis/data/commands/mget.md new file mode 100644 index 0000000..8bca6ca --- /dev/null +++ b/iredis/data/commands/mget.md @@ -0,0 +1,16 @@ +Returns the values of all specified keys. +For every key that does not hold a string value or does not exist, the special +value `nil` is returned. +Because of this, the operation never fails. + +@return + +@array-reply: list of values at the specified keys. + +@examples + +```cli +SET key1 "Hello" +SET key2 "World" +MGET key1 key2 nonexisting +``` diff --git a/iredis/data/commands/migrate.md b/iredis/data/commands/migrate.md new file mode 100644 index 0000000..318e0e2 --- /dev/null +++ b/iredis/data/commands/migrate.md @@ -0,0 +1,72 @@ +Atomically transfer a key from a source Redis instance to a destination Redis +instance. +On success the key is deleted from the original instance and is guaranteed to +exist in the target instance. + +The command is atomic and blocks the two instances for the time required to +transfer the key, at any given time the key will appear to exist in a given +instance or in the other instance, unless a timeout error occurs. In 3.2 and +above, multiple keys can be pipelined in a single call to `MIGRATE` by passing +the empty string ("") as key and adding the `!KEYS` clause. + +The command internally uses `DUMP` to generate the serialized version of the key +value, and `RESTORE` in order to synthesize the key in the target instance. +The source instance acts as a client for the target instance. +If the target instance returns OK to the `RESTORE` command, the source instance +deletes the key using `DEL`. + +The timeout specifies the maximum idle time in any moment of the communication +with the destination instance in milliseconds. +This means that the operation does not need to be completed within the specified +amount of milliseconds, but that the transfer should make progresses without +blocking for more than the specified amount of milliseconds. + +`MIGRATE` needs to perform I/O operations and to honor the specified timeout. +When there is an I/O error during the transfer or if the timeout is reached the +operation is aborted and the special error - `IOERR` returned. +When this happens the following two cases are possible: + +* The key may be on both the instances. +* The key may be only in the source instance. + +It is not possible for the key to get lost in the event of a timeout, but the +client calling `MIGRATE`, in the event of a timeout error, should check if the +key is _also_ present in the target instance and act accordingly. + +When any other error is returned (starting with `ERR`) `MIGRATE` guarantees that +the key is still only present in the originating instance (unless a key with the +same name was also _already_ present on the target instance). + +If there are no keys to migrate in the source instance `NOKEY` is returned. +Because missing keys are possible in normal conditions, from expiry for example, +`NOKEY` isn't an error. + +## Migrating multiple keys with a single command call + +Starting with Redis 3.0.6 `MIGRATE` supports a new bulk-migration mode that +uses pipelining in order to migrate multiple keys between instances without +incurring in the round trip time latency and other overheads that there are +when moving each key with a single `MIGRATE` call. + +In order to enable this form, the `!KEYS` option is used, and the normal *key* +argument is set to an empty string. The actual key names will be provided +after the `!KEYS` argument itself, like in the following example: + + MIGRATE 192.168.1.34 6379 "" 0 5000 KEYS key1 key2 key3 + +When this form is used the `NOKEY` status code is only returned when none +of the keys is present in the instance, otherwise the command is executed, even if +just a single key exists. + +## Options + +* `!COPY` -- Do not remove the key from the local instance. +* `REPLACE` -- Replace existing key on the remote instance. +* `!KEYS` -- If the key argument is an empty string, the command will instead migrate all the keys that follow the `!KEYS` option (see the above section for more info). +* `!AUTH` -- Authenticate with the given password to the remote instance. +* `AUTH2` -- Authenticate with the given username and password pair (Redis 6 or greater ACL auth style). + +@return + +@simple-string-reply: The command returns OK on success, or `NOKEY` if no keys were +found in the source instance. diff --git a/iredis/data/commands/module-help.md b/iredis/data/commands/module-help.md new file mode 100644 index 0000000..a05bf1e --- /dev/null +++ b/iredis/data/commands/module-help.md @@ -0,0 +1,5 @@ +The `MODULE HELP` command returns a helpful text describing the different subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/module-list.md b/iredis/data/commands/module-list.md new file mode 100644 index 0000000..1bfa3e2 --- /dev/null +++ b/iredis/data/commands/module-list.md @@ -0,0 +1,10 @@ +Returns information about the modules loaded to the server. + +@return + +@array-reply: list of loaded modules. Each element in the list represents a +module, and is in itself a list of property names and their values. The +following properties is reported for each loaded module: + +* `name`: Name of the module +* `ver`: Version of the module diff --git a/iredis/data/commands/module-load.md b/iredis/data/commands/module-load.md new file mode 100644 index 0000000..99777c3 --- /dev/null +++ b/iredis/data/commands/module-load.md @@ -0,0 +1,13 @@ +Loads a module from a dynamic library at runtime. + +This command loads and initializes the Redis module from the dynamic library +specified by the `path` argument. The `path` should be the absolute path of the +library, including the full filename. Any additional arguments are passed +unmodified to the module. + +**Note**: modules can also be loaded at server startup with `loadmodule` +configuration directive in `redis.conf`. + +@return + +@simple-string-reply: `OK` if module was loaded. diff --git a/iredis/data/commands/module-loadex.md b/iredis/data/commands/module-loadex.md new file mode 100644 index 0000000..f7a55db --- /dev/null +++ b/iredis/data/commands/module-loadex.md @@ -0,0 +1,15 @@ +Loads a module from a dynamic library at runtime with configuration directives. + +This is an extended version of the `MODULE LOAD` command. + +It loads and initializes the Redis module from the dynamic library specified by the `path` argument. The `path` should be the absolute path of the library, including the full filename. + +You can use the optional `!CONFIG` argument to provide the module with configuration directives. +Any additional arguments that follow the `ARGS` keyword are passed unmodified to the module. + +**Note**: modules can also be loaded at server startup with `loadmodule` +configuration directive in `redis.conf`. + +@return + +@simple-string-reply: `OK` if module was loaded. diff --git a/iredis/data/commands/module-unload.md b/iredis/data/commands/module-unload.md new file mode 100644 index 0000000..84ebebf --- /dev/null +++ b/iredis/data/commands/module-unload.md @@ -0,0 +1,13 @@ +Unloads a module. + +This command unloads the module specified by `name`. Note that the module's name +is reported by the `MODULE LIST` command, and may differ from the dynamic +library's filename. + +Known limitations: + +* Modules that register custom data types can not be unloaded. + +@return + +@simple-string-reply: `OK` if module was unloaded. diff --git a/iredis/data/commands/module.md b/iredis/data/commands/module.md new file mode 100644 index 0000000..87fa539 --- /dev/null +++ b/iredis/data/commands/module.md @@ -0,0 +1,3 @@ +This is a container command for module management commands. + +To see the list of available commands you can call `MODULE HELP`. diff --git a/iredis/data/commands/monitor.md b/iredis/data/commands/monitor.md new file mode 100644 index 0000000..2622cdd --- /dev/null +++ b/iredis/data/commands/monitor.md @@ -0,0 +1,92 @@ +`MONITOR` is a debugging command that streams back every command processed by +the Redis server. +It can help in understanding what is happening to the database. +This command can both be used via `redis-cli` and via `telnet`. + +The ability to see all the requests processed by the server is useful in order +to spot bugs in an application both when using Redis as a database and as a +distributed caching system. + +``` +$ redis-cli monitor +1339518083.107412 [0 127.0.0.1:60866] "keys" "*" +1339518087.877697 [0 127.0.0.1:60866] "dbsize" +1339518090.420270 [0 127.0.0.1:60866] "set" "x" "6" +1339518096.506257 [0 127.0.0.1:60866] "get" "x" +1339518099.363765 [0 127.0.0.1:60866] "eval" "return redis.call('set','x','7')" "0" +1339518100.363799 [0 lua] "set" "x" "7" +1339518100.544926 [0 127.0.0.1:60866] "del" "x" +``` + +Use `SIGINT` (Ctrl-C) to stop a `MONITOR` stream running via `redis-cli`. + +``` +$ telnet localhost 6379 +Trying 127.0.0.1... +Connected to localhost. +Escape character is '^]'. +MONITOR ++OK ++1339518083.107412 [0 127.0.0.1:60866] "keys" "*" ++1339518087.877697 [0 127.0.0.1:60866] "dbsize" ++1339518090.420270 [0 127.0.0.1:60866] "set" "x" "6" ++1339518096.506257 [0 127.0.0.1:60866] "get" "x" ++1339518099.363765 [0 127.0.0.1:60866] "del" "x" ++1339518100.544926 [0 127.0.0.1:60866] "get" "x" +QUIT ++OK +Connection closed by foreign host. +``` + +Manually issue the `QUIT` or `RESET` commands to stop a `MONITOR` stream running +via `telnet`. + +## Commands not logged by MONITOR + +Because of security concerns, no administrative commands are logged +by `MONITOR`'s output and sensitive data is redacted in the command `AUTH`. + +Furthermore, the command `QUIT` is also not logged. + +## Cost of running MONITOR + +Because `MONITOR` streams back **all** commands, its use comes at a cost. +The following (totally unscientific) benchmark numbers illustrate what the cost +of running `MONITOR` can be. + +Benchmark result **without** `MONITOR` running: + +``` +$ src/redis-benchmark -c 10 -n 100000 -q +PING_INLINE: 101936.80 requests per second +PING_BULK: 102880.66 requests per second +SET: 95419.85 requests per second +GET: 104275.29 requests per second +INCR: 93283.58 requests per second +``` + +Benchmark result **with** `MONITOR` running (`redis-cli monitor > /dev/null`): + +``` +$ src/redis-benchmark -c 10 -n 100000 -q +PING_INLINE: 58479.53 requests per second +PING_BULK: 59136.61 requests per second +SET: 41823.50 requests per second +GET: 45330.91 requests per second +INCR: 41771.09 requests per second +``` + +In this particular case, running a single `MONITOR` client can reduce the +throughput by more than 50%. +Running more `MONITOR` clients will reduce throughput even more. + +@return + +**Non standard return value**, just dumps the received commands in an infinite +flow. + +## Behavior change history + +* `>= 6.0.0`: `AUTH` excluded from the command's output. +* `>= 6.2.0`: "`RESET` can be called to exit monitor mode. +* `>= 6.2.4`: "`AUTH`, `HELLO`, `EVAL`, `EVAL_RO`, `EVALSHA` and `EVALSHA_RO` included in the command's output.
\ No newline at end of file diff --git a/iredis/data/commands/move.md b/iredis/data/commands/move.md new file mode 100644 index 0000000..ceb212c --- /dev/null +++ b/iredis/data/commands/move.md @@ -0,0 +1,12 @@ +Move `key` from the currently selected database (see `SELECT`) to the specified +destination database. +When `key` already exists in the destination database, or it does not exist in +the source database, it does nothing. +It is possible to use `MOVE` as a locking primitive because of this. + +@return + +@integer-reply, specifically: + +* `1` if `key` was moved. +* `0` if `key` was not moved. diff --git a/iredis/data/commands/mset.md b/iredis/data/commands/mset.md new file mode 100644 index 0000000..f070d29 --- /dev/null +++ b/iredis/data/commands/mset.md @@ -0,0 +1,19 @@ +Sets the given keys to their respective values. +`MSET` replaces existing values with new values, just as regular `SET`. +See `MSETNX` if you don't want to overwrite existing values. + +`MSET` is atomic, so all given keys are set at once. +It is not possible for clients to see that some of the keys were updated while +others are unchanged. + +@return + +@simple-string-reply: always `OK` since `MSET` can't fail. + +@examples + +```cli +MSET key1 "Hello" key2 "World" +GET key1 +GET key2 +``` diff --git a/iredis/data/commands/msetnx.md b/iredis/data/commands/msetnx.md new file mode 100644 index 0000000..795bfc9 --- /dev/null +++ b/iredis/data/commands/msetnx.md @@ -0,0 +1,26 @@ +Sets the given keys to their respective values. +`MSETNX` will not perform any operation at all even if just a single key already +exists. + +Because of this semantic `MSETNX` can be used in order to set different keys +representing different fields of a unique logic object in a way that ensures +that either all the fields or none at all are set. + +`MSETNX` is atomic, so all given keys are set at once. +It is not possible for clients to see that some of the keys were updated while +others are unchanged. + +@return + +@integer-reply, specifically: + +* `1` if the all the keys were set. +* `0` if no key was set (at least one key already existed). + +@examples + +```cli +MSETNX key1 "Hello" key2 "there" +MSETNX key2 "new" key3 "world" +MGET key1 key2 key3 +``` diff --git a/iredis/data/commands/multi.md b/iredis/data/commands/multi.md new file mode 100644 index 0000000..dc87892 --- /dev/null +++ b/iredis/data/commands/multi.md @@ -0,0 +1,8 @@ +Marks the start of a [transaction][tt] block. +Subsequent commands will be queued for atomic execution using `EXEC`. + +[tt]: /topics/transactions + +@return + +@simple-string-reply: always `OK`. diff --git a/iredis/data/commands/object-encoding.md b/iredis/data/commands/object-encoding.md new file mode 100644 index 0000000..3a9583d --- /dev/null +++ b/iredis/data/commands/object-encoding.md @@ -0,0 +1,21 @@ +Returns the internal encoding for the Redis object stored at `<key>` + +Redis objects can be encoded in different ways: + +* Strings can be encoded as: + + - `raw`, normal string encoding. + - `int`, strings representing integers in a 64-bit signed interval, encoded in this way to save space. + - `embstr`, an embedded string, which is an object where the internal simple dynamic string, `sds`, is an unmodifiable string allocated in the same chuck as the object itself. + `embstr` can be strings with lengths up to the hardcoded limit of `OBJ_ENCODING_EMBSTR_SIZE_LIMIT` or 44 bytes. + +* Lists can be encoded as `ziplist` or `linkedlist`. The `ziplist` is the special representation that is used to save space for small lists. +* Sets can be encoded as `intset` or `hashtable`. The `intset` is a special encoding used for small sets composed solely of integers. +* Hashes can be encoded as `ziplist` or `hashtable`. The `ziplist` is a special encoding used for small hashes. +* Sorted Sets can be encoded as `ziplist` or `skiplist` format. As for the List type small sorted sets can be specially encoded using `ziplist`, while the `skiplist` encoding is the one that works with sorted sets of any size. + +All the specially encoded types are automatically converted to the general type once you perform an operation that makes it impossible for Redis to retain the space saving encoding. + +@return + +@bulk-string-reply: the encoding of the object, or `nil` if the key doesn't exist diff --git a/iredis/data/commands/object-freq.md b/iredis/data/commands/object-freq.md new file mode 100644 index 0000000..fdf891e --- /dev/null +++ b/iredis/data/commands/object-freq.md @@ -0,0 +1,9 @@ +This command returns the logarithmic access frequency counter of a Redis object stored at `<key>`. + +The command is only available when the `maxmemory-policy` configuration directive is set to one of the LFU policies. + +@return + +@integer-reply + +The counter's value.
\ No newline at end of file diff --git a/iredis/data/commands/object-help.md b/iredis/data/commands/object-help.md new file mode 100644 index 0000000..f98196c --- /dev/null +++ b/iredis/data/commands/object-help.md @@ -0,0 +1,5 @@ +The `OBJECT HELP` command returns a helpful text describing the different subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/object-idletime.md b/iredis/data/commands/object-idletime.md new file mode 100644 index 0000000..2a89641 --- /dev/null +++ b/iredis/data/commands/object-idletime.md @@ -0,0 +1,9 @@ +This command returns the time in seconds since the last access to the value stored at `<key>`. + +The command is only available when the `maxmemory-policy` configuration directive is not set to one of the LFU policies. + +@return + +@integer-reply + +The idle time in seconds.
\ No newline at end of file diff --git a/iredis/data/commands/object-refcount.md b/iredis/data/commands/object-refcount.md new file mode 100644 index 0000000..639c899 --- /dev/null +++ b/iredis/data/commands/object-refcount.md @@ -0,0 +1,7 @@ +This command returns the reference count of the stored at `<key>`. + +@return + +@integer-reply + +The number of references.
\ No newline at end of file diff --git a/iredis/data/commands/object.md b/iredis/data/commands/object.md new file mode 100644 index 0000000..887ab9d --- /dev/null +++ b/iredis/data/commands/object.md @@ -0,0 +1,3 @@ +This is a container command for object introspection commands. + +To see the list of available commands you can call `OBJECT HELP`. diff --git a/iredis/data/commands/persist.md b/iredis/data/commands/persist.md new file mode 100644 index 0000000..67a0014 --- /dev/null +++ b/iredis/data/commands/persist.md @@ -0,0 +1,20 @@ +Remove the existing timeout on `key`, turning the key from _volatile_ (a key +with an expire set) to _persistent_ (a key that will never expire as no timeout +is associated). + +@return + +@integer-reply, specifically: + +* `1` if the timeout was removed. +* `0` if `key` does not exist or does not have an associated timeout. + +@examples + +```cli +SET mykey "Hello" +EXPIRE mykey 10 +TTL mykey +PERSIST mykey +TTL mykey +``` diff --git a/iredis/data/commands/pexpire.md b/iredis/data/commands/pexpire.md new file mode 100644 index 0000000..bc2e6f1 --- /dev/null +++ b/iredis/data/commands/pexpire.md @@ -0,0 +1,34 @@ +This command works exactly like `EXPIRE` but the time to live of the key is +specified in milliseconds instead of seconds. + +## Options + +The `PEXPIRE` command supports a set of options since Redis 7.0: + +* `NX` -- Set expiry only when the key has no expiry +* `XX` -- Set expiry only when the key has an existing expiry +* `GT` -- Set expiry only when the new expiry is greater than current one +* `LT` -- Set expiry only when the new expiry is less than current one + +A non-volatile key is treated as an infinite TTL for the purpose of `GT` and `LT`. +The `GT`, `LT` and `NX` options are mutually exclusive. + +@return + +@integer-reply, specifically: + +* `1` if the timeout was set. +* `0` if the timeout was not set. e.g. key doesn't exist, or operation skipped due to the provided arguments. + +@examples + +```cli +SET mykey "Hello" +PEXPIRE mykey 1500 +TTL mykey +PTTL mykey +PEXPIRE mykey 1000 XX +TTL mykey +PEXPIRE mykey 1000 NX +TTL mykey +``` diff --git a/iredis/data/commands/pexpireat.md b/iredis/data/commands/pexpireat.md new file mode 100644 index 0000000..21e2853 --- /dev/null +++ b/iredis/data/commands/pexpireat.md @@ -0,0 +1,30 @@ +`PEXPIREAT` has the same effect and semantic as `EXPIREAT`, but the Unix time at +which the key will expire is specified in milliseconds instead of seconds. + +## Options + +The `PEXPIREAT` command supports a set of options since Redis 7.0: + +* `NX` -- Set expiry only when the key has no expiry +* `XX` -- Set expiry only when the key has an existing expiry +* `GT` -- Set expiry only when the new expiry is greater than current one +* `LT` -- Set expiry only when the new expiry is less than current one + +A non-volatile key is treated as an infinite TTL for the purpose of `GT` and `LT`. +The `GT`, `LT` and `NX` options are mutually exclusive. + +@return + +@integer-reply, specifically: + +* `1` if the timeout was set. +* `0` if the timeout was not set. e.g. key doesn't exist, or operation skipped due to the provided arguments. + +@examples + +```cli +SET mykey "Hello" +PEXPIREAT mykey 1555555555005 +TTL mykey +PTTL mykey +``` diff --git a/iredis/data/commands/pexpiretime.md b/iredis/data/commands/pexpiretime.md new file mode 100644 index 0000000..9fcda95 --- /dev/null +++ b/iredis/data/commands/pexpiretime.md @@ -0,0 +1,16 @@ +`PEXPIRETIME` has the same semantic as `EXPIRETIME`, but returns the absolute Unix expiration timestamp in milliseconds instead of seconds. + +@return + +@integer-reply: Expiration Unix timestamp in milliseconds, or a negative value in order to signal an error (see the description below). + +* The command returns `-1` if the key exists but has no associated expiration time. +* The command returns `-2` if the key does not exist. + +@examples + +```cli +SET mykey "Hello" +PEXPIREAT mykey 33177117420000 +PEXPIRETIME mykey +``` diff --git a/iredis/data/commands/pfadd.md b/iredis/data/commands/pfadd.md new file mode 100644 index 0000000..5d0128b --- /dev/null +++ b/iredis/data/commands/pfadd.md @@ -0,0 +1,22 @@ +Adds all the element arguments to the HyperLogLog data structure stored at the variable name specified as first argument. + +As a side effect of this command the HyperLogLog internals may be updated to reflect a different estimation of the number of unique items added so far (the cardinality of the set). + +If the approximated cardinality estimated by the HyperLogLog changed after executing the command, `PFADD` returns 1, otherwise 0 is returned. The command automatically creates an empty HyperLogLog structure (that is, a Redis String of a specified length and with a given encoding) if the specified key does not exist. + +To call the command without elements but just the variable name is valid, this will result into no operation performed if the variable already exists, or just the creation of the data structure if the key does not exist (in the latter case 1 is returned). + +For an introduction to HyperLogLog data structure check the `PFCOUNT` command page. + +@return + +@integer-reply, specifically: + +* 1 if at least 1 HyperLogLog internal register was altered. 0 otherwise. + +@examples + +```cli +PFADD hll a b c d e f g +PFCOUNT hll +``` diff --git a/iredis/data/commands/pfcount.md b/iredis/data/commands/pfcount.md new file mode 100644 index 0000000..71d1093 --- /dev/null +++ b/iredis/data/commands/pfcount.md @@ -0,0 +1,61 @@ +When called with a single key, returns the approximated cardinality computed by the HyperLogLog data structure stored at the specified variable, which is 0 if the variable does not exist. + +When called with multiple keys, returns the approximated cardinality of the union of the HyperLogLogs passed, by internally merging the HyperLogLogs stored at the provided keys into a temporary HyperLogLog. + +The HyperLogLog data structure can be used in order to count **unique** elements in a set using just a small constant amount of memory, specifically 12k bytes for every HyperLogLog (plus a few bytes for the key itself). + +The returned cardinality of the observed set is not exact, but approximated with a standard error of 0.81%. + +For example in order to take the count of all the unique search queries performed in a day, a program needs to call `PFADD` every time a query is processed. The estimated number of unique queries can be retrieved with `PFCOUNT` at any time. + +Note: as a side effect of calling this function, it is possible that the HyperLogLog is modified, since the last 8 bytes encode the latest computed cardinality +for caching purposes. So `PFCOUNT` is technically a write command. + +@return + +@integer-reply, specifically: + +* The approximated number of unique elements observed via `PFADD`. + +@examples + +```cli +PFADD hll foo bar zap +PFADD hll zap zap zap +PFADD hll foo bar +PFCOUNT hll +PFADD some-other-hll 1 2 3 +PFCOUNT hll some-other-hll +``` + +Performances +--- + +When `PFCOUNT` is called with a single key, performances are excellent even if +in theory constant times to process a dense HyperLogLog are high. This is +possible because the `PFCOUNT` uses caching in order to remember the cardinality +previously computed, that rarely changes because most `PFADD` operations will +not update any register. Hundreds of operations per second are possible. + +When `PFCOUNT` is called with multiple keys, an on-the-fly merge of the +HyperLogLogs is performed, which is slow, moreover the cardinality of the union +can't be cached, so when used with multiple keys `PFCOUNT` may take a time in +the order of magnitude of the millisecond, and should be not abused. + +The user should take in mind that single-key and multiple-keys executions of +this command are semantically different and have different performances. + +HyperLogLog representation +--- + +Redis HyperLogLogs are represented using a double representation: the *sparse* representation suitable for HLLs counting a small number of elements (resulting in a small number of registers set to non-zero value), and a *dense* representation suitable for higher cardinalities. Redis automatically switches from the sparse to the dense representation when needed. + +The sparse representation uses a run-length encoding optimized to store efficiently a big number of registers set to zero. The dense representation is a Redis string of 12288 bytes in order to store 16384 6-bit counters. The need for the double representation comes from the fact that using 12k (which is the dense representation memory requirement) to encode just a few registers for smaller cardinalities is extremely suboptimal. + +Both representations are prefixed with a 16 bytes header, that includes a magic, an encoding / version field, and the cached cardinality estimation computed, stored in little endian format (the most significant bit is 1 if the estimation is invalid since the HyperLogLog was updated since the cardinality was computed). + +The HyperLogLog, being a Redis string, can be retrieved with `GET` and restored with `SET`. Calling `PFADD`, `PFCOUNT` or `PFMERGE` commands with a corrupted HyperLogLog is never a problem, it may return random values but does not affect the stability of the server. Most of the times when corrupting a sparse representation, the server recognizes the corruption and returns an error. + +The representation is neutral from the point of view of the processor word size and endianness, so the same representation is used by 32 bit and 64 bit processor, big endian or little endian. + +More details about the Redis HyperLogLog implementation can be found in [this blog post](http://antirez.com/news/75). The source code of the implementation in the `hyperloglog.c` file is also easy to read and understand, and includes a full specification for the exact encoding used for the sparse and dense representations. diff --git a/iredis/data/commands/pfdebug.md b/iredis/data/commands/pfdebug.md new file mode 100644 index 0000000..b7cceea --- /dev/null +++ b/iredis/data/commands/pfdebug.md @@ -0,0 +1,2 @@ +The `PFDEBUG` command is an internal command. +It is meant to be used for developing and testing Redis.
\ No newline at end of file diff --git a/iredis/data/commands/pfmerge.md b/iredis/data/commands/pfmerge.md new file mode 100644 index 0000000..c59c930 --- /dev/null +++ b/iredis/data/commands/pfmerge.md @@ -0,0 +1,23 @@ +Merge multiple HyperLogLog values into a unique value that will approximate +the cardinality of the union of the observed Sets of the source HyperLogLog +structures. + +The computed merged HyperLogLog is set to the destination variable, which is +created if does not exist (defaulting to an empty HyperLogLog). + +If the destination variable exists, it is treated as one of the source sets +and its cardinality will be included in the cardinality of the computed +HyperLogLog. + +@return + +@simple-string-reply: The command just returns `OK`. + +@examples + +```cli +PFADD hll1 foo bar zap a +PFADD hll2 a b c foo +PFMERGE hll3 hll1 hll2 +PFCOUNT hll3 +``` diff --git a/iredis/data/commands/pfselftest.md b/iredis/data/commands/pfselftest.md new file mode 100644 index 0000000..bdc1e61 --- /dev/null +++ b/iredis/data/commands/pfselftest.md @@ -0,0 +1,2 @@ +The `PFSELFTEST` command is an internal command. +It is meant to be used for developing and testing Redis.
\ No newline at end of file diff --git a/iredis/data/commands/ping.md b/iredis/data/commands/ping.md new file mode 100644 index 0000000..c16f760 --- /dev/null +++ b/iredis/data/commands/ping.md @@ -0,0 +1,23 @@ +Returns `PONG` if no argument is provided, otherwise return a copy of the +argument as a bulk. +This command is often used to test if a connection is still alive, or to measure +latency. + +If the client is subscribed to a channel or a pattern, it will instead return a +multi-bulk with a "pong" in the first position and an empty bulk in the second +position, unless an argument is provided in which case it returns a copy +of the argument. + +@return + +@simple-string-reply, and specifically `PONG`, when no argument is provided. + +@bulk-string-reply the argument provided, when applicable. + +@examples + +```cli +PING + +PING "hello world" +``` diff --git a/iredis/data/commands/psetex.md b/iredis/data/commands/psetex.md new file mode 100644 index 0000000..3e9988e --- /dev/null +++ b/iredis/data/commands/psetex.md @@ -0,0 +1,10 @@ +`PSETEX` works exactly like `SETEX` with the sole difference that the expire +time is specified in milliseconds instead of seconds. + +@examples + +```cli +PSETEX mykey 1000 "Hello" +PTTL mykey +GET mykey +``` diff --git a/iredis/data/commands/psubscribe.md b/iredis/data/commands/psubscribe.md new file mode 100644 index 0000000..81c4bba --- /dev/null +++ b/iredis/data/commands/psubscribe.md @@ -0,0 +1,9 @@ +Subscribes the client to the given patterns. + +Supported glob-style patterns: + +* `h?llo` subscribes to `hello`, `hallo` and `hxllo` +* `h*llo` subscribes to `hllo` and `heeeello` +* `h[ae]llo` subscribes to `hello` and `hallo,` but not `hillo` + +Use `\` to escape special characters if you want to match them verbatim. diff --git a/iredis/data/commands/psync.md b/iredis/data/commands/psync.md new file mode 100644 index 0000000..8cbacf2 --- /dev/null +++ b/iredis/data/commands/psync.md @@ -0,0 +1,13 @@ +Initiates a replication stream from the master. + +The `PSYNC` command is called by Redis replicas for initiating a replication +stream from the master. + +For more information about replication in Redis please check the +[replication page][tr]. + +[tr]: /topics/replication + +@return + +**Non standard return value**, a bulk transfer of the data followed by `PING` and write requests from the master. diff --git a/iredis/data/commands/pttl.md b/iredis/data/commands/pttl.md new file mode 100644 index 0000000..4e08079 --- /dev/null +++ b/iredis/data/commands/pttl.md @@ -0,0 +1,22 @@ +Like `TTL` this command returns the remaining time to live of a key that has an +expire set, with the sole difference that `TTL` returns the amount of remaining +time in seconds while `PTTL` returns it in milliseconds. + +In Redis 2.6 or older the command returns `-1` if the key does not exist or if the key exist but has no associated expire. + +Starting with Redis 2.8 the return value in case of error changed: + +* The command returns `-2` if the key does not exist. +* The command returns `-1` if the key exists but has no associated expire. + +@return + +@integer-reply: TTL in milliseconds, or a negative value in order to signal an error (see the description above). + +@examples + +```cli +SET mykey "Hello" +EXPIRE mykey 1 +PTTL mykey +``` diff --git a/iredis/data/commands/publish.md b/iredis/data/commands/publish.md new file mode 100644 index 0000000..62283f8 --- /dev/null +++ b/iredis/data/commands/publish.md @@ -0,0 +1,11 @@ +Posts a message to the given channel. + +In a Redis Cluster clients can publish to every node. The cluster makes sure +that published messages are forwarded as needed, so clients can subscribe to any +channel by connecting to any one of the nodes. + +@return + +@integer-reply: the number of clients that received the message. Note that in a +Redis Cluster, only clients that are connected to the same node as the +publishing client are included in the count. diff --git a/iredis/data/commands/pubsub-channels.md b/iredis/data/commands/pubsub-channels.md new file mode 100644 index 0000000..8b9a06e --- /dev/null +++ b/iredis/data/commands/pubsub-channels.md @@ -0,0 +1,11 @@ +Lists the currently *active channels*. + +An active channel is a Pub/Sub channel with one or more subscribers (excluding clients subscribed to patterns). + +If no `pattern` is specified, all the channels are listed, otherwise if pattern is specified only channels matching the specified glob-style pattern are listed. + +Cluster note: in a Redis Cluster clients can subscribe to every node, and can also publish to every other node. The cluster will make sure that published messages are forwarded as needed. That said, `PUBSUB`'s replies in a cluster only report information from the node's Pub/Sub context, rather than the entire cluster. + +@return + +@array-reply: a list of active channels, optionally matching the specified pattern. diff --git a/iredis/data/commands/pubsub-help.md b/iredis/data/commands/pubsub-help.md new file mode 100644 index 0000000..a7ab2a3 --- /dev/null +++ b/iredis/data/commands/pubsub-help.md @@ -0,0 +1,5 @@ +The `PUBSUB HELP` command returns a helpful text describing the different subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/pubsub-numpat.md b/iredis/data/commands/pubsub-numpat.md new file mode 100644 index 0000000..6f3a7c9 --- /dev/null +++ b/iredis/data/commands/pubsub-numpat.md @@ -0,0 +1,9 @@ +Returns the number of unique patterns that are subscribed to by clients (that are performed using the `PSUBSCRIBE` command). + +Note that this isn't the count of clients subscribed to patterns, but the total number of unique patterns all the clients are subscribed to. + +Cluster note: in a Redis Cluster clients can subscribe to every node, and can also publish to every other node. The cluster will make sure that published messages are forwarded as needed. That said, `PUBSUB`'s replies in a cluster only report information from the node's Pub/Sub context, rather than the entire cluster. + +@return + +@integer-reply: the number of patterns all the clients are subscribed to. diff --git a/iredis/data/commands/pubsub-numsub.md b/iredis/data/commands/pubsub-numsub.md new file mode 100644 index 0000000..d4d6b85 --- /dev/null +++ b/iredis/data/commands/pubsub-numsub.md @@ -0,0 +1,11 @@ +Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified channels. + +Note that it is valid to call this command without channels. In this case it will just return an empty list. + +Cluster note: in a Redis Cluster clients can subscribe to every node, and can also publish to every other node. The cluster will make sure that published messages are forwarded as needed. That said, `PUBSUB`'s replies in a cluster only report information from the node's Pub/Sub context, rather than the entire cluster. + +@return + +@array-reply: a list of channels and number of subscribers for every channel. + +The format is channel, count, channel, count, ..., so the list is flat. The order in which the channels are listed is the same as the order of the channels specified in the command call. diff --git a/iredis/data/commands/pubsub-shardchannels.md b/iredis/data/commands/pubsub-shardchannels.md new file mode 100644 index 0000000..543eab0 --- /dev/null +++ b/iredis/data/commands/pubsub-shardchannels.md @@ -0,0 +1,20 @@ +Lists the currently *active shard channels*. + +An active shard channel is a Pub/Sub shard channel with one or more subscribers. + +If no `pattern` is specified, all the channels are listed, otherwise if pattern is specified only channels matching the specified glob-style pattern are listed. + +The information returned about the active shard channels are at the shard level and not at the cluster level. + +@return + +@array-reply: a list of active channels, optionally matching the specified pattern. + +@examples + +``` +> PUBSUB SHARDCHANNELS +1) "orders" +PUBSUB SHARDCHANNELS o* +1) "orders" +``` diff --git a/iredis/data/commands/pubsub-shardnumsub.md b/iredis/data/commands/pubsub-shardnumsub.md new file mode 100644 index 0000000..8d09d43 --- /dev/null +++ b/iredis/data/commands/pubsub-shardnumsub.md @@ -0,0 +1,19 @@ +Returns the number of subscribers for the specified shard channels. + +Note that it is valid to call this command without channels, in this case it will just return an empty list. + +Cluster note: in a Redis Cluster, `PUBSUB`'s replies in a cluster only report information from the node's Pub/Sub context, rather than the entire cluster. + +@return + +@array-reply: a list of channels and number of subscribers for every channel. + +The format is channel, count, channel, count, ..., so the list is flat. The order in which the channels are listed is the same as the order of the shard channels specified in the command call. + +@examples + +``` +> PUBSUB SHARDNUMSUB orders +1) "orders" +2) (integer) 1 +``` diff --git a/iredis/data/commands/pubsub.md b/iredis/data/commands/pubsub.md new file mode 100644 index 0000000..fa10a9e --- /dev/null +++ b/iredis/data/commands/pubsub.md @@ -0,0 +1,3 @@ +This is a container command for Pub/Sub introspection commands. + +To see the list of available commands you can call `PUBSUB HELP`. diff --git a/iredis/data/commands/punsubscribe.md b/iredis/data/commands/punsubscribe.md new file mode 100644 index 0000000..af8ee7e --- /dev/null +++ b/iredis/data/commands/punsubscribe.md @@ -0,0 +1,7 @@ +Unsubscribes the client from the given patterns, or from all of them if none is +given. + +When no patterns are specified, the client is unsubscribed from all the +previously subscribed patterns. +In this case, a message for every unsubscribed pattern will be sent to the +client. diff --git a/iredis/data/commands/quit.md b/iredis/data/commands/quit.md new file mode 100644 index 0000000..6be9b55 --- /dev/null +++ b/iredis/data/commands/quit.md @@ -0,0 +1,7 @@ +Ask the server to close the connection. +The connection is closed as soon as all pending replies have been written to the +client. + +@return + +@simple-string-reply: always OK. diff --git a/iredis/data/commands/randomkey.md b/iredis/data/commands/randomkey.md new file mode 100644 index 0000000..d823322 --- /dev/null +++ b/iredis/data/commands/randomkey.md @@ -0,0 +1,5 @@ +Return a random key from the currently selected database. + +@return + +@bulk-string-reply: the random key, or `nil` when the database is empty. diff --git a/iredis/data/commands/readonly.md b/iredis/data/commands/readonly.md new file mode 100644 index 0000000..bc73b9b --- /dev/null +++ b/iredis/data/commands/readonly.md @@ -0,0 +1,19 @@ +Enables read queries for a connection to a Redis Cluster replica node. + +Normally replica nodes will redirect clients to the authoritative master for +the hash slot involved in a given command, however clients can use replicas +in order to scale reads using the `READONLY` command. + +`READONLY` tells a Redis Cluster replica node that the client is willing to +read possibly stale data and is not interested in running write queries. + +When the connection is in readonly mode, the cluster will send a redirection +to the client only if the operation involves keys not served by the replica's +master node. This may happen because: + +1. The client sent a command about hash slots never served by the master of this replica. +2. The cluster was reconfigured (for example resharded) and the replica is no longer able to serve commands for a given hash slot. + +@return + +@simple-string-reply diff --git a/iredis/data/commands/readwrite.md b/iredis/data/commands/readwrite.md new file mode 100644 index 0000000..d6d7089 --- /dev/null +++ b/iredis/data/commands/readwrite.md @@ -0,0 +1,10 @@ +Disables read queries for a connection to a Redis Cluster replica node. + +Read queries against a Redis Cluster replica node are disabled by default, +but you can use the `READONLY` command to change this behavior on a per- +connection basis. The `READWRITE` command resets the readonly mode flag +of a connection back to readwrite. + +@return + +@simple-string-reply diff --git a/iredis/data/commands/rename.md b/iredis/data/commands/rename.md new file mode 100644 index 0000000..471ecf4 --- /dev/null +++ b/iredis/data/commands/rename.md @@ -0,0 +1,21 @@ +Renames `key` to `newkey`. +It returns an error when `key` does not exist. +If `newkey` already exists it is overwritten, when this happens `RENAME` executes an implicit `DEL` operation, so if the deleted key contains a very big value it may cause high latency even if `RENAME` itself is usually a constant-time operation. + +In Cluster mode, both `key` and `newkey` must be in the same **hash slot**, meaning that in practice only keys that have the same hash tag can be reliably renamed in cluster. + +@return + +@simple-string-reply + +@examples + +```cli +SET mykey "Hello" +RENAME mykey myotherkey +GET myotherkey +``` + +## Behavior change history + +* `>= 3.2.0`: The command no longer returns an error when source and destination names are the same.
\ No newline at end of file diff --git a/iredis/data/commands/renamenx.md b/iredis/data/commands/renamenx.md new file mode 100644 index 0000000..c132af4 --- /dev/null +++ b/iredis/data/commands/renamenx.md @@ -0,0 +1,20 @@ +Renames `key` to `newkey` if `newkey` does not yet exist. +It returns an error when `key` does not exist. + +In Cluster mode, both `key` and `newkey` must be in the same **hash slot**, meaning that in practice only keys that have the same hash tag can be reliably renamed in cluster. + +@return + +@integer-reply, specifically: + +* `1` if `key` was renamed to `newkey`. +* `0` if `newkey` already exists. + +@examples + +```cli +SET mykey "Hello" +SET myotherkey "World" +RENAMENX mykey myotherkey +GET myotherkey +``` diff --git a/iredis/data/commands/replconf.md b/iredis/data/commands/replconf.md new file mode 100644 index 0000000..fc34549 --- /dev/null +++ b/iredis/data/commands/replconf.md @@ -0,0 +1,2 @@ +The `REPLCONF` command is an internal command. +It is used by a Redis master to configure a connected replica.
\ No newline at end of file diff --git a/iredis/data/commands/replicaof.md b/iredis/data/commands/replicaof.md new file mode 100644 index 0000000..1c3ec93 --- /dev/null +++ b/iredis/data/commands/replicaof.md @@ -0,0 +1,21 @@ +The `REPLICAOF` command can change the replication settings of a replica on the fly. + +If a Redis server is already acting as replica, the command `REPLICAOF` NO ONE will turn off the replication, turning the Redis server into a MASTER. In the proper form `REPLICAOF` hostname port will make the server a replica of another server listening at the specified hostname and port. + +If a server is already a replica of some master, `REPLICAOF` hostname port will stop the replication against the old server and start the synchronization against the new one, discarding the old dataset. + +The form `REPLICAOF` NO ONE will stop replication, turning the server into a MASTER, but will not discard the replication. So, if the old master stops working, it is possible to turn the replica into a master and set the application to use this new master in read/write. Later when the other Redis server is fixed, it can be reconfigured to work as a replica. + +@return + +@simple-string-reply + +@examples + +``` +> REPLICAOF NO ONE +"OK" + +> REPLICAOF 127.0.0.1 6799 +"OK" +``` diff --git a/iredis/data/commands/reset.md b/iredis/data/commands/reset.md new file mode 100644 index 0000000..b3f17d2 --- /dev/null +++ b/iredis/data/commands/reset.md @@ -0,0 +1,23 @@ +This command performs a full reset of the connection's server-side context, +mimicking the effect of disconnecting and reconnecting again. + +When the command is called from a regular client connection, it does the +following: + +* Discards the current `MULTI` transaction block, if one exists. +* Unwatches all keys `WATCH`ed by the connection. +* Disables `CLIENT TRACKING`, if in use. +* Sets the connection to `READWRITE` mode. +* Cancels the connection's `ASKING` mode, if previously set. +* Sets `CLIENT REPLY` to `ON`. +* Sets the protocol version to RESP2. +* `SELECT`s database 0. +* Exits `MONITOR` mode, when applicable. +* Aborts Pub/Sub's subscription state (`SUBSCRIBE` and `PSUBSCRIBE`), when + appropriate. +* Deauthenticates the connection, requiring a call `AUTH` to reauthenticate when + authentication is enabled. + +@return + +@simple-string-reply: always 'RESET'. diff --git a/iredis/data/commands/restore-asking.md b/iredis/data/commands/restore-asking.md new file mode 100644 index 0000000..1648805 --- /dev/null +++ b/iredis/data/commands/restore-asking.md @@ -0,0 +1,2 @@ +The `RESTORE-ASKING` command is an internal command. +It is used by a Redis cluster master during slot migration.
\ No newline at end of file diff --git a/iredis/data/commands/restore.md b/iredis/data/commands/restore.md new file mode 100644 index 0000000..eb605be --- /dev/null +++ b/iredis/data/commands/restore.md @@ -0,0 +1,40 @@ +Create a key associated with a value that is obtained by deserializing the +provided serialized value (obtained via `DUMP`). + +If `ttl` is 0 the key is created without any expire, otherwise the specified +expire time (in milliseconds) is set. + +If the `ABSTTL` modifier was used, `ttl` should represent an absolute +[Unix timestamp][hewowu] (in milliseconds) in which the key will expire. + +[hewowu]: http://en.wikipedia.org/wiki/Unix_time + +For eviction purposes, you may use the `IDLETIME` or `FREQ` modifiers. See +`OBJECT` for more information. + +`!RESTORE` will return a "Target key name is busy" error when `key` already +exists unless you use the `REPLACE` modifier. + +`!RESTORE` checks the RDB version and data checksum. +If they don't match an error is returned. + +@return + +@simple-string-reply: The command returns OK on success. + +@examples + +``` +redis> DEL mykey +0 +redis> RESTORE mykey 0 "\n\x17\x17\x00\x00\x00\x12\x00\x00\x00\x03\x00\ + x00\xc0\x01\x00\x04\xc0\x02\x00\x04\xc0\x03\x00\ + xff\x04\x00u#<\xc0;.\xe9\xdd" +OK +redis> TYPE mykey +list +redis> LRANGE mykey 0 -1 +1) "1" +2) "2" +3) "3" +``` diff --git a/iredis/data/commands/role.md b/iredis/data/commands/role.md new file mode 100644 index 0000000..c308c93 --- /dev/null +++ b/iredis/data/commands/role.md @@ -0,0 +1,82 @@ +Provide information on the role of a Redis instance in the context of replication, by returning if the instance is currently a `master`, `slave`, or `sentinel`. The command also returns additional information about the state of the replication (if the role is master or slave) or the list of monitored master names (if the role is sentinel). + +## Output format + +The command returns an array of elements. The first element is the role of +the instance, as one of the following three strings: + +* "master" +* "slave" +* "sentinel" + +The additional elements of the array depends on the role. + +## Master output + +An example of output when `ROLE` is called in a master instance: + +``` +1) "master" +2) (integer) 3129659 +3) 1) 1) "127.0.0.1" + 2) "9001" + 3) "3129242" + 2) 1) "127.0.0.1" + 2) "9002" + 3) "3129543" +``` + +The master output is composed of the following parts: + +1. The string `master`. +2. The current master replication offset, which is an offset that masters and replicas share to understand, in partial resynchronizations, the part of the replication stream the replicas needs to fetch to continue. +3. An array composed of three elements array representing the connected replicas. Every sub-array contains the replica IP, port, and the last acknowledged replication offset. + +## Output of the command on replicas + +An example of output when `ROLE` is called in a replica instance: + +``` +1) "slave" +2) "127.0.0.1" +3) (integer) 9000 +4) "connected" +5) (integer) 3167038 +``` + +The replica output is composed of the following parts: + +1. The string `slave`, because of backward compatibility (see note at the end of this page). +2. The IP of the master. +3. The port number of the master. +4. The state of the replication from the point of view of the master, that can be `connect` (the instance needs to connect to its master), `connecting` (the master-replica connection is in progress), `sync` (the master and replica are trying to perform the synchronization), `connected` (the replica is online). +5. The amount of data received from the replica so far in terms of master replication offset. + +## Sentinel output + +An example of Sentinel output: + +``` +1) "sentinel" +2) 1) "resque-master" + 2) "html-fragments-master" + 3) "stats-master" + 4) "metadata-master" +``` + +The sentinel output is composed of the following parts: + +1. The string `sentinel`. +2. An array of master names monitored by this Sentinel instance. + +@return + +@array-reply: where the first element is one of `master`, `slave`, `sentinel` and the additional elements are role-specific as illustrated above. + +@examples + +```cli +ROLE +``` + +**A note about the word slave used in this man page**: Starting with Redis 5, if not for backward compatibility, the Redis project no longer uses the word slave. Unfortunately in this command the word slave is part of the protocol, so we'll be able to remove such occurrences only when this API will be naturally deprecated. diff --git a/iredis/data/commands/rpop.md b/iredis/data/commands/rpop.md new file mode 100644 index 0000000..99c863c --- /dev/null +++ b/iredis/data/commands/rpop.md @@ -0,0 +1,24 @@ +Removes and returns the last elements of the list stored at `key`. + +By default, the command pops a single element from the end of the list. +When provided with the optional `count` argument, the reply will consist of up +to `count` elements, depending on the list's length. + +@return + +When called without the `count` argument: + +@bulk-string-reply: the value of the last element, or `nil` when `key` does not exist. + +When called with the `count` argument: + +@array-reply: list of popped elements, or `nil` when `key` does not exist. + +@examples + +```cli +RPUSH mylist "one" "two" "three" "four" "five" +RPOP mylist +RPOP mylist 2 +LRANGE mylist 0 -1 +``` diff --git a/iredis/data/commands/rpoplpush.md b/iredis/data/commands/rpoplpush.md new file mode 100644 index 0000000..d00e8c9 --- /dev/null +++ b/iredis/data/commands/rpoplpush.md @@ -0,0 +1,75 @@ +Atomically returns and removes the last element (tail) of the list stored at +`source`, and pushes the element at the first element (head) of the list stored +at `destination`. + +For example: consider `source` holding the list `a,b,c`, and `destination` +holding the list `x,y,z`. +Executing `RPOPLPUSH` results in `source` holding `a,b` and `destination` +holding `c,x,y,z`. + +If `source` does not exist, the value `nil` is returned and no operation is +performed. +If `source` and `destination` are the same, the operation is equivalent to +removing the last element from the list and pushing it as first element of the +list, so it can be considered as a list rotation command. + +@return + +@bulk-string-reply: the element being popped and pushed. + +@examples + +```cli +RPUSH mylist "one" +RPUSH mylist "two" +RPUSH mylist "three" +RPOPLPUSH mylist myotherlist +LRANGE mylist 0 -1 +LRANGE myotherlist 0 -1 +``` + +## Pattern: Reliable queue + +Redis is often used as a messaging server to implement processing of background +jobs or other kinds of messaging tasks. +A simple form of queue is often obtained pushing values into a list in the +producer side, and waiting for this values in the consumer side using `RPOP` +(using polling), or `BRPOP` if the client is better served by a blocking +operation. + +However in this context the obtained queue is not _reliable_ as messages can +be lost, for example in the case there is a network problem or if the consumer +crashes just after the message is received but before it can be processed. + +`RPOPLPUSH` (or `BRPOPLPUSH` for the blocking variant) offers a way to avoid +this problem: the consumer fetches the message and at the same time pushes it +into a _processing_ list. +It will use the `LREM` command in order to remove the message from the +_processing_ list once the message has been processed. + +An additional client may monitor the _processing_ list for items that remain +there for too much time, pushing timed out items into the queue +again if needed. + +## Pattern: Circular list + +Using `RPOPLPUSH` with the same source and destination key, a client can visit +all the elements of an N-elements list, one after the other, in O(N) without +transferring the full list from the server to the client using a single `LRANGE` +operation. + +The above pattern works even if one or both of the following conditions occur: + +* There are multiple clients rotating the list: they'll fetch different + elements, until all the elements of the list are visited, and the process + restarts. +* Other clients are actively pushing new items at the end of the list. + +The above makes it very simple to implement a system where a set of items must +be processed by N workers continuously as fast as possible. +An example is a monitoring system that must check that a set of web sites are +reachable, with the smallest delay possible, using a number of parallel workers. + +Note that this implementation of workers is trivially scalable and reliable, +because even if a message is lost the item is still in the queue and will be +processed at the next iteration. diff --git a/iredis/data/commands/rpush.md b/iredis/data/commands/rpush.md new file mode 100644 index 0000000..def4ee1 --- /dev/null +++ b/iredis/data/commands/rpush.md @@ -0,0 +1,23 @@ +Insert all the specified values at the tail of the list stored at `key`. +If `key` does not exist, it is created as empty list before performing the push +operation. +When `key` holds a value that is not a list, an error is returned. + +It is possible to push multiple elements using a single command call just +specifying multiple arguments at the end of the command. +Elements are inserted one after the other to the tail of the list, from the +leftmost element to the rightmost element. +So for instance the command `RPUSH mylist a b c` will result into a list +containing `a` as first element, `b` as second element and `c` as third element. + +@return + +@integer-reply: the length of the list after the push operation. + +@examples + +```cli +RPUSH mylist "hello" +RPUSH mylist "world" +LRANGE mylist 0 -1 +``` diff --git a/iredis/data/commands/rpushx.md b/iredis/data/commands/rpushx.md new file mode 100644 index 0000000..daab019 --- /dev/null +++ b/iredis/data/commands/rpushx.md @@ -0,0 +1,18 @@ +Inserts specified values at the tail of the list stored at `key`, only if `key` +already exists and holds a list. +In contrary to `RPUSH`, no operation will be performed when `key` does not yet +exist. + +@return + +@integer-reply: the length of the list after the push operation. + +@examples + +```cli +RPUSH mylist "Hello" +RPUSHX mylist "World" +RPUSHX myotherlist "World" +LRANGE mylist 0 -1 +LRANGE myotherlist 0 -1 +``` diff --git a/iredis/data/commands/sadd.md b/iredis/data/commands/sadd.md new file mode 100644 index 0000000..f8232bb --- /dev/null +++ b/iredis/data/commands/sadd.md @@ -0,0 +1,20 @@ +Add the specified members to the set stored at `key`. +Specified members that are already a member of this set are ignored. +If `key` does not exist, a new set is created before adding the specified +members. + +An error is returned when the value stored at `key` is not a set. + +@return + +@integer-reply: the number of elements that were added to the set, not including +all the elements already present in the set. + +@examples + +```cli +SADD myset "Hello" +SADD myset "World" +SADD myset "World" +SMEMBERS myset +``` diff --git a/iredis/data/commands/save.md b/iredis/data/commands/save.md new file mode 100644 index 0000000..c66c5e9 --- /dev/null +++ b/iredis/data/commands/save.md @@ -0,0 +1,18 @@ +The `SAVE` commands performs a **synchronous** save of the dataset producing a +_point in time_ snapshot of all the data inside the Redis instance, in the form +of an RDB file. + +You almost never want to call `SAVE` in production environments where it will +block all the other clients. +Instead usually `BGSAVE` is used. +However in case of issues preventing Redis to create the background saving child +(for instance errors in the fork(2) system call), the `SAVE` command can be a +good last resort to perform the dump of the latest dataset. + +Please refer to the [persistence documentation][tp] for detailed information. + +[tp]: /topics/persistence + +@return + +@simple-string-reply: The commands returns OK on success. diff --git a/iredis/data/commands/scan.md b/iredis/data/commands/scan.md new file mode 100644 index 0000000..fd5924f --- /dev/null +++ b/iredis/data/commands/scan.md @@ -0,0 +1,219 @@ +The `SCAN` command and the closely related commands `SSCAN`, `HSCAN` and `ZSCAN` are used in order to incrementally iterate over a collection of elements. + +* `SCAN` iterates the set of keys in the currently selected Redis database. +* `SSCAN` iterates elements of Sets types. +* `HSCAN` iterates fields of Hash types and their associated values. +* `ZSCAN` iterates elements of Sorted Set types and their associated scores. + +Since these commands allow for incremental iteration, returning only a small number of elements per call, they can be used in production without the downside of commands like `KEYS` or `SMEMBERS` that may block the server for a long time (even several seconds) when called against big collections of keys or elements. + +However while blocking commands like `SMEMBERS` are able to provide all the elements that are part of a Set in a given moment, The SCAN family of commands only offer limited guarantees about the returned elements since the collection that we incrementally iterate can change during the iteration process. + +Note that `SCAN`, `SSCAN`, `HSCAN` and `ZSCAN` all work very similarly, so this documentation covers all the four commands. However an obvious difference is that in the case of `SSCAN`, `HSCAN` and `ZSCAN` the first argument is the name of the key holding the Set, Hash or Sorted Set value. The `SCAN` command does not need any key name argument as it iterates keys in the current database, so the iterated object is the database itself. + +## SCAN basic usage + +SCAN is a cursor based iterator. This means that at every call of the command, the server returns an updated cursor that the user needs to use as the cursor argument in the next call. + +An iteration starts when the cursor is set to 0, and terminates when the cursor returned by the server is 0. The following is an example of SCAN iteration: + +``` +redis 127.0.0.1:6379> scan 0 +1) "17" +2) 1) "key:12" + 2) "key:8" + 3) "key:4" + 4) "key:14" + 5) "key:16" + 6) "key:17" + 7) "key:15" + 8) "key:10" + 9) "key:3" + 10) "key:7" + 11) "key:1" +redis 127.0.0.1:6379> scan 17 +1) "0" +2) 1) "key:5" + 2) "key:18" + 3) "key:0" + 4) "key:2" + 5) "key:19" + 6) "key:13" + 7) "key:6" + 8) "key:9" + 9) "key:11" +``` + +In the example above, the first call uses zero as a cursor, to start the iteration. The second call uses the cursor returned by the previous call as the first element of the reply, that is, 17. + +As you can see the **SCAN return value** is an array of two values: the first value is the new cursor to use in the next call, the second value is an array of elements. + +Since in the second call the returned cursor is 0, the server signaled to the caller that the iteration finished, and the collection was completely explored. Starting an iteration with a cursor value of 0, and calling `SCAN` until the returned cursor is 0 again is called a **full iteration**. + +## Scan guarantees + +The `SCAN` command, and the other commands in the `SCAN` family, are able to provide to the user a set of guarantees associated to full iterations. + +* A full iteration always retrieves all the elements that were present in the collection from the start to the end of a full iteration. This means that if a given element is inside the collection when an iteration is started, and is still there when an iteration terminates, then at some point `SCAN` returned it to the user. +* A full iteration never returns any element that was NOT present in the collection from the start to the end of a full iteration. So if an element was removed before the start of an iteration, and is never added back to the collection for all the time an iteration lasts, `SCAN` ensures that this element will never be returned. + +However because `SCAN` has very little state associated (just the cursor) it has the following drawbacks: + +* A given element may be returned multiple times. It is up to the application to handle the case of duplicated elements, for example only using the returned elements in order to perform operations that are safe when re-applied multiple times. +* Elements that were not constantly present in the collection during a full iteration, may be returned or not: it is undefined. + +## Number of elements returned at every SCAN call + +`SCAN` family functions do not guarantee that the number of elements returned per call are in a given range. The commands are also allowed to return zero elements, and the client should not consider the iteration complete as long as the returned cursor is not zero. + +However the number of returned elements is reasonable, that is, in practical terms SCAN may return a maximum number of elements in the order of a few tens of elements when iterating a large collection, or may return all the elements of the collection in a single call when the iterated collection is small enough to be internally represented as an encoded data structure (this happens for small sets, hashes and sorted sets). + +However there is a way for the user to tune the order of magnitude of the number of returned elements per call using the **COUNT** option. + +## The COUNT option + +While `SCAN` does not provide guarantees about the number of elements returned at every iteration, it is possible to empirically adjust the behavior of `SCAN` using the **COUNT** option. Basically with COUNT the user specified the *amount of work that should be done at every call in order to retrieve elements from the collection*. This is **just a hint** for the implementation, however generally speaking this is what you could expect most of the times from the implementation. + +* The default COUNT value is 10. +* When iterating the key space, or a Set, Hash or Sorted Set that is big enough to be represented by a hash table, assuming no **MATCH** option is used, the server will usually return *count* or a bit more than *count* elements per call. Please check the *why SCAN may return all the elements at once* section later in this document. +* When iterating Sets encoded as intsets (small sets composed of just integers), or Hashes and Sorted Sets encoded as ziplists (small hashes and sets composed of small individual values), usually all the elements are returned in the first `SCAN` call regardless of the COUNT value. + +Important: **there is no need to use the same COUNT value** for every iteration. The caller is free to change the count from one iteration to the other as required, as long as the cursor passed in the next call is the one obtained in the previous call to the command. + +## The MATCH option + +It is possible to only iterate elements matching a given glob-style pattern, similarly to the behavior of the `KEYS` command that takes a pattern as only argument. + +To do so, just append the `MATCH <pattern>` arguments at the end of the `SCAN` command (it works with all the SCAN family commands). + +This is an example of iteration using **MATCH**: + +``` +redis 127.0.0.1:6379> sadd myset 1 2 3 foo foobar feelsgood +(integer) 6 +redis 127.0.0.1:6379> sscan myset 0 match f* +1) "0" +2) 1) "foo" + 2) "feelsgood" + 3) "foobar" +redis 127.0.0.1:6379> +``` + +It is important to note that the **MATCH** filter is applied after elements are retrieved from the collection, just before returning data to the client. This means that if the pattern matches very little elements inside the collection, `SCAN` will likely return no elements in most iterations. An example is shown below: + +``` +redis 127.0.0.1:6379> scan 0 MATCH *11* +1) "288" +2) 1) "key:911" +redis 127.0.0.1:6379> scan 288 MATCH *11* +1) "224" +2) (empty list or set) +redis 127.0.0.1:6379> scan 224 MATCH *11* +1) "80" +2) (empty list or set) +redis 127.0.0.1:6379> scan 80 MATCH *11* +1) "176" +2) (empty list or set) +redis 127.0.0.1:6379> scan 176 MATCH *11* COUNT 1000 +1) "0" +2) 1) "key:611" + 2) "key:711" + 3) "key:118" + 4) "key:117" + 5) "key:311" + 6) "key:112" + 7) "key:111" + 8) "key:110" + 9) "key:113" + 10) "key:211" + 11) "key:411" + 12) "key:115" + 13) "key:116" + 14) "key:114" + 15) "key:119" + 16) "key:811" + 17) "key:511" + 18) "key:11" +redis 127.0.0.1:6379> +``` + +As you can see most of the calls returned zero elements, but the last call where a COUNT of 1000 was used in order to force the command to do more scanning for that iteration. + + +## The TYPE option + +You can use the `!TYPE` option to ask `SCAN` to only return objects that match a given `type`, allowing you to iterate through the database looking for keys of a specific type. The **TYPE** option is only available on the whole-database `SCAN`, not `HSCAN` or `ZSCAN` etc. + +The `type` argument is the same string name that the `TYPE` command returns. Note a quirk where some Redis types, such as GeoHashes, HyperLogLogs, Bitmaps, and Bitfields, may internally be implemented using other Redis types, such as a string or zset, so can't be distinguished from other keys of that same type by `SCAN`. For example, a ZSET and GEOHASH: + +``` +redis 127.0.0.1:6379> GEOADD geokey 0 0 value +(integer) 1 +redis 127.0.0.1:6379> ZADD zkey 1000 value +(integer) 1 +redis 127.0.0.1:6379> TYPE geokey +zset +redis 127.0.0.1:6379> TYPE zkey +zset +redis 127.0.0.1:6379> SCAN 0 TYPE zset +1) "0" +2) 1) "geokey" + 2) "zkey" +``` + +It is important to note that the **TYPE** filter is also applied after elements are retrieved from the database, so the option does not reduce the amount of work the server has to do to complete a full iteration, and for rare types you may receive no elements in many iterations. + +## Multiple parallel iterations + +It is possible for an infinite number of clients to iterate the same collection at the same time, as the full state of the iterator is in the cursor, that is obtained and returned to the client at every call. No server side state is taken at all. + +## Terminating iterations in the middle + +Since there is no state server side, but the full state is captured by the cursor, the caller is free to terminate an iteration half-way without signaling this to the server in any way. An infinite number of iterations can be started and never terminated without any issue. + +## Calling SCAN with a corrupted cursor + +Calling `SCAN` with a broken, negative, out of range, or otherwise invalid cursor, will result into undefined behavior but never into a crash. What will be undefined is that the guarantees about the returned elements can no longer be ensured by the `SCAN` implementation. + +The only valid cursors to use are: + +* The cursor value of 0 when starting an iteration. +* The cursor returned by the previous call to SCAN in order to continue the iteration. + +## Guarantee of termination + +The `SCAN` algorithm is guaranteed to terminate only if the size of the iterated collection remains bounded to a given maximum size, otherwise iterating a collection that always grows may result into `SCAN` to never terminate a full iteration. + +This is easy to see intuitively: if the collection grows there is more and more work to do in order to visit all the possible elements, and the ability to terminate the iteration depends on the number of calls to `SCAN` and its COUNT option value compared with the rate at which the collection grows. + +## Why SCAN may return all the items of an aggregate data type in a single call? + +In the `COUNT` option documentation, we state that sometimes this family of commands may return all the elements of a Set, Hash or Sorted Set at once in a single call, regardless of the `COUNT` option value. The reason why this happens is that the cursor-based iterator can be implemented, and is useful, only when the aggregate data type that we are scanning is represented as a hash table. However Redis uses a [memory optimization](/topics/memory-optimization) where small aggregate data types, until they reach a given amount of items or a given max size of single elements, are represented using a compact single-allocation packed encoding. When this is the case, `SCAN` has no meaningful cursor to return, and must iterate the whole data structure at once, so the only sane behavior it has is to return everything in a call. + +However once the data structures are bigger and are promoted to use real hash tables, the `SCAN` family of commands will resort to the normal behavior. Note that since this special behavior of returning all the elements is true only for small aggregates, it has no effects on the command complexity or latency. However the exact limits to get converted into real hash tables are [user configurable](/topics/memory-optimization), so the maximum number of elements you can see returned in a single call depends on how big an aggregate data type could be and still use the packed representation. + +Also note that this behavior is specific of `SSCAN`, `HSCAN` and `ZSCAN`. `SCAN` itself never shows this behavior because the key space is always represented by hash tables. + +## Return value + +`SCAN`, `SSCAN`, `HSCAN` and `ZSCAN` return a two elements multi-bulk reply, where the first element is a string representing an unsigned 64 bit number (the cursor), and the second element is a multi-bulk with an array of elements. + +* `SCAN` array of elements is a list of keys. +* `SSCAN` array of elements is a list of Set members. +* `HSCAN` array of elements contain two elements, a field and a value, for every returned element of the Hash. +* `ZSCAN` array of elements contain two elements, a member and its associated score, for every returned element of the sorted set. + +## Additional examples + +Iteration of a Hash value. + +``` +redis 127.0.0.1:6379> hmset hash name Jack age 33 +OK +redis 127.0.0.1:6379> hscan hash 0 +1) "0" +2) 1) "name" + 2) "Jack" + 3) "age" + 4) "33" +``` diff --git a/iredis/data/commands/scard.md b/iredis/data/commands/scard.md new file mode 100644 index 0000000..85d3c01 --- /dev/null +++ b/iredis/data/commands/scard.md @@ -0,0 +1,14 @@ +Returns the set cardinality (number of elements) of the set stored at `key`. + +@return + +@integer-reply: the cardinality (number of elements) of the set, or `0` if `key` +does not exist. + +@examples + +```cli +SADD myset "Hello" +SADD myset "World" +SCARD myset +``` diff --git a/iredis/data/commands/script-debug.md b/iredis/data/commands/script-debug.md new file mode 100644 index 0000000..3779ed5 --- /dev/null +++ b/iredis/data/commands/script-debug.md @@ -0,0 +1,27 @@ +Set the debug mode for subsequent scripts executed with `EVAL`. Redis includes a +complete Lua debugger, codename LDB, that can be used to make the task of +writing complex scripts much simpler. In debug mode Redis acts as a remote +debugging server and a client, such as `redis-cli`, can execute scripts step by +step, set breakpoints, inspect variables and more - for additional information +about LDB refer to the [Redis Lua debugger](/topics/ldb) page. + +**Important note:** avoid debugging Lua scripts using your Redis production +server. Use a development server instead. + +LDB can be enabled in one of two modes: asynchronous or synchronous. In +asynchronous mode the server creates a forked debugging session that does not +block and all changes to the data are **rolled back** after the session +finishes, so debugging can be restarted using the same initial state. The +alternative synchronous debug mode blocks the server while the debugging session +is active and retains all changes to the data set once it ends. + +* `YES`. Enable non-blocking asynchronous debugging of Lua scripts (changes are discarded). +* `!SYNC`. Enable blocking synchronous debugging of Lua scripts (saves changes to data). +* `NO`. Disables scripts debug mode. + +For more information about `EVAL` scripts please refer to [Introduction to Eval Scripts](/topics/eval-intro). + +@return + +@simple-string-reply: `OK`. + diff --git a/iredis/data/commands/script-exists.md b/iredis/data/commands/script-exists.md new file mode 100644 index 0000000..758660c --- /dev/null +++ b/iredis/data/commands/script-exists.md @@ -0,0 +1,18 @@ +Returns information about the existence of the scripts in the script cache. + +This command accepts one or more SHA1 digests and returns a list of ones or +zeros to signal if the scripts are already defined or not inside the script +cache. +This can be useful before a pipelining operation to ensure that scripts are +loaded (and if not, to load them using `SCRIPT LOAD`) so that the pipelining +operation can be performed solely using `EVALSHA` instead of `EVAL` to save +bandwidth. + +For more information about `EVAL` scripts please refer to [Introduction to Eval Scripts](/topics/eval-intro). + +@return + +@array-reply The command returns an array of integers that correspond to +the specified SHA1 digest arguments. +For every corresponding SHA1 digest of a script that actually exists in the +script cache, a 1 is returned, otherwise 0 is returned. diff --git a/iredis/data/commands/script-flush.md b/iredis/data/commands/script-flush.md new file mode 100644 index 0000000..705d014 --- /dev/null +++ b/iredis/data/commands/script-flush.md @@ -0,0 +1,19 @@ +Flush the Lua scripts cache. + +By default, `SCRIPT FLUSH` will synchronously flush the cache. +Starting with Redis 6.2, setting the **lazyfree-lazy-user-flush** configuration directive to "yes" changes the default flush mode to asynchronous. + +It is possible to use one of the following modifiers to dictate the flushing mode explicitly: + +* `ASYNC`: flushes the cache asynchronously +* `!SYNC`: flushes the cache synchronously + +For more information about `EVAL` scripts please refer to [Introduction to Eval Scripts](/topics/eval-intro). + +@return + +@simple-string-reply + +## Behavior change history + +* `>= 6.2.0`: Default flush behavior now configurable by the **lazyfree-lazy-user-flush** configuration directive.
\ No newline at end of file diff --git a/iredis/data/commands/script-help.md b/iredis/data/commands/script-help.md new file mode 100644 index 0000000..02b7163 --- /dev/null +++ b/iredis/data/commands/script-help.md @@ -0,0 +1,5 @@ +The `SCRIPT HELP` command returns a helpful text describing the different subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/script-kill.md b/iredis/data/commands/script-kill.md new file mode 100644 index 0000000..5b4c646 --- /dev/null +++ b/iredis/data/commands/script-kill.md @@ -0,0 +1,19 @@ +Kills the currently executing `EVAL` script, assuming no write operation was yet +performed by the script. + +This command is mainly useful to kill a script that is running for too much +time(for instance, because it entered an infinite loop because of a bug). +The script will be killed, and the client currently blocked into EVAL will see +the command returning with an error. + +If the script has already performed write operations, it can not be killed in this +way because it would violate Lua's script atomicity contract. +In such a case, only `SHUTDOWN NOSAVE` can kill the script, killing +the Redis process in a hard way and preventing it from persisting with half-written +information. + +For more information about `EVAL` scripts please refer to [Introduction to Eval Scripts](/topics/eval-intro). + +@return + +@simple-string-reply diff --git a/iredis/data/commands/script-load.md b/iredis/data/commands/script-load.md new file mode 100644 index 0000000..ed5ab2d --- /dev/null +++ b/iredis/data/commands/script-load.md @@ -0,0 +1,17 @@ +Load a script into the scripts cache, without executing it. +After the specified command is loaded into the script cache it will be callable +using `EVALSHA` with the correct SHA1 digest of the script, exactly like after +the first successful invocation of `EVAL`. + +The script is guaranteed to stay in the script cache forever (unless `SCRIPT +FLUSH` is called). + +The command works in the same way even if the script was already present in the +script cache. + +For more information about `EVAL` scripts please refer to [Introduction to Eval Scripts](/topics/eval-intro). + +@return + +@bulk-string-reply This command returns the SHA1 digest of the script added into the +script cache. diff --git a/iredis/data/commands/script.md b/iredis/data/commands/script.md new file mode 100644 index 0000000..a7a41d8 --- /dev/null +++ b/iredis/data/commands/script.md @@ -0,0 +1,3 @@ +This is a container command for script management commands. + +To see the list of available commands you can call `SCRIPT HELP`. diff --git a/iredis/data/commands/sdiff.md b/iredis/data/commands/sdiff.md new file mode 100644 index 0000000..5d458ec --- /dev/null +++ b/iredis/data/commands/sdiff.md @@ -0,0 +1,29 @@ +Returns the members of the set resulting from the difference between the first +set and all the successive sets. + +For example: + +``` +key1 = {a,b,c,d} +key2 = {c} +key3 = {a,c,e} +SDIFF key1 key2 key3 = {b,d} +``` + +Keys that do not exist are considered to be empty sets. + +@return + +@array-reply: list with members of the resulting set. + +@examples + +```cli +SADD key1 "a" +SADD key1 "b" +SADD key1 "c" +SADD key2 "c" +SADD key2 "d" +SADD key2 "e" +SDIFF key1 key2 +``` diff --git a/iredis/data/commands/sdiffstore.md b/iredis/data/commands/sdiffstore.md new file mode 100644 index 0000000..e941016 --- /dev/null +++ b/iredis/data/commands/sdiffstore.md @@ -0,0 +1,21 @@ +This command is equal to `SDIFF`, but instead of returning the resulting set, it +is stored in `destination`. + +If `destination` already exists, it is overwritten. + +@return + +@integer-reply: the number of elements in the resulting set. + +@examples + +```cli +SADD key1 "a" +SADD key1 "b" +SADD key1 "c" +SADD key2 "c" +SADD key2 "d" +SADD key2 "e" +SDIFFSTORE key key1 key2 +SMEMBERS key +``` diff --git a/iredis/data/commands/select.md b/iredis/data/commands/select.md new file mode 100644 index 0000000..9ebc04e --- /dev/null +++ b/iredis/data/commands/select.md @@ -0,0 +1,14 @@ +Select the Redis logical database having the specified zero-based numeric index. +New connections always use the database 0. + +Selectable Redis databases are a form of namespacing: all databases are still persisted in the same RDB / AOF file. However different databases can have keys with the same name, and commands like `FLUSHDB`, `SWAPDB` or `RANDOMKEY` work on specific databases. + +In practical terms, Redis databases should be used to separate different keys belonging to the same application (if needed), and not to use a single Redis instance for multiple unrelated applications. + +When using Redis Cluster, the `SELECT` command cannot be used, since Redis Cluster only supports database zero. In the case of a Redis Cluster, having multiple databases would be useless and an unnecessary source of complexity. Commands operating atomically on a single database would not be possible with the Redis Cluster design and goals. + +Since the currently selected database is a property of the connection, clients should track the currently selected database and re-select it on reconnection. While there is no command in order to query the selected database in the current connection, the `CLIENT LIST` output shows, for each client, the currently selected database. + +@return + +@simple-string-reply diff --git a/iredis/data/commands/set.md b/iredis/data/commands/set.md new file mode 100644 index 0000000..6f1ceca --- /dev/null +++ b/iredis/data/commands/set.md @@ -0,0 +1,67 @@ +Set `key` to hold the string `value`. +If `key` already holds a value, it is overwritten, regardless of its type. +Any previous time to live associated with the key is discarded on successful `SET` operation. + +## Options + +The `SET` command supports a set of options that modify its behavior: + +* `EX` *seconds* -- Set the specified expire time, in seconds. +* `PX` *milliseconds* -- Set the specified expire time, in milliseconds. +* `EXAT` *timestamp-seconds* -- Set the specified Unix time at which the key will expire, in seconds. +* `PXAT` *timestamp-milliseconds* -- Set the specified Unix time at which the key will expire, in milliseconds. +* `NX` -- Only set the key if it does not already exist. +* `XX` -- Only set the key if it already exist. +* `KEEPTTL` -- Retain the time to live associated with the key. +* `!GET` -- Return the old string stored at key, or nil if key did not exist. An error is returned and `SET` aborted if the value stored at key is not a string. + +Note: Since the `SET` command options can replace `SETNX`, `SETEX`, `PSETEX`, `GETSET`, it is possible that in future versions of Redis these commands will be deprecated and finally removed. + +@return + +@simple-string-reply: `OK` if `SET` was executed correctly. + +@nil-reply: `(nil)` if the `SET` operation was not performed because the user specified the `NX` or `XX` option but the condition was not met. + +If the command is issued with the `!GET` option, the above does not apply. It will instead reply as follows, regardless if the `SET` was actually performed: + +@bulk-string-reply: the old string value stored at key. + +@nil-reply: `(nil)` if the key did not exist. + +@examples + +```cli +SET mykey "Hello" +GET mykey + +SET anotherkey "will expire in a minute" EX 60 +``` + +## Patterns + +**Note:** The following pattern is discouraged in favor of [the Redlock algorithm](https://redis.io/topics/distlock) which is only a bit more complex to implement, but offers better guarantees and is fault tolerant. + +The command `SET resource-name anystring NX EX max-lock-time` is a simple way to implement a locking system with Redis. + +A client can acquire the lock if the above command returns `OK` (or retry after some time if the command returns Nil), and remove the lock just using `DEL`. + +The lock will be auto-released after the expire time is reached. + +It is possible to make this system more robust modifying the unlock schema as follows: + +* Instead of setting a fixed string, set a non-guessable large random string, called token. +* Instead of releasing the lock with `DEL`, send a script that only removes the key if the value matches. + +This avoids that a client will try to release the lock after the expire time deleting the key created by another client that acquired the lock later. + +An example of unlock script would be similar to the following: + + if redis.call("get",KEYS[1]) == ARGV[1] + then + return redis.call("del",KEYS[1]) + else + return 0 + end + +The script should be called with `EVAL ...script... 1 resource-name token-value` diff --git a/iredis/data/commands/setbit.md b/iredis/data/commands/setbit.md new file mode 100644 index 0000000..e0b440b --- /dev/null +++ b/iredis/data/commands/setbit.md @@ -0,0 +1,161 @@ +Sets or clears the bit at _offset_ in the string value stored at _key_. + +The bit is either set or cleared depending on _value_, which can be either 0 or +1. + +When _key_ does not exist, a new string value is created. +The string is grown to make sure it can hold a bit at _offset_. +The _offset_ argument is required to be greater than or equal to 0, and smaller +than 2^32 (this limits bitmaps to 512MB). +When the string at _key_ is grown, added bits are set to 0. + +**Warning**: When setting the last possible bit (_offset_ equal to 2^32 -1) and +the string value stored at _key_ does not yet hold a string value, or holds a +small string value, Redis needs to allocate all intermediate memory which can +block the server for some time. +On a 2010 MacBook Pro, setting bit number 2^32 -1 (512MB allocation) takes +~300ms, setting bit number 2^30 -1 (128MB allocation) takes ~80ms, setting bit +number 2^28 -1 (32MB allocation) takes ~30ms and setting bit number 2^26 -1 (8MB +allocation) takes ~8ms. +Note that once this first allocation is done, subsequent calls to `SETBIT` for +the same _key_ will not have the allocation overhead. + +@return + +@integer-reply: the original bit value stored at _offset_. + +@examples + +```cli +SETBIT mykey 7 1 +SETBIT mykey 7 0 +GET mykey +``` + +## Pattern: accessing the entire bitmap + +There are cases when you need to set all the bits of single bitmap at once, for +example when initializing it to a default non-zero value. It is possible to do +this with multiple calls to the `SETBIT` command, one for each bit that needs to +be set. However, so as an optimization you can use a single `SET` command to set +the entire bitmap. + +Bitmaps are not an actual data type, but a set of bit-oriented operations +defined on the String type (for more information refer to the +[Bitmaps section of the Data Types Introduction page][ti]). This means that +bitmaps can be used with string commands, and most importantly with `SET` and +`GET`. + +Because Redis' strings are binary-safe, a bitmap is trivially encoded as a bytes +stream. The first byte of the string corresponds to offsets 0..7 of +the bitmap, the second byte to the 8..15 range, and so forth. + +For example, after setting a few bits, getting the string value of the bitmap +would look like this: + +``` +> SETBIT bitmapsarestrings 2 1 +> SETBIT bitmapsarestrings 3 1 +> SETBIT bitmapsarestrings 5 1 +> SETBIT bitmapsarestrings 10 1 +> SETBIT bitmapsarestrings 11 1 +> SETBIT bitmapsarestrings 14 1 +> GET bitmapsarestrings +"42" +``` + +By getting the string representation of a bitmap, the client can then parse the +response's bytes by extracting the bit values using native bit operations in its +native programming language. Symmetrically, it is also possible to set an entire +bitmap by performing the bits-to-bytes encoding in the client and calling `SET` +with the resultant string. + +[ti]: /topics/data-types-intro#bitmaps + +## Pattern: setting multiple bits + +`SETBIT` excels at setting single bits, and can be called several times when +multiple bits need to be set. To optimize this operation you can replace +multiple `SETBIT` calls with a single call to the variadic `BITFIELD` command +and the use of fields of type `u1`. + +For example, the example above could be replaced by: + +``` +> BITFIELD bitsinabitmap SET u1 2 1 SET u1 3 1 SET u1 5 1 SET u1 10 1 SET u1 11 1 SET u1 14 1 +``` + +## Advanced Pattern: accessing bitmap ranges + +It is also possible to use the `GETRANGE` and `SETRANGE` string commands to +efficiently access a range of bit offsets in a bitmap. Below is a sample +implementation in idiomatic Redis Lua scripting that can be run with the `EVAL` +command: + +``` +--[[ +Sets a bitmap range + +Bitmaps are stored as Strings in Redis. A range spans one or more bytes, +so we can call `SETRANGE` when entire bytes need to be set instead of flipping +individual bits. Also, to avoid multiple internal memory allocations in +Redis, we traverse in reverse. +Expected input: + KEYS[1] - bitfield key + ARGV[1] - start offset (0-based, inclusive) + ARGV[2] - end offset (same, should be bigger than start, no error checking) + ARGV[3] - value (should be 0 or 1, no error checking) +]]-- + +-- A helper function to stringify a binary string to semi-binary format +local function tobits(str) + local r = '' + for i = 1, string.len(str) do + local c = string.byte(str, i) + local b = ' ' + for j = 0, 7 do + b = tostring(bit.band(c, 1)) .. b + c = bit.rshift(c, 1) + end + r = r .. b + end + return r +end + +-- Main +local k = KEYS[1] +local s, e, v = tonumber(ARGV[1]), tonumber(ARGV[2]), tonumber(ARGV[3]) + +-- First treat the dangling bits in the last byte +local ms, me = s % 8, (e + 1) % 8 +if me > 0 then + local t = math.max(e - me + 1, s) + for i = e, t, -1 do + redis.call('SETBIT', k, i, v) + end + e = t +end + +-- Then the danglings in the first byte +if ms > 0 then + local t = math.min(s - ms + 7, e) + for i = s, t, 1 do + redis.call('SETBIT', k, i, v) + end + s = t + 1 +end + +-- Set a range accordingly, if at all +local rs, re = s / 8, (e + 1) / 8 +local rl = re - rs +if rl > 0 then + local b = '\255' + if 0 == v then + b = '\0' + end + redis.call('SETRANGE', k, rs, string.rep(b, rl)) +end +``` + +**Note:** the implementation for getting a range of bit offsets from a bitmap is +left as an exercise to the reader. diff --git a/iredis/data/commands/setex.md b/iredis/data/commands/setex.md new file mode 100644 index 0000000..8d8b6b3 --- /dev/null +++ b/iredis/data/commands/setex.md @@ -0,0 +1,27 @@ +Set `key` to hold the string `value` and set `key` to timeout after a given +number of seconds. +This command is equivalent to executing the following commands: + +``` +SET mykey value +EXPIRE mykey seconds +``` + +`SETEX` is atomic, and can be reproduced by using the previous two commands +inside an `MULTI` / `EXEC` block. +It is provided as a faster alternative to the given sequence of operations, +because this operation is very common when Redis is used as a cache. + +An error is returned when `seconds` is invalid. + +@return + +@simple-string-reply + +@examples + +```cli +SETEX mykey 10 "Hello" +TTL mykey +GET mykey +``` diff --git a/iredis/data/commands/setnx.md b/iredis/data/commands/setnx.md new file mode 100644 index 0000000..833573c --- /dev/null +++ b/iredis/data/commands/setnx.md @@ -0,0 +1,99 @@ +Set `key` to hold string `value` if `key` does not exist. +In that case, it is equal to `SET`. +When `key` already holds a value, no operation is performed. +`SETNX` is short for "**SET** if **N**ot e**X**ists". + +@return + +@integer-reply, specifically: + +* `1` if the key was set +* `0` if the key was not set + +@examples + +```cli +SETNX mykey "Hello" +SETNX mykey "World" +GET mykey +``` + +## Design pattern: Locking with `!SETNX` + +**Please note that:** + +1. The following pattern is discouraged in favor of [the Redlock algorithm](https://redis.io/topics/distlock) which is only a bit more complex to implement, but offers better guarantees and is fault tolerant. +2. We document the old pattern anyway because certain existing implementations link to this page as a reference. Moreover it is an interesting example of how Redis commands can be used in order to mount programming primitives. +3. Anyway even assuming a single-instance locking primitive, starting with 2.6.12 it is possible to create a much simpler locking primitive, equivalent to the one discussed here, using the `SET` command to acquire the lock, and a simple Lua script to release the lock. The pattern is documented in the `SET` command page. + +That said, `SETNX` can be used, and was historically used, as a locking primitive. For example, to acquire the lock of the key `foo`, the client could try the +following: + +``` +SETNX lock.foo <current Unix time + lock timeout + 1> +``` + +If `SETNX` returns `1` the client acquired the lock, setting the `lock.foo` key +to the Unix time at which the lock should no longer be considered valid. +The client will later use `DEL lock.foo` in order to release the lock. + +If `SETNX` returns `0` the key is already locked by some other client. +We can either return to the caller if it's a non blocking lock, or enter a loop +retrying to hold the lock until we succeed or some kind of timeout expires. + +### Handling deadlocks + +In the above locking algorithm there is a problem: what happens if a client +fails, crashes, or is otherwise not able to release the lock? +It's possible to detect this condition because the lock key contains a UNIX +timestamp. +If such a timestamp is equal to the current Unix time the lock is no longer +valid. + +When this happens we can't just call `DEL` against the key to remove the lock +and then try to issue a `SETNX`, as there is a race condition here, when +multiple clients detected an expired lock and are trying to release it. + +* C1 and C2 read `lock.foo` to check the timestamp, because they both received + `0` after executing `SETNX`, as the lock is still held by C3 that crashed + after holding the lock. +* C1 sends `DEL lock.foo` +* C1 sends `SETNX lock.foo` and it succeeds +* C2 sends `DEL lock.foo` +* C2 sends `SETNX lock.foo` and it succeeds +* **ERROR**: both C1 and C2 acquired the lock because of the race condition. + +Fortunately, it's possible to avoid this issue using the following algorithm. +Let's see how C4, our sane client, uses the good algorithm: + +* C4 sends `SETNX lock.foo` in order to acquire the lock + +* The crashed client C3 still holds it, so Redis will reply with `0` to C4. + +* C4 sends `GET lock.foo` to check if the lock expired. + If it is not, it will sleep for some time and retry from the start. + +* Instead, if the lock is expired because the Unix time at `lock.foo` is older + than the current Unix time, C4 tries to perform: + + ``` + GETSET lock.foo <current Unix timestamp + lock timeout + 1> + ``` + +* Because of the `GETSET` semantic, C4 can check if the old value stored at + `key` is still an expired timestamp. + If it is, the lock was acquired. + +* If another client, for instance C5, was faster than C4 and acquired the lock + with the `GETSET` operation, the C4 `GETSET` operation will return a non + expired timestamp. + C4 will simply restart from the first step. + Note that even if C4 set the key a bit a few seconds in the future this is + not a problem. + +In order to make this locking algorithm more robust, a +client holding a lock should always check the timeout didn't expire before +unlocking the key with `DEL` because client failures can be complex, not just +crashing but also blocking a lot of time against some operations and trying +to issue `DEL` after a lot of time (when the LOCK is already held by another +client). diff --git a/iredis/data/commands/setrange.md b/iredis/data/commands/setrange.md new file mode 100644 index 0000000..617e3d5 --- /dev/null +++ b/iredis/data/commands/setrange.md @@ -0,0 +1,48 @@ +Overwrites part of the string stored at _key_, starting at the specified offset, +for the entire length of _value_. +If the offset is larger than the current length of the string at _key_, the +string is padded with zero-bytes to make _offset_ fit. +Non-existing keys are considered as empty strings, so this command will make +sure it holds a string large enough to be able to set _value_ at _offset_. + +Note that the maximum offset that you can set is 2^29 -1 (536870911), as Redis +Strings are limited to 512 megabytes. +If you need to grow beyond this size, you can use multiple keys. + +**Warning**: When setting the last possible byte and the string value stored at +_key_ does not yet hold a string value, or holds a small string value, Redis +needs to allocate all intermediate memory which can block the server for some +time. +On a 2010 MacBook Pro, setting byte number 536870911 (512MB allocation) takes +~300ms, setting byte number 134217728 (128MB allocation) takes ~80ms, setting +bit number 33554432 (32MB allocation) takes ~30ms and setting bit number 8388608 +(8MB allocation) takes ~8ms. +Note that once this first allocation is done, subsequent calls to `SETRANGE` for +the same _key_ will not have the allocation overhead. + +## Patterns + +Thanks to `SETRANGE` and the analogous `GETRANGE` commands, you can use Redis +strings as a linear array with O(1) random access. +This is a very fast and efficient storage in many real world use cases. + +@return + +@integer-reply: the length of the string after it was modified by the command. + +@examples + +Basic usage: + +```cli +SET key1 "Hello World" +SETRANGE key1 6 "Redis" +GET key1 +``` + +Example of zero padding: + +```cli +SETRANGE key2 6 "Redis" +GET key2 +``` diff --git a/iredis/data/commands/shutdown.md b/iredis/data/commands/shutdown.md new file mode 100644 index 0000000..5dca6de --- /dev/null +++ b/iredis/data/commands/shutdown.md @@ -0,0 +1,73 @@ +The command behavior is the following: + +* If there are any replicas lagging behind in replication: + * Pause clients attempting to write by performing a `CLIENT PAUSE` with the `WRITE` option. + * Wait up to the configured `shutdown-timeout` (default 10 seconds) for replicas to catch up the replication offset. +* Stop all the clients. +* Perform a blocking SAVE if at least one **save point** is configured. +* Flush the Append Only File if AOF is enabled. +* Quit the server. + +If persistence is enabled this commands makes sure that Redis is switched off +without any data loss. + +Note: A Redis instance that is configured for not persisting on disk (no AOF +configured, nor "save" directive) will not dump the RDB file on `SHUTDOWN`, as +usually you don't want Redis instances used only for caching to block on when +shutting down. + +Also note: If Redis receives one of the signals `SIGTERM` and `SIGINT`, the same shutdown sequence is performed. +See also [Signal Handling](/topics/signals). + +## Modifiers + +It is possible to specify optional modifiers to alter the behavior of the command. +Specifically: + +* **SAVE** will force a DB saving operation even if no save points are configured. +* **NOSAVE** will prevent a DB saving operation even if one or more save points are configured. +* **NOW** skips waiting for lagging replicas, i.e. it bypasses the first step in the shutdown sequence. +* **FORCE** ignores any errors that would normally prevent the server from exiting. + For details, see the following section. +* **ABORT** cancels an ongoing shutdown and cannot be combined with other flags. + +## Conditions where a SHUTDOWN fails + +When a save point is configured or the **SAVE** modifier is specified, the shutdown may fail if the RDB file can't be saved. +Then, the server continues to run in order to ensure no data loss. +This may be bypassed using the **FORCE** modifier, causing the server to exit anyway. + +When the Append Only File is enabled the shutdown may fail because the +system is in a state that does not allow to safely immediately persist +on disk. + +Normally if there is an AOF child process performing an AOF rewrite, Redis +will simply kill it and exit. +However, there are situations where it is unsafe to do so and, unless the **FORCE** modifier is specified, the **SHUTDOWN** command will be refused with an error instead. +This happens in the following situations: + +* The user just turned on AOF, and the server triggered the first AOF rewrite in order to create the initial AOF file. In this context, stopping will result in losing the dataset at all: once restarted, the server will potentially have AOF enabled without having any AOF file at all. +* A replica with AOF enabled, reconnected with its master, performed a full resynchronization, and restarted the AOF file, triggering the initial AOF creation process. In this case not completing the AOF rewrite is dangerous because the latest dataset received from the master would be lost. The new master can actually be even a different instance (if the **REPLICAOF** or **SLAVEOF** command was used in order to reconfigure the replica), so it is important to finish the AOF rewrite and start with the correct data set representing the data set in memory when the server was terminated. + +There are situations when we want just to terminate a Redis instance ASAP, regardless of what its content is. +In such a case, the command **SHUTDOWN NOW NOSAVE FORCE** can be used. +In versions before 7.0, where the **NOW** and **FORCE** flags are not available, the right combination of commands is to send a **CONFIG appendonly no** followed by a **SHUTDOWN NOSAVE**. +The first command will turn off the AOF if needed, and will terminate the AOF rewriting child if there is one active. +The second command will not have any problem to execute since the AOF is no longer enabled. + +## Minimize the risk of data loss + +Since Redis 7.0, the server waits for lagging replicas up to a configurable `shutdown-timeout`, by default 10 seconds, before shutting down. +This provides a best effort minimizing the risk of data loss in a situation where no save points are configured and AOF is disabled. +Before version 7.0, shutting down a heavily loaded master node in a diskless setup was more likely to result in data loss. +To minimize the risk of data loss in such setups, it's advised to trigger a manual `FAILOVER` (or `CLUSTER FAILOVER`) to demote the master to a replica and promote one of the replicas to be the new master, before shutting down a master node. + +@return + +@simple-string-reply: `OK` if `ABORT` was specified and shutdown was aborted. +On successful shutdown, nothing is returned since the server quits and the connection is closed. +On failure, an error is returned. + +## Behavior change history + +* `>= 7.0.0`: Introduced waiting for lagging replicas before exiting.
\ No newline at end of file diff --git a/iredis/data/commands/sinter.md b/iredis/data/commands/sinter.md new file mode 100644 index 0000000..465b3d7 --- /dev/null +++ b/iredis/data/commands/sinter.md @@ -0,0 +1,31 @@ +Returns the members of the set resulting from the intersection of all the given +sets. + +For example: + +``` +key1 = {a,b,c,d} +key2 = {c} +key3 = {a,c,e} +SINTER key1 key2 key3 = {c} +``` + +Keys that do not exist are considered to be empty sets. +With one of the keys being an empty set, the resulting set is also empty (since +set intersection with an empty set always results in an empty set). + +@return + +@array-reply: list with members of the resulting set. + +@examples + +```cli +SADD key1 "a" +SADD key1 "b" +SADD key1 "c" +SADD key2 "c" +SADD key2 "d" +SADD key2 "e" +SINTER key1 key2 +``` diff --git a/iredis/data/commands/sintercard.md b/iredis/data/commands/sintercard.md new file mode 100644 index 0000000..24473e5 --- /dev/null +++ b/iredis/data/commands/sintercard.md @@ -0,0 +1,28 @@ +This command is similar to `SINTER`, but instead of returning the result set, it returns just the cardinality of the result. +Returns the cardinality of the set which would result from the intersection of all the given sets. + +Keys that do not exist are considered to be empty sets. +With one of the keys being an empty set, the resulting set is also empty (since set intersection with an empty set always results in an empty set). + +By default, the command calculates the cardinality of the intersection of all given sets. +When provided with the optional `LIMIT` argument (which defaults to 0 and means unlimited), if the intersection cardinality reaches limit partway through the computation, the algorithm will exit and yield limit as the cardinality. +Such implementation ensures a significant speedup for queries where the limit is lower than the actual intersection cardinality. + +@return + +@integer-reply: the number of elements in the resulting intersection. + +@examples + +```cli +SADD key1 "a" +SADD key1 "b" +SADD key1 "c" +SADD key1 "d" +SADD key2 "c" +SADD key2 "d" +SADD key2 "e" +SINTER key1 key2 +SINTERCARD 2 key1 key2 +SINTERCARD 2 key1 key2 LIMIT 1 +``` diff --git a/iredis/data/commands/sinterstore.md b/iredis/data/commands/sinterstore.md new file mode 100644 index 0000000..17dd0bf --- /dev/null +++ b/iredis/data/commands/sinterstore.md @@ -0,0 +1,21 @@ +This command is equal to `SINTER`, but instead of returning the resulting set, +it is stored in `destination`. + +If `destination` already exists, it is overwritten. + +@return + +@integer-reply: the number of elements in the resulting set. + +@examples + +```cli +SADD key1 "a" +SADD key1 "b" +SADD key1 "c" +SADD key2 "c" +SADD key2 "d" +SADD key2 "e" +SINTERSTORE key key1 key2 +SMEMBERS key +``` diff --git a/iredis/data/commands/sismember.md b/iredis/data/commands/sismember.md new file mode 100644 index 0000000..219cd6e --- /dev/null +++ b/iredis/data/commands/sismember.md @@ -0,0 +1,16 @@ +Returns if `member` is a member of the set stored at `key`. + +@return + +@integer-reply, specifically: + +* `1` if the element is a member of the set. +* `0` if the element is not a member of the set, or if `key` does not exist. + +@examples + +```cli +SADD myset "one" +SISMEMBER myset "one" +SISMEMBER myset "two" +``` diff --git a/iredis/data/commands/slaveof.md b/iredis/data/commands/slaveof.md new file mode 100644 index 0000000..34b9574 --- /dev/null +++ b/iredis/data/commands/slaveof.md @@ -0,0 +1,22 @@ +**A note about the word slave used in this man page and command name**: starting with Redis version 5, if not for backward compatibility, the Redis project no longer uses the word slave. Please use the new command `REPLICAOF`. The command `SLAVEOF` will continue to work for backward compatibility. + +The `SLAVEOF` command can change the replication settings of a replica on the fly. +If a Redis server is already acting as replica, the command `SLAVEOF` NO ONE will +turn off the replication, turning the Redis server into a MASTER. +In the proper form `SLAVEOF` hostname port will make the server a replica of +another server listening at the specified hostname and port. + +If a server is already a replica of some master, `SLAVEOF` hostname port will stop +the replication against the old server and start the synchronization against the +new one, discarding the old dataset. + +The form `SLAVEOF` NO ONE will stop replication, turning the server into a +MASTER, but will not discard the replication. +So, if the old master stops working, it is possible to turn the replica into a +master and set the application to use this new master in read/write. +Later when the other Redis server is fixed, it can be reconfigured to work as a +replica. + +@return + +@simple-string-reply diff --git a/iredis/data/commands/slowlog-get.md b/iredis/data/commands/slowlog-get.md new file mode 100644 index 0000000..d496e39 --- /dev/null +++ b/iredis/data/commands/slowlog-get.md @@ -0,0 +1,26 @@ +The `SLOWLOG GET` command returns entries from the slow log in chronological order. + +The Redis Slow Log is a system to log queries that exceeded a specified execution time. +The execution time does not include I/O operations like talking with the client, sending the reply and so forth, but just the time needed to actually execute the command (this is the only stage of command execution where the thread is blocked and can not serve other requests in the meantime). + +A new entry is added to the slow log whenever a command exceeds the execution time threshold defined by the `slowlog-log-slower-than` configuration directive. +The maximum number of entries in the slow log is governed by the `slowlog-max-len` configuration directive. + +By default the command returns all of the entries in the log. The optional `count` argument limits the number of returned entries, so the command returns at most up to `count` entries. + +Each entry from the slow log is comprised of the following six values: + +1. A unique progressive identifier for every slow log entry. +2. The unix timestamp at which the logged command was processed. +3. The amount of time needed for its execution, in microseconds. +4. The array composing the arguments of the command. +5. Client IP address and port. +6. Client name if set via the `CLIENT SETNAME` command. + +The entry's unique ID can be used in order to avoid processing slow log entries multiple times (for instance you may have a script sending you an email alert for every new slow log entry). +The ID is never reset in the course of the Redis server execution, only a server +restart will reset it. + +@reply + +@array-reply: a list of slow log entries. diff --git a/iredis/data/commands/slowlog-help.md b/iredis/data/commands/slowlog-help.md new file mode 100644 index 0000000..a70f3a5 --- /dev/null +++ b/iredis/data/commands/slowlog-help.md @@ -0,0 +1,5 @@ +The `SLOWLOG HELP` command returns a helpful text describing the different subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/slowlog-len.md b/iredis/data/commands/slowlog-len.md new file mode 100644 index 0000000..6f0d977 --- /dev/null +++ b/iredis/data/commands/slowlog-len.md @@ -0,0 +1,12 @@ +This command returns the current number of entries in the slow log. + +A new entry is added to the slow log whenever a command exceeds the execution time threshold defined by the `slowlog-log-slower-than` configuration directive. +The maximum number of entries in the slow log is governed by the `slowlog-max-len` configuration directive. +Once the slog log reaches its maximal size, the oldest entry is removed whenever a new entry is created. +The slow log can be cleared with the `SLOWLOG RESET` command. + +@reply + +@integer-reply + +The number of entries in the slow log. diff --git a/iredis/data/commands/slowlog-reset.md b/iredis/data/commands/slowlog-reset.md new file mode 100644 index 0000000..b522c26 --- /dev/null +++ b/iredis/data/commands/slowlog-reset.md @@ -0,0 +1,7 @@ +This command resets the slow log, clearing all entries in it. + +Once deleted the information is lost forever. + +@reply + +@simple-string-reply: `OK` diff --git a/iredis/data/commands/slowlog.md b/iredis/data/commands/slowlog.md new file mode 100644 index 0000000..26e5bb7 --- /dev/null +++ b/iredis/data/commands/slowlog.md @@ -0,0 +1,3 @@ +This is a container command for slow log management commands. + +To see the list of available commands you can call `SLOWLOG HELP`. diff --git a/iredis/data/commands/smembers.md b/iredis/data/commands/smembers.md new file mode 100644 index 0000000..2272859 --- /dev/null +++ b/iredis/data/commands/smembers.md @@ -0,0 +1,15 @@ +Returns all the members of the set value stored at `key`. + +This has the same effect as running `SINTER` with one argument `key`. + +@return + +@array-reply: all elements of the set. + +@examples + +```cli +SADD myset "Hello" +SADD myset "World" +SMEMBERS myset +``` diff --git a/iredis/data/commands/smismember.md b/iredis/data/commands/smismember.md new file mode 100644 index 0000000..c4cec64 --- /dev/null +++ b/iredis/data/commands/smismember.md @@ -0,0 +1,16 @@ +Returns whether each `member` is a member of the set stored at `key`. + +For every `member`, `1` is returned if the value is a member of the set, or `0` if the element is not a member of the set or if `key` does not exist. + +@return + +@array-reply: list representing the membership of the given elements, in the same +order as they are requested. + +@examples + +```cli +SADD myset "one" +SADD myset "one" +SMISMEMBER myset "one" "notamember" +``` diff --git a/iredis/data/commands/smove.md b/iredis/data/commands/smove.md new file mode 100644 index 0000000..6b2400b --- /dev/null +++ b/iredis/data/commands/smove.md @@ -0,0 +1,31 @@ +Move `member` from the set at `source` to the set at `destination`. +This operation is atomic. +In every given moment the element will appear to be a member of `source` **or** +`destination` for other clients. + +If the source set does not exist or does not contain the specified element, no +operation is performed and `0` is returned. +Otherwise, the element is removed from the source set and added to the +destination set. +When the specified element already exists in the destination set, it is only +removed from the source set. + +An error is returned if `source` or `destination` does not hold a set value. + +@return + +@integer-reply, specifically: + +* `1` if the element is moved. +* `0` if the element is not a member of `source` and no operation was performed. + +@examples + +```cli +SADD myset "one" +SADD myset "two" +SADD myotherset "three" +SMOVE myset myotherset "two" +SMEMBERS myset +SMEMBERS myotherset +``` diff --git a/iredis/data/commands/sort.md b/iredis/data/commands/sort.md new file mode 100644 index 0000000..2a091db --- /dev/null +++ b/iredis/data/commands/sort.md @@ -0,0 +1,154 @@ +Returns or stores the elements contained in the [list][tdtl], [set][tdts] or +[sorted set][tdtss] at `key`. + +There is also the `SORT_RO` read-only variant of this command. + +By default, sorting is numeric and elements are compared by their value +interpreted as double precision floating point number. +This is `SORT` in its simplest form: + +[tdtl]: /topics/data-types#lists +[tdts]: /topics/data-types#set +[tdtss]: /topics/data-types#sorted-sets + +``` +SORT mylist +``` + +Assuming `mylist` is a list of numbers, this command will return the same list +with the elements sorted from small to large. +In order to sort the numbers from large to small, use the `!DESC` modifier: + +``` +SORT mylist DESC +``` + +When `mylist` contains string values and you want to sort them +lexicographically, use the `!ALPHA` modifier: + +``` +SORT mylist ALPHA +``` + +Redis is UTF-8 aware, assuming you correctly set the `!LC_COLLATE` environment +variable. + +The number of returned elements can be limited using the `!LIMIT` modifier. +This modifier takes the `offset` argument, specifying the number of elements to +skip and the `count` argument, specifying the number of elements to return from +starting at `offset`. +The following example will return 10 elements of the sorted version of `mylist`, +starting at element 0 (`offset` is zero-based): + +``` +SORT mylist LIMIT 0 10 +``` + +Almost all modifiers can be used together. +The following example will return the first 5 elements, lexicographically sorted +in descending order: + +``` +SORT mylist LIMIT 0 5 ALPHA DESC +``` + +## Sorting by external keys + +Sometimes you want to sort elements using external keys as weights to compare +instead of comparing the actual elements in the list, set or sorted set. +Let's say the list `mylist` contains the elements `1`, `2` and `3` representing +unique IDs of objects stored in `object_1`, `object_2` and `object_3`. +When these objects have associated weights stored in `weight_1`, `weight_2` and +`weight_3`, `SORT` can be instructed to use these weights to sort `mylist` with +the following statement: + +``` +SORT mylist BY weight_* +``` + +The `BY` option takes a pattern (equal to `weight_*` in this example) that is +used to generate the keys that are used for sorting. +These key names are obtained substituting the first occurrence of `*` with the +actual value of the element in the list (`1`, `2` and `3` in this example). + +## Skip sorting the elements + +The `!BY` option can also take a non-existent key, which causes `SORT` to skip +the sorting operation. +This is useful if you want to retrieve external keys (see the `!GET` option +below) without the overhead of sorting. + +``` +SORT mylist BY nosort +``` + +## Retrieving external keys + +Our previous example returns just the sorted IDs. +In some cases, it is more useful to get the actual objects instead of their IDs +(`object_1`, `object_2` and `object_3`). +Retrieving external keys based on the elements in a list, set or sorted set can +be done with the following command: + +``` +SORT mylist BY weight_* GET object_* +``` + +The `!GET` option can be used multiple times in order to get more keys for every +element of the original list, set or sorted set. + +It is also possible to `!GET` the element itself using the special pattern `#`: + +``` +SORT mylist BY weight_* GET object_* GET # +``` + +## Restrictions for using external keys + +When enabling `Redis cluster-mode` there is no way to guarantee the existence of the external keys on the node which the command is processed on. +In this case, any use of `GET` or `BY` which reference external key pattern will cause the command to fail with an error. + +Starting from Redis 7.0, any use of `GET` or `BY` which reference external key pattern will only be allowed in case the current user running the command has full key read permissions. +Full key read permissions can be set for the user by, for example, specifying `'%R~*'` or `'~*` with the relevant command access rules. +You can check the `ACL SETUSER` command manual for more information on setting ACL access rules. +If full key read permissions aren't set, the command will fail with an error. + +## Storing the result of a SORT operation + +By default, `SORT` returns the sorted elements to the client. +With the `!STORE` option, the result will be stored as a list at the specified +key instead of being returned to the client. + +``` +SORT mylist BY weight_* STORE resultkey +``` + +An interesting pattern using `SORT ... STORE` consists in associating an +`EXPIRE` timeout to the resulting key so that in applications where the result +of a `SORT` operation can be cached for some time. +Other clients will use the cached list instead of calling `SORT` for every +request. +When the key will timeout, an updated version of the cache can be created by +calling `SORT ... STORE` again. + +Note that for correctly implementing this pattern it is important to avoid +multiple clients rebuilding the cache at the same time. +Some kind of locking is needed here (for instance using `SETNX`). + +## Using hashes in `!BY` and `!GET` + +It is possible to use `!BY` and `!GET` options against hash fields with the +following syntax: + +``` +SORT mylist BY weight_*->fieldname GET object_*->fieldname +``` + +The string `->` is used to separate the key name from the hash field name. +The key is substituted as documented above, and the hash stored at the resulting +key is accessed to retrieve the specified hash field. + +@return + +@array-reply: without passing the `store` option the command returns a list of sorted elements. +@integer-reply: when the `store` option is specified the command returns the number of sorted elements in the destination list. diff --git a/iredis/data/commands/sort_ro.md b/iredis/data/commands/sort_ro.md new file mode 100644 index 0000000..66223a3 --- /dev/null +++ b/iredis/data/commands/sort_ro.md @@ -0,0 +1,17 @@ +Read-only variant of the `SORT` command. It is exactly like the original `SORT` but refuses the `STORE` option and can safely be used in read-only replicas. + +Since the original `SORT` has a `STORE` option it is technically flagged as a writing command in the Redis command table. For this reason read-only replicas in a Redis Cluster will redirect it to the master instance even if the connection is in read-only mode (see the `READONLY` command of Redis Cluster). + +The `SORT_RO` variant was introduced in order to allow `SORT` behavior in read-only replicas without breaking compatibility on command flags. + +See original `SORT` for more details. + +@examples + +``` +SORT_RO mylist BY weight_*->fieldname GET object_*->fieldname +``` + +@return + +@array-reply: a list of sorted elements. diff --git a/iredis/data/commands/spop.md b/iredis/data/commands/spop.md new file mode 100644 index 0000000..8c86a9a --- /dev/null +++ b/iredis/data/commands/spop.md @@ -0,0 +1,34 @@ +Removes and returns one or more random members from the set value store at `key`. + +This operation is similar to `SRANDMEMBER`, that returns one or more random elements from a set but does not remove it. + +By default, the command pops a single member from the set. When provided with +the optional `count` argument, the reply will consist of up to `count` members, +depending on the set's cardinality. + +@return + +When called without the `count` argument: + +@bulk-string-reply: the removed member, or `nil` when `key` does not exist. + +When called with the `count` argument: + +@array-reply: the removed members, or an empty array when `key` does not exist. + +@examples + +```cli +SADD myset "one" +SADD myset "two" +SADD myset "three" +SPOP myset +SMEMBERS myset +SADD myset "four" +SADD myset "five" +SPOP myset 3 +SMEMBERS myset +``` +## Distribution of returned elements + +Note that this command is not suitable when you need a guaranteed uniform distribution of the returned elements. For more information about the algorithms used for `SPOP`, look up both the Knuth sampling and Floyd sampling algorithms. diff --git a/iredis/data/commands/spublish.md b/iredis/data/commands/spublish.md new file mode 100644 index 0000000..e8b6925 --- /dev/null +++ b/iredis/data/commands/spublish.md @@ -0,0 +1,20 @@ +Posts a message to the given shard channel. + +In Redis Cluster, shard channels are assigned to slots by the same algorithm used to assign keys to slots. +A shard message must be sent to a node that own the slot the shard channel is hashed to. +The cluster makes sure that published shard messages are forwarded to all the node in the shard, so clients can subscribe to a shard channel by connecting to any one of the nodes in the shard. + +For more information about sharded pubsub, see [Sharded Pubsub](/topics/pubsub#sharded-pubsub). + +@return + +@integer-reply: the number of clients that received the message. + +@examples + +For example the following command publish to channel `orders` with a subscriber already waiting for message(s). + +``` +> spublish orders hello +(integer) 1 +``` diff --git a/iredis/data/commands/srandmember.md b/iredis/data/commands/srandmember.md new file mode 100644 index 0000000..dd2d4a8 --- /dev/null +++ b/iredis/data/commands/srandmember.md @@ -0,0 +1,46 @@ +When called with just the `key` argument, return a random element from the set value stored at `key`. + +If the provided `count` argument is positive, return an array of **distinct elements**. +The array's length is either `count` or the set's cardinality (`SCARD`), whichever is lower. + +If called with a negative `count`, the behavior changes and the command is allowed to return the **same element multiple times**. +In this case, the number of returned elements is the absolute value of the specified `count`. + +@return + +@bulk-string-reply: without the additional `count` argument, the command returns a Bulk Reply with the randomly selected element, or `nil` when `key` does not exist. + +@array-reply: when the additional `count` argument is passed, the command returns an array of elements, or an empty array when `key` does not exist. + +@examples + +```cli +SADD myset one two three +SRANDMEMBER myset +SRANDMEMBER myset 2 +SRANDMEMBER myset -5 +``` + +## Specification of the behavior when count is passed + +When the `count` argument is a positive value this command behaves as follows: + +* No repeated elements are returned. +* If `count` is bigger than the set's cardinality, the command will only return the whole set without additional elements. +* The order of elements in the reply is not truly random, so it is up to the client to shuffle them if needed. + +When the `count` is a negative value, the behavior changes as follows: + +* Repeating elements are possible. +* Exactly `count` elements, or an empty array if the set is empty (non-existing key), are always returned. +* The order of elements in the reply is truly random. + +## Distribution of returned elements + +Note: this section is relevant only for Redis 5 or below, as Redis 6 implements a fairer algorithm. + +The distribution of the returned elements is far from perfect when the number of elements in the set is small, this is due to the fact that we used an approximated random element function that does not really guarantees good distribution. + +The algorithm used, that is implemented inside dict.c, samples the hash table buckets to find a non-empty one. Once a non empty bucket is found, since we use chaining in our hash table implementation, the number of elements inside the bucket is checked and a random element is selected. + +This means that if you have two non-empty buckets in the entire hash table, and one has three elements while one has just one, the element that is alone in its bucket will be returned with much higher probability. diff --git a/iredis/data/commands/srem.md b/iredis/data/commands/srem.md new file mode 100644 index 0000000..fca5b75 --- /dev/null +++ b/iredis/data/commands/srem.md @@ -0,0 +1,22 @@ +Remove the specified members from the set stored at `key`. +Specified members that are not a member of this set are ignored. +If `key` does not exist, it is treated as an empty set and this command returns +`0`. + +An error is returned when the value stored at `key` is not a set. + +@return + +@integer-reply: the number of members that were removed from the set, not +including non existing members. + +@examples + +```cli +SADD myset "one" +SADD myset "two" +SADD myset "three" +SREM myset "one" +SREM myset "four" +SMEMBERS myset +``` diff --git a/iredis/data/commands/sscan.md b/iredis/data/commands/sscan.md new file mode 100644 index 0000000..c19f3b1 --- /dev/null +++ b/iredis/data/commands/sscan.md @@ -0,0 +1 @@ +See `SCAN` for `SSCAN` documentation. diff --git a/iredis/data/commands/ssubscribe.md b/iredis/data/commands/ssubscribe.md new file mode 100644 index 0000000..bf7d30e --- /dev/null +++ b/iredis/data/commands/ssubscribe.md @@ -0,0 +1,21 @@ +Subscribes the client to the specified shard channels. + +In a Redis cluster, shard channels are assigned to slots by the same algorithm used to assign keys to slots. +Client(s) can subscribe to a node covering a slot (primary/replica) to receive the messages published. +All the specified shard channels needs to belong to a single slot to subscribe in a given `SSUBSCRIBE` call, +A client can subscribe to channels across different slots over separate `SSUBSCRIBE` call. + +For more information about sharded Pub/Sub, see [Sharded Pub/Sub](/topics/pubsub#sharded-pubsub). + +@examples + +``` +> ssubscribe orders +Reading messages... (press Ctrl-C to quit) +1) "ssubscribe" +2) "orders" +3) (integer) 1 +1) "smessage" +2) "orders" +3) "hello" +``` diff --git a/iredis/data/commands/stralgo.md b/iredis/data/commands/stralgo.md new file mode 100644 index 0000000..f3a31dd --- /dev/null +++ b/iredis/data/commands/stralgo.md @@ -0,0 +1,121 @@ +The STRALGO implements complex algorithms that operate on strings. Right now the +only algorithm implemented is the LCS algorithm (longest common substring). +However new algorithms could be implemented in the future. The goal of this +command is to provide to Redis users algorithms that need fast implementations +and are normally not provided in the standard library of most programming +languages. + +The first argument of the command selects the algorithm to use, right now the +argument must be "LCS", since this is the only implemented one. + +## LCS algorithm + +``` +STRALGO LCS STRINGS <string_a> <string_b> | KEYS <key_a> <key_b> [LEN] [IDX] [MINMATCHLEN <len>] [WITHMATCHLEN] +``` + +The LCS subcommand implements the longest common subsequence algorithm. Note +that this is different than the longest common string algorithm, since matching +characters in the string does not need to be contiguous. + +For instance the LCS between "foo" and "fao" is "fo", since scanning the two +strings from left to right, the longest common set of characters is composed of +the first "f" and then the "o". + +LCS is very useful in order to evaluate how similar two strings are. Strings can +represent many things. For instance if two strings are DNA sequences, the LCS +will provide a measure of similarity between the two DNA sequences. If the +strings represent some text edited by some user, the LCS could represent how +different the new text is compared to the old one, and so forth. + +Note that this algorithm runs in `O(N*M)` time, where N is the length of the +first string and M is the length of the second string. So either spin a +different Redis instance in order to run this algorithm, or make sure to run it +against very small strings. + +The basic usage is the following: + +``` +> STRALGO LCS STRINGS ohmytext mynewtext +"mytext" +``` + +It is also possible to compute the LCS between the content of two keys: + +``` +> MSET key1 ohmytext key2 mynewtext +OK +> STRALGO LCS KEYS key1 key2 +"mytext" +``` + +Sometimes we need just the length of the match: + +``` +> STRALGO LCS STRINGS ohmytext mynewtext LEN +6 +``` + +However what is often very useful, is to know the match position in each +strings: + +``` +> STRALGO LCS KEYS key1 key2 IDX +1) "matches" +2) 1) 1) 1) (integer) 4 + 2) (integer) 7 + 2) 1) (integer) 5 + 2) (integer) 8 + 2) 1) 1) (integer) 2 + 2) (integer) 3 + 2) 1) (integer) 0 + 2) (integer) 1 +3) "len" +4) (integer) 6 +``` + +Matches are produced from the last one to the first one, since this is how the +algorithm works, and it more efficient to emit things in the same order. The +above array means that the first match (second element of the array) is between +positions 2-3 of the first string and 0-1 of the second. Then there is another +match between 4-7 and 5-8. + +To restrict the list of matches to the ones of a given minimal length: + +``` +> STRALGO LCS KEYS key1 key2 IDX MINMATCHLEN 4 +1) "matches" +2) 1) 1) 1) (integer) 4 + 2) (integer) 7 + 2) 1) (integer) 5 + 2) (integer) 8 +3) "len" +4) (integer) 6 +``` + +Finally to also have the match len: + +``` +> STRALGO LCS KEYS key1 key2 IDX MINMATCHLEN 4 WITHMATCHLEN +1) "matches" +2) 1) 1) 1) (integer) 4 + 2) (integer) 7 + 2) 1) (integer) 5 + 2) (integer) 8 + 3) (integer) 4 +3) "len" +4) (integer) 6 +``` + +@return + +For the LCS algorithm: + +- Without modifiers the string representing the longest common substring is + returned. +- When `LEN` is given the command returns the length of the longest common + substring. +- When `IDX` is given the command returns an array with the LCS length and all + the ranges in both the strings, start and end offset for each string, where + there are matches. When `WITHMATCHLEN` is given each array representing a + match will also have the length of the match (see examples). diff --git a/iredis/data/commands/strlen.md b/iredis/data/commands/strlen.md new file mode 100644 index 0000000..e504180 --- /dev/null +++ b/iredis/data/commands/strlen.md @@ -0,0 +1,15 @@ +Returns the length of the string value stored at `key`. +An error is returned when `key` holds a non-string value. + +@return + +@integer-reply: the length of the string at `key`, or `0` when `key` does not +exist. + +@examples + +```cli +SET mykey "Hello world" +STRLEN mykey +STRLEN nonexisting +``` diff --git a/iredis/data/commands/subscribe.md b/iredis/data/commands/subscribe.md new file mode 100644 index 0000000..bbc7127 --- /dev/null +++ b/iredis/data/commands/subscribe.md @@ -0,0 +1,9 @@ +Subscribes the client to the specified channels. + +Once the client enters the subscribed state it is not supposed to issue any +other commands, except for additional `SUBSCRIBE`, `SSUBSCRIBE`, `PSUBSCRIBE`, `UNSUBSCRIBE`, `SUNSUBSCRIBE`, +`PUNSUBSCRIBE`, `PING`, `RESET` and `QUIT` commands. + +## Behavior change history + +* `>= 6.2.0`: `RESET` can be called to exit subscribed state.
\ No newline at end of file diff --git a/iredis/data/commands/substr.md b/iredis/data/commands/substr.md new file mode 100644 index 0000000..7283def --- /dev/null +++ b/iredis/data/commands/substr.md @@ -0,0 +1,22 @@ +Returns the substring of the string value stored at `key`, determined by the +offsets `start` and `end` (both are inclusive). +Negative offsets can be used in order to provide an offset starting from the end +of the string. +So -1 means the last character, -2 the penultimate and so forth. + +The function handles out of range requests by limiting the resulting range to +the actual length of the string. + +@return + +@bulk-string-reply + +@examples + +```cli +SET mykey "This is a string" +GETRANGE mykey 0 3 +GETRANGE mykey -3 -1 +GETRANGE mykey 0 -1 +GETRANGE mykey 10 100 +``` diff --git a/iredis/data/commands/sunion.md b/iredis/data/commands/sunion.md new file mode 100644 index 0000000..2056468 --- /dev/null +++ b/iredis/data/commands/sunion.md @@ -0,0 +1,28 @@ +Returns the members of the set resulting from the union of all the given sets. + +For example: + +``` +key1 = {a,b,c,d} +key2 = {c} +key3 = {a,c,e} +SUNION key1 key2 key3 = {a,b,c,d,e} +``` + +Keys that do not exist are considered to be empty sets. + +@return + +@array-reply: list with members of the resulting set. + +@examples + +```cli +SADD key1 "a" +SADD key1 "b" +SADD key1 "c" +SADD key2 "c" +SADD key2 "d" +SADD key2 "e" +SUNION key1 key2 +``` diff --git a/iredis/data/commands/sunionstore.md b/iredis/data/commands/sunionstore.md new file mode 100644 index 0000000..716caf1 --- /dev/null +++ b/iredis/data/commands/sunionstore.md @@ -0,0 +1,21 @@ +This command is equal to `SUNION`, but instead of returning the resulting set, +it is stored in `destination`. + +If `destination` already exists, it is overwritten. + +@return + +@integer-reply: the number of elements in the resulting set. + +@examples + +```cli +SADD key1 "a" +SADD key1 "b" +SADD key1 "c" +SADD key2 "c" +SADD key2 "d" +SADD key2 "e" +SUNIONSTORE key key1 key2 +SMEMBERS key +``` diff --git a/iredis/data/commands/sunsubscribe.md b/iredis/data/commands/sunsubscribe.md new file mode 100644 index 0000000..7ce76c3 --- /dev/null +++ b/iredis/data/commands/sunsubscribe.md @@ -0,0 +1,8 @@ +Unsubscribes the client from the given shard channels, or from all of them if none is given. + +When no shard channels are specified, the client is unsubscribed from all the previously subscribed shard channels. +In this case a message for every unsubscribed shard channel will be sent to the client. + +Note: The global channels and shard channels needs to be unsubscribed from separately. + +For more information about sharded Pub/Sub, see [Sharded Pub/Sub](/topics/pubsub#sharded-pubsub). diff --git a/iredis/data/commands/swapdb.md b/iredis/data/commands/swapdb.md new file mode 100644 index 0000000..ead2db0 --- /dev/null +++ b/iredis/data/commands/swapdb.md @@ -0,0 +1,17 @@ +This command swaps two Redis databases, so that immediately all the +clients connected to a given database will see the data of the other database, and +the other way around. Example: + + SWAPDB 0 1 + +This will swap database 0 with database 1. All the clients connected with database 0 will immediately see the new data, exactly like all the clients connected with database 1 will see the data that was formerly of database 0. + +@return + +@simple-string-reply: `OK` if `SWAPDB` was executed correctly. + +@examples + +``` +SWAPDB 0 1 +``` diff --git a/iredis/data/commands/sync.md b/iredis/data/commands/sync.md new file mode 100644 index 0000000..cb95847 --- /dev/null +++ b/iredis/data/commands/sync.md @@ -0,0 +1,14 @@ +Initiates a replication stream from the master. + +The `SYNC` command is called by Redis replicas for initiating a replication +stream from the master. It has been replaced in newer versions of Redis by + `PSYNC`. + +For more information about replication in Redis please check the +[replication page][tr]. + +[tr]: /topics/replication + +@return + +**Non standard return value**, a bulk transfer of the data followed by `PING` and write requests from the master. diff --git a/iredis/data/commands/time.md b/iredis/data/commands/time.md new file mode 100644 index 0000000..2cf1af6 --- /dev/null +++ b/iredis/data/commands/time.md @@ -0,0 +1,20 @@ +The `TIME` command returns the current server time as a two items lists: a Unix +timestamp and the amount of microseconds already elapsed in the current second. +Basically the interface is very similar to the one of the `gettimeofday` system +call. + +@return + +@array-reply, specifically: + +A multi bulk reply containing two elements: + +* unix time in seconds. +* microseconds. + +@examples + +```cli +TIME +TIME +``` diff --git a/iredis/data/commands/touch.md b/iredis/data/commands/touch.md new file mode 100644 index 0000000..a369354 --- /dev/null +++ b/iredis/data/commands/touch.md @@ -0,0 +1,14 @@ +Alters the last access time of a key(s). +A key is ignored if it does not exist. + +@return + +@integer-reply: The number of keys that were touched. + +@examples + +```cli +SET key1 "Hello" +SET key2 "World" +TOUCH key1 key2 +``` diff --git a/iredis/data/commands/ttl.md b/iredis/data/commands/ttl.md new file mode 100644 index 0000000..15821e1 --- /dev/null +++ b/iredis/data/commands/ttl.md @@ -0,0 +1,24 @@ +Returns the remaining time to live of a key that has a timeout. +This introspection capability allows a Redis client to check how many seconds a +given key will continue to be part of the dataset. + +In Redis 2.6 or older the command returns `-1` if the key does not exist or if the key exist but has no associated expire. + +Starting with Redis 2.8 the return value in case of error changed: + +* The command returns `-2` if the key does not exist. +* The command returns `-1` if the key exists but has no associated expire. + +See also the `PTTL` command that returns the same information with milliseconds resolution (Only available in Redis 2.6 or greater). + +@return + +@integer-reply: TTL in seconds, or a negative value in order to signal an error (see the description above). + +@examples + +```cli +SET mykey "Hello" +EXPIRE mykey 10 +TTL mykey +``` diff --git a/iredis/data/commands/type.md b/iredis/data/commands/type.md new file mode 100644 index 0000000..8a818e0 --- /dev/null +++ b/iredis/data/commands/type.md @@ -0,0 +1,18 @@ +Returns the string representation of the type of the value stored at `key`. +The different types that can be returned are: `string`, `list`, `set`, `zset`, +`hash` and `stream`. + +@return + +@simple-string-reply: type of `key`, or `none` when `key` does not exist. + +@examples + +```cli +SET key1 "value" +LPUSH key2 "value" +SADD key3 "value" +TYPE key1 +TYPE key2 +TYPE key3 +``` diff --git a/iredis/data/commands/unlink.md b/iredis/data/commands/unlink.md new file mode 100644 index 0000000..c91dd66 --- /dev/null +++ b/iredis/data/commands/unlink.md @@ -0,0 +1,18 @@ +This command is very similar to `DEL`: it removes the specified keys. +Just like `DEL` a key is ignored if it does not exist. However the command +performs the actual memory reclaiming in a different thread, so it is not +blocking, while `DEL` is. This is where the command name comes from: the +command just **unlinks** the keys from the keyspace. The actual removal +will happen later asynchronously. + +@return + +@integer-reply: The number of keys that were unlinked. + +@examples + +```cli +SET key1 "Hello" +SET key2 "World" +UNLINK key1 key2 key3 +``` diff --git a/iredis/data/commands/unsubscribe.md b/iredis/data/commands/unsubscribe.md new file mode 100644 index 0000000..7bdf1d1 --- /dev/null +++ b/iredis/data/commands/unsubscribe.md @@ -0,0 +1,7 @@ +Unsubscribes the client from the given channels, or from all of them if none is +given. + +When no channels are specified, the client is unsubscribed from all the +previously subscribed channels. +In this case, a message for every unsubscribed channel will be sent to the +client. diff --git a/iredis/data/commands/unwatch.md b/iredis/data/commands/unwatch.md new file mode 100644 index 0000000..b60bcb8 --- /dev/null +++ b/iredis/data/commands/unwatch.md @@ -0,0 +1,9 @@ +Flushes all the previously watched keys for a [transaction][tt]. + +[tt]: /topics/transactions + +If you call `EXEC` or `DISCARD`, there's no need to manually call `UNWATCH`. + +@return + +@simple-string-reply: always `OK`. diff --git a/iredis/data/commands/wait.md b/iredis/data/commands/wait.md new file mode 100644 index 0000000..d3636ae --- /dev/null +++ b/iredis/data/commands/wait.md @@ -0,0 +1,55 @@ +This command blocks the current client until all the previous write commands +are successfully transferred and acknowledged by at least the specified number +of replicas. If the timeout, specified in milliseconds, is reached, the command +returns even if the specified number of replicas were not yet reached. + +The command **will always return** the number of replicas that acknowledged +the write commands sent before the `WAIT` command, both in the case where +the specified number of replicas are reached, or when the timeout is reached. + +A few remarks: + +1. When `WAIT` returns, all the previous write commands sent in the context of the current connection are guaranteed to be received by the number of replicas returned by `WAIT`. +2. If the command is sent as part of a `MULTI` transaction, the command does not block but instead just return ASAP the number of replicas that acknowledged the previous write commands. +3. A timeout of 0 means to block forever. +4. Since `WAIT` returns the number of replicas reached both in case of failure and success, the client should check that the returned value is equal or greater to the replication level it demanded. + +Consistency and WAIT +--- + +Note that `WAIT` does not make Redis a strongly consistent store: while synchronous replication is part of a replicated state machine, it is not the only thing needed. However in the context of Sentinel or Redis Cluster failover, `WAIT` improves the real world data safety. + +Specifically if a given write is transferred to one or more replicas, it is more likely (but not guaranteed) that if the master fails, we'll be able to promote, during a failover, a replica that received the write: both Sentinel and Redis Cluster will do a best-effort attempt to promote the best replica among the set of available replicas. + +However this is just a best-effort attempt so it is possible to still lose a write synchronously replicated to multiple replicas. + +Implementation details +--- + +Since the introduction of partial resynchronization with replicas (PSYNC feature) Redis replicas asynchronously ping their master with the offset they already processed in the replication stream. This is used in multiple ways: + +1. Detect timed out replicas. +2. Perform a partial resynchronization after a disconnection. +3. Implement `WAIT`. + +In the specific case of the implementation of `WAIT`, Redis remembers, for each client, the replication offset of the produced replication stream when a given +write command was executed in the context of a given client. When `WAIT` is +called Redis checks if the specified number of replicas already acknowledged +this offset or a greater one. + +@return + +@integer-reply: The command returns the number of replicas reached by all the writes performed in the context of the current connection. + +@examples + +``` +> SET foo bar +OK +> WAIT 1 0 +(integer) 1 +> WAIT 2 1000 +(integer) 1 +``` + +In the following example the first call to `WAIT` does not use a timeout and asks for the write to reach 1 replica. It returns with success. In the second attempt instead we put a timeout, and ask for the replication of the write to two replicas. Since there is a single replica available, after one second `WAIT` unblocks and returns 1, the number of replicas reached. diff --git a/iredis/data/commands/watch.md b/iredis/data/commands/watch.md new file mode 100644 index 0000000..08f823f --- /dev/null +++ b/iredis/data/commands/watch.md @@ -0,0 +1,8 @@ +Marks the given keys to be watched for conditional execution of a +[transaction][tt]. + +[tt]: /topics/transactions + +@return + +@simple-string-reply: always `OK`. diff --git a/iredis/data/commands/xack.md b/iredis/data/commands/xack.md new file mode 100644 index 0000000..aae2db5 --- /dev/null +++ b/iredis/data/commands/xack.md @@ -0,0 +1,31 @@ +The `XACK` command removes one or multiple messages from the +*Pending Entries List* (PEL) of a stream consumer group. A message is pending, +and as such stored inside the PEL, when it was delivered to some consumer, +normally as a side effect of calling `XREADGROUP`, or when a consumer took +ownership of a message calling `XCLAIM`. The pending message was delivered to +some consumer but the server is yet not sure it was processed at least once. +So new calls to `XREADGROUP` to grab the messages history for a consumer +(for instance using an ID of 0), will return such message. +Similarly the pending message will be listed by the `XPENDING` command, +that inspects the PEL. + +Once a consumer *successfully* processes a message, it should call `XACK` +so that such message does not get processed again, and as a side effect, +the PEL entry about this message is also purged, releasing memory from the +Redis server. + +@return + +@integer-reply, specifically: + +The command returns the number of messages successfully acknowledged. +Certain message IDs may no longer be part of the PEL (for example because +they have already been acknowledged), and XACK will not count them as +successfully acknowledged. + +@examples + +``` +redis> XACK mystream mygroup 1526569495631-0 +(integer) 1 +``` diff --git a/iredis/data/commands/xadd.md b/iredis/data/commands/xadd.md new file mode 100644 index 0000000..d651a68 --- /dev/null +++ b/iredis/data/commands/xadd.md @@ -0,0 +1,93 @@ +Appends the specified stream entry to the stream at the specified key. +If the key does not exist, as a side effect of running this command the +key is created with a stream value. The creation of stream's key can be +disabled with the `NOMKSTREAM` option. + +An entry is composed of a list of field-value pairs. +The field-value pairs are stored in the same order they are given by the user. +Commands that read the stream, such as `XRANGE` or `XREAD`, are guaranteed to return the fields and values exactly in the same order they were added by `XADD`. + +`XADD` is the *only Redis command* that can add data to a stream, but +there are other commands, such as `XDEL` and `XTRIM`, that are able to +remove data from a stream. + +## Specifying a Stream ID as an argument + +A stream entry ID identifies a given entry inside a stream. + +The `XADD` command will auto-generate a unique ID for you if the ID argument +specified is the `*` character (asterisk ASCII character). However, while +useful only in very rare cases, it is possible to specify a well-formed ID, so +that the new entry will be added exactly with the specified ID. + +IDs are specified by two numbers separated by a `-` character: + + 1526919030474-55 + +Both quantities are 64-bit numbers. When an ID is auto-generated, the +first part is the Unix time in milliseconds of the Redis instance generating +the ID. The second part is just a sequence number and is used in order to +distinguish IDs generated in the same millisecond. + +You can also specify an incomplete ID, that consists only of the milliseconds part, which is interpreted as a zero value for sequence part. +To have only the sequence part automatically generated, specify the milliseconds part followed by the `-` separator and the `*` character: + +``` +> XADD mystream 1526919030474-55 message "Hello," +"1526919030474-55" +> XADD mystream 1526919030474-* message " World!" +"1526919030474-56" +``` + +IDs are guaranteed to be always incremental: If you compare the ID of the +entry just inserted it will be greater than any other past ID, so entries +are totally ordered inside a stream. In order to guarantee this property, +if the current top ID in the stream has a time greater than the current +local time of the instance, the top entry time will be used instead, and +the sequence part of the ID incremented. This may happen when, for instance, +the local clock jumps backward, or if after a failover the new master has +a different absolute time. + +When a user specified an explicit ID to `XADD`, the minimum valid ID is +`0-1`, and the user *must* specify an ID which is greater than any other +ID currently inside the stream, otherwise the command will fail and return an error. Usually +resorting to specific IDs is useful only if you have another system generating +unique IDs (for instance an SQL table) and you really want the Redis stream +IDs to match the one of this other system. + +## Capped streams + +`XADD` incorporates the same semantics as the `XTRIM` command - refer to its documentation page for more information. +This allows adding new entries and keeping the stream's size in check with a single call to `XADD`, effectively capping the stream with an arbitrary threshold. +Although exact trimming is possible and is the default, due to the internal representation of steams it is more efficient to add an entry and trim stream with `XADD` using **almost exact** trimming (the `~` argument). + +For example, calling `XADD` in the following form: + + XADD mystream MAXLEN ~ 1000 * ... entry fields here ... + +Will add a new entry but will also evict old entries so that the stream will contain only 1000 entries, or at most a few tens more. + +## Additional information about streams + +For further information about Redis streams please check our +[introduction to Redis Streams document](/topics/streams-intro). + +@return + +@bulk-string-reply, specifically: + +The command returns the ID of the added entry. The ID is the one auto-generated +if `*` is passed as ID argument, otherwise the command just returns the same ID +specified by the user during insertion. + +The command returns a @nil-reply when used with the `NOMKSTREAM` option and the +key doesn't exist. + +@examples + +```cli +XADD mystream * name Sara surname OConnor +XADD mystream * field1 value1 field2 value2 field3 value3 +XLEN mystream +XRANGE mystream - + +``` diff --git a/iredis/data/commands/xautoclaim.md b/iredis/data/commands/xautoclaim.md new file mode 100644 index 0000000..5ff44f2 --- /dev/null +++ b/iredis/data/commands/xautoclaim.md @@ -0,0 +1,52 @@ +This command transfers ownership of pending stream entries that match the specified criteria. Conceptually, `XAUTOCLAIM` is equivalent to calling `XPENDING` and then `XCLAIM`, +but provides a more straightforward way to deal with message delivery failures via `SCAN`-like semantics. + +Like `XCLAIM`, the command operates on the stream entries at `<key>` and in the context of the provided `<group>`. +It transfers ownership to `<consumer>` of messages pending for more than `<min-idle-time>` milliseconds and having an equal or greater ID than `<start>`. + +The optional `<count>` argument, which defaults to 100, is the upper limit of the number of entries that the command attempts to claim. +Internally, the command begins scanning the consumer group's Pending Entries List (PEL) from `<start>` and filters out entries having an idle time less than or equal to `<min-idle-time>`. +The maximum number of pending entries that the command scans is the product of multiplying `<count>`'s value by 10 (hard-coded). +It is possible, therefore, that the number of entries claimed will be less than the specified value. + +The optional `JUSTID` argument changes the reply to return just an array of IDs of messages successfully claimed, without returning the actual message. +Using this option means the retry counter is not incremented. + +The command returns the claimed entries as an array. It also returns a stream ID intended for cursor-like use as the `<start>` argument for its subsequent call. +When there are no remaining PEL entries, the command returns the special `0-0` ID to signal completion. +However, note that you may want to continue calling `XAUTOCLAIM` even after the scan is complete with the `0-0` as `<start>` ID, because enough time passed, so older pending entries may now be eligible for claiming. + +Note that only messages that are idle longer than `<min-idle-time>` are claimed, and claiming a message resets its idle time. +This ensures that only a single consumer can successfully claim a given pending message at a specific instant of time and trivially reduces the probability of processing the same message multiple times. + +While iterating the PEL, if `XAUTOCLAIM` stumbles upon a message which doesn't exist in the stream anymore (either trimmed or deleted by `XDEL`) it does not claim it, and deletes it from the PEL in which it was found. This feature was introduced in Redis 7.0. +These message IDs are returned to the caller as a part of `XAUTOCLAIM`s reply. + +Lastly, claiming a message with `XAUTOCLAIM` also increments the attempted deliveries count for that message, unless the `JUSTID` option has been specified (which only delivers the message ID, not the message itself). +Messages that cannot be processed for some reason - for example, because consumers systematically crash when processing them - will exhibit high attempted delivery counts that can be detected by monitoring. + +@return + +@array-reply, specifically: + +An array with three elements: + +1. A stream ID to be used as the `<start>` argument for the next call to `XAUTOCLAIM`. +2. An array containing all the successfully claimed messages in the same format as `XRANGE`. +3. An array containing message IDs that no longer exist in the stream, and were deleted from the PEL in which they were found. + +@examples + +``` +> XAUTOCLAIM mystream mygroup Alice 3600000 0-0 COUNT 25 +1) "0-0" +2) 1) 1) "1609338752495-0" + 2) 1) "field" + 2) "value" +3) (empty array) +``` + +In the above example, we attempt to claim up to 25 entries that are pending and idle (not having been acknowledged or claimed) for at least an hour, starting at the stream's beginning. +The consumer "Alice" from the "mygroup" group acquires ownership of these messages. +Note that the stream ID returned in the example is `0-0`, indicating that the entire stream was scanned. +We can also see that `XAUTOCLAIM` did not stumble upon any deleted messages (the third reply element is an empty array). diff --git a/iredis/data/commands/xclaim.md b/iredis/data/commands/xclaim.md new file mode 100644 index 0000000..d3a17dc --- /dev/null +++ b/iredis/data/commands/xclaim.md @@ -0,0 +1,55 @@ +In the context of a stream consumer group, this command changes the ownership +of a pending message, so that the new owner is the consumer specified as the +command argument. Normally this is what happens: + +1. There is a stream with an associated consumer group. +2. Some consumer A reads a message via `XREADGROUP` from a stream, in the context of that consumer group. +3. As a side effect a pending message entry is created in the Pending Entries List (PEL) of the consumer group: it means the message was delivered to a given consumer, but it was not yet acknowledged via `XACK`. +4. Then suddenly that consumer fails forever. +5. Other consumers may inspect the list of pending messages, that are stale for quite some time, using the `XPENDING` command. In order to continue processing such messages, they use `XCLAIM` to acquire the ownership of the message and continue. Consumers can also use the `XAUTOCLAIM` command to automatically scan and claim stale pending messages. + +This dynamic is clearly explained in the [Stream intro documentation](/topics/streams-intro). + +Note that the message is claimed only if its idle time is greater the minimum idle time we specify when calling `XCLAIM`. Because as a side effect `XCLAIM` will also reset the idle time (since this is a new attempt at processing the message), two consumers trying to claim a message at the same time will never both succeed: only one will successfully claim the message. This avoids that we process a given message multiple times in a trivial way (yet multiple processing is possible and unavoidable in the general case). + +Moreover, as a side effect, `XCLAIM` will increment the count of attempted deliveries of the message unless the `JUSTID` option has been specified (which only delivers the message ID, not the message itself). In this way messages that cannot be processed for some reason, for instance because the consumers crash attempting to process them, will start to have a larger counter and can be detected inside the system. + +`XCLAIM` will not claim a message in the following cases: + +1. The message doesn't exist in the group PEL (i.e. it was never read by any consumer) +2. The message exists in the group PEL but not in the stream itself (i.e. the message was read but never acknowledged, and then was deleted from the stream, either by trimming or by `XDEL`) + +In both cases the reply will not contain a corresponding entry to that message (i.e. the length of the reply array may be smaller than the number of IDs provided to `XCLAIM`). +In the latter case, the message will also be deleted from the PEL in which it was found. This feature was introduced in Redis 7.0. + +## Command options + +The command has multiple options, however most are mainly for internal use in +order to transfer the effects of `XCLAIM` or other commands to the AOF file +and to propagate the same effects to the replicas, and are unlikely to be +useful to normal users: + +1. `IDLE <ms>`: Set the idle time (last time it was delivered) of the message. If IDLE is not specified, an IDLE of 0 is assumed, that is, the time count is reset because the message has now a new owner trying to process it. +2. `TIME <ms-unix-time>`: This is the same as IDLE but instead of a relative amount of milliseconds, it sets the idle time to a specific Unix time (in milliseconds). This is useful in order to rewrite the AOF file generating `XCLAIM` commands. +3. `RETRYCOUNT <count>`: Set the retry counter to the specified value. This counter is incremented every time a message is delivered again. Normally `XCLAIM` does not alter this counter, which is just served to clients when the XPENDING command is called: this way clients can detect anomalies, like messages that are never processed for some reason after a big number of delivery attempts. +4. `FORCE`: Creates the pending message entry in the PEL even if certain specified IDs are not already in the PEL assigned to a different client. However the message must be exist in the stream, otherwise the IDs of non existing messages are ignored. +5. `JUSTID`: Return just an array of IDs of messages successfully claimed, without returning the actual message. Using this option means the retry counter is not incremented. + +@return + +@array-reply, specifically: + +The command returns all the messages successfully claimed, in the same format +as `XRANGE`. However if the `JUSTID` option was specified, only the message +IDs are reported, without including the actual message. + +@examples + +``` +> XCLAIM mystream mygroup Alice 3600000 1526569498055-0 +1) 1) 1526569498055-0 + 2) 1) "message" + 2) "orange" +``` + +In the above example we claim the message with ID `1526569498055-0`, only if the message is idle for at least one hour without the original consumer or some other consumer making progresses (acknowledging or claiming it), and assigns the ownership to the consumer `Alice`. diff --git a/iredis/data/commands/xdel.md b/iredis/data/commands/xdel.md new file mode 100644 index 0000000..3ee4a3d --- /dev/null +++ b/iredis/data/commands/xdel.md @@ -0,0 +1,51 @@ +Removes the specified entries from a stream, and returns the number of entries +deleted. This number may be less than the number of IDs passed to the command in +the case where some of the specified IDs do not exist in the stream. + +Normally you may think at a Redis stream as an append-only data structure, +however Redis streams are represented in memory, so we are also able to +delete entries. This may be useful, for instance, in order to comply with +certain privacy policies. + +## Understanding the low level details of entries deletion + +Redis streams are represented in a way that makes them memory efficient: +a radix tree is used in order to index macro-nodes that pack linearly tens +of stream entries. Normally what happens when you delete an entry from a stream +is that the entry is not *really* evicted, it just gets marked as deleted. + +Eventually if all the entries in a macro-node are marked as deleted, the whole +node is destroyed and the memory reclaimed. This means that if you delete +a large amount of entries from a stream, for instance more than 50% of the +entries appended to the stream, the memory usage per entry may increment, since +what happens is that the stream will become fragmented. However the stream +performance will remain the same. + +In future versions of Redis it is possible that we'll trigger a node garbage +collection in case a given macro-node reaches a given amount of deleted +entries. Currently with the usage we anticipate for this data structure, it is +not a good idea to add such complexity. + +@return + +@integer-reply: the number of entries actually deleted. + +@examples + +``` +> XADD mystream * a 1 +1538561698944-0 +> XADD mystream * b 2 +1538561700640-0 +> XADD mystream * c 3 +1538561701744-0 +> XDEL mystream 1538561700640-0 +(integer) 1 +127.0.0.1:6379> XRANGE mystream - + +1) 1) 1538561698944-0 + 2) 1) "a" + 2) "1" +2) 1) 1538561701744-0 + 2) 1) "c" + 2) "3" +``` diff --git a/iredis/data/commands/xgroup-create.md b/iredis/data/commands/xgroup-create.md new file mode 100644 index 0000000..f0f1606 --- /dev/null +++ b/iredis/data/commands/xgroup-create.md @@ -0,0 +1,23 @@ +This command creates a new consumer group uniquely identified by `<groupname>` for the stream stored at `<key>`. + +Every group has a unique name in a given stream. When a consumer group with the same name already exists, the command returns a `-BUSYGROUP` error. + +The command's `<id>` argument specifies the last delivered entry in the stream from the new group's perspective. +The special ID `$` means the ID of the last entry in the stream, but you can provide any valid ID instead. +For example, if you want the group's consumers to fetch the entire stream from the beginning, use zero as the starting ID for the consumer group: + + XGROUP CREATE mystream mygroup 0 + +By default, the `XGROUP CREATE` command insists that the target stream exists and returns an error when it doesn't. +However, you can use the optional `MKSTREAM` subcommand as the last argument after the `<id>` to automatically create the stream (with length of 0) if it doesn't exist: + + XGROUP CREATE mystream mygroup $ MKSTREAM + +The optional `entries_read` named argument can be specified to enable consumer group lag tracking for an arbitrary ID. +An arbitrary ID is any ID that isn't the ID of the stream's first entry, its last entry or the zero ("0-0") ID. +This can be useful you know exactly how many entries are between the arbitrary ID (excluding it) and the stream's last entry. +In such cases, the `entries_read` can be set to the stream's `entries_added` subtracted with the number of entries. + +@return + +@simple-string-reply: `OK` on success. diff --git a/iredis/data/commands/xgroup-createconsumer.md b/iredis/data/commands/xgroup-createconsumer.md new file mode 100644 index 0000000..17274a5 --- /dev/null +++ b/iredis/data/commands/xgroup-createconsumer.md @@ -0,0 +1,7 @@ +Create a consumer named `<consumername>` in the consumer group `<groupname>` of the stream that's stored at `<key>`. + +Consumers are also created automatically whenever an operation, such as `XREADGROUP`, references a consumer that doesn't exist. + +@return + +@integer-reply: the number of created consumers (0 or 1)
\ No newline at end of file diff --git a/iredis/data/commands/xgroup-delconsumer.md b/iredis/data/commands/xgroup-delconsumer.md new file mode 100644 index 0000000..9e73da8 --- /dev/null +++ b/iredis/data/commands/xgroup-delconsumer.md @@ -0,0 +1,10 @@ +The `XGROUP DELCONSUMER` command deletes a consumer from the consumer group. + +Sometimes it may be useful to remove old consumers since they are no longer used. + +Note, however, that any pending messages that the consumer had will become unclaimable after it was deleted. +It is strongly recommended, therefore, that any pending messages are claimed or acknowledged prior to deleting the consumer from the group. + +@return + +@integer-reply: the number of pending messages that the consumer had before it was deleted diff --git a/iredis/data/commands/xgroup-destroy.md b/iredis/data/commands/xgroup-destroy.md new file mode 100644 index 0000000..448468b --- /dev/null +++ b/iredis/data/commands/xgroup-destroy.md @@ -0,0 +1,7 @@ +The `XGROUP DESTROY` command completely destroys a consumer group. + +The consumer group will be destroyed even if there are active consumers, and pending messages, so make sure to call this command only when really needed. + +@return + +@integer-reply: the number of destroyed consumer groups (0 or 1)
\ No newline at end of file diff --git a/iredis/data/commands/xgroup-help.md b/iredis/data/commands/xgroup-help.md new file mode 100644 index 0000000..1eb1a7b --- /dev/null +++ b/iredis/data/commands/xgroup-help.md @@ -0,0 +1,5 @@ +The `XGROUP HELP` command returns a helpful text describing the different subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/xgroup-setid.md b/iredis/data/commands/xgroup-setid.md new file mode 100644 index 0000000..0808404 --- /dev/null +++ b/iredis/data/commands/xgroup-setid.md @@ -0,0 +1,16 @@ +Set the **last delivered ID** for a consumer group. + +Normally, a consumer group's last delivered ID is set when the group is created with `XGROUP CREATE`. +The `XGROUP SETID` command allows modifying the group's last delivered ID, without having to delete and recreate the group. +For instance if you want the consumers in a consumer group to re-process all the messages in a stream, you may want to set its next ID to 0: + + XGROUP SETID mystream mygroup 0 + +The optional `entries_read` argument can be specified to enable consumer group lag tracking for an arbitrary ID. +An arbitrary ID is any ID that isn't the ID of the stream's first entry, its last entry or the zero ("0-0") ID. +This can be useful you know exactly how many entries are between the arbitrary ID (excluding it) and the stream's last entry. +In such cases, the `entries_read` can be set to the stream's `entries_added` subtracted with the number of entries. + +@return + +@simple-string-reply: `OK` on success. diff --git a/iredis/data/commands/xgroup.md b/iredis/data/commands/xgroup.md new file mode 100644 index 0000000..e7b517a --- /dev/null +++ b/iredis/data/commands/xgroup.md @@ -0,0 +1,3 @@ +This is a container command for stream consumer group management commands. + +To see the list of available commands you can call `XGROUP HELP`. diff --git a/iredis/data/commands/xinfo-consumers.md b/iredis/data/commands/xinfo-consumers.md new file mode 100644 index 0000000..f65366d --- /dev/null +++ b/iredis/data/commands/xinfo-consumers.md @@ -0,0 +1,29 @@ +This command returns the list of consumers that belong to the `<groupname>` consumer group of the stream stored at `<key>`. + +The following information is provided for each consumer in the group: + +* **name**: the consumer's name +* **pending**: the number of pending messages for the client, which are messages that were delivered but are yet to be acknowledged +* **idle**: the number of milliseconds that have passed since the consumer last interacted with the server + +@reply + +@array-reply: a list of consumers. + +@examples + +``` +> XINFO CONSUMERS mystream mygroup +1) 1) name + 2) "Alice" + 3) pending + 4) (integer) 1 + 5) idle + 6) (integer) 9104628 +2) 1) name + 2) "Bob" + 3) pending + 4) (integer) 1 + 5) idle + 6) (integer) 83841983 +``` diff --git a/iredis/data/commands/xinfo-groups.md b/iredis/data/commands/xinfo-groups.md new file mode 100644 index 0000000..03eafec --- /dev/null +++ b/iredis/data/commands/xinfo-groups.md @@ -0,0 +1,74 @@ +This command returns the list of all consumers groups of the stream stored at `<key>`. + +By default, only the following information is provided for each of the groups: + +* **name**: the consumer group's name +* **consumers**: the number of consumers in the group +* **pending**: the length of the group's pending entries list (PEL), which are messages that were delivered but are yet to be acknowledged +* **last-delivered-id**: the ID of the last entry delivered the group's consumers +* **entries-read**: the logical "read counter" of the last entry delivered to group's consumers +* **lag**: the number of entries in the stream that are still waiting to be delivered to the group's consumers, or a NULL when that number can't be determined. + +### Consumer group lag + +The lag of a given consumer group is the number of entries in the range between the group's `entries_read` and the stream's `entries_added`. +Put differently, it is the number of entries that are yet to be delivered to the group's consumers. + +The values and trends of this metric are helpful in making scaling decisions about the consumer group. +You can address high lag values by adding more consumers to the group, whereas low values may indicate that you can remove consumers from the group to scale it down. + +Redis reports the lag of a consumer group by keeping two counters: the number of all entries added to the stream and the number of logical reads made by the consumer group. +The lag is the difference between these two. + +The stream's counter (the `entries_added` field of the `XINFO STREAM` command) is incremented by one with every `XADD` and counts all of the entries added to the stream during its lifetime. + +The consumer group's counter, `entries_read`, is the logical counter of entries that the group had read. +It is important to note that this counter is only a heuristic rather than an accurate counter, and therefore the use of the term "logical". +The counter attempts to reflect the number of entries that the group **should have read** to get to its current `last-delivered-id`. +The `entries_read` counter is accurate only in a perfect world, where a consumer group starts at the stream's first entry and processes all of its entries (i.e., no entries deleted before processing). + +There are two special cases in which this mechanism is unable to report the lag: + +1. A consumer group is created or set with an arbitrary last delivered ID (the `XGROUP CREATE` and `XGROUP SETID` commands, respectively). + An arbitrary ID is any ID that isn't the ID of the stream's first entry, its last entry or the zero ("0-0") ID. +2. One or more entries between the group's `last-delivered-id` and the stream's `last-generated-id` were deleted (with `XDEL` or a trimming operation). + +In both cases, the group's read counter is considered invalid, and the returned value is set to NULL to signal that the lag isn't currently available. + +However, the lag is only temporarily unavailable. +It is restored automatically during regular operation as consumers keep processing messages. +Once the consumer group delivers the last message in the stream to its members, it will be set with the correct logical read counter, and tracking its lag can be resumed. + +@reply + +@array-reply: a list of consumer groups. + +@examples + +``` +> XINFO GROUPS mystream +1) 1) "name" + 2) "mygroup" + 3) "consumers" + 4) (integer) 2 + 5) "pending" + 6) (integer) 2 + 7) "last-delivered-id" + 8) "1638126030001-0" + 9) "entries-read" + 10) (integer) 2 + 11) "lag" + 12) (integer) 0 +2) 1) "name" + 2) "some-other-group" + 3) "consumers" + 4) (integer) 1 + 5) "pending" + 6) (integer) 0 + 7) "last-delivered-id" + 8) "1638126028070-0" + 9) "entries-read" + 10) (integer) 1 + 11) "lag" + 12) (integer) 1 +``` diff --git a/iredis/data/commands/xinfo-help.md b/iredis/data/commands/xinfo-help.md new file mode 100644 index 0000000..293892f --- /dev/null +++ b/iredis/data/commands/xinfo-help.md @@ -0,0 +1,5 @@ +The `XINFO HELP` command returns a helpful text describing the different subcommands. + +@return + +@array-reply: a list of subcommands and their descriptions diff --git a/iredis/data/commands/xinfo-stream.md b/iredis/data/commands/xinfo-stream.md new file mode 100644 index 0000000..f697608 --- /dev/null +++ b/iredis/data/commands/xinfo-stream.md @@ -0,0 +1,118 @@ +This command returns information about the stream stored at `<key>`. + +The informative details provided by this command are: + +* **length**: the number of entries in the stream (see `XLEN`) +* **radix-tree-keys**: the number of keys in the underlying radix data structure +* **radix-tree-nodes**: the number of nodes in the underlying radix data structure +* **groups**: the number of consumer groups defined for the stream +* **last-generated-id**: the ID of the least-recently entry that was added to the stream +* **max-deleted-entry-id**: the maximal entry ID that was deleted from the stream +* **entries-added**: the count of all entries added to the stream during its lifetime +* **first-entry**: the ID and field-value tuples of the first entry in the stream +* **last-entry**: the ID and field-value tuples of the last entry in the stream + +The optional `FULL` modifier provides a more verbose reply. +When provided, the `FULL` reply includes an **entries** array that consists of the stream entries (ID and field-value tuples) in ascending order. +Furthermore, **groups** is also an array, and for each of the consumer groups it consists of the information reported by `XINFO GROUPS` and `XINFO CONSUMERS`. + +The `COUNT` option can be used to limit the number of stream and PEL entries that are returned (The first `<count>` entries are returned). +The default `COUNT` is 10 and a `COUNT` of 0 means that all entries will be returned (execution time may be long if the stream has a lot of entries). + +@return + +@array-reply: a list of informational bits + +@examples + +Default reply: + +``` +> XINFO STREAM mystream + 1) "length" + 2) (integer) 2 + 3) "radix-tree-keys" + 4) (integer) 1 + 5) "radix-tree-nodes" + 6) (integer) 2 + 7) "last-generated-id" + 8) "1638125141232-0" + 9) "max-deleted-entry-id" +10) "0-0" +11) "entries-added" +12) (integer) 2 +13) "groups" +14) (integer) 1 +15) "first-entry" +16) 1) "1638125133432-0" + 2) 1) "message" + 2) "apple" +17) "last-entry" +18) 1) "1638125141232-0" + 2) 1) "message" + 2) "banana" +``` + +Full reply: + +``` +> XADD mystream * foo bar +"1638125133432-0" +> XADD mystream * foo bar2 +"1638125141232-0" +> XGROUP CREATE mystream mygroup 0-0 +OK +> XREADGROUP GROUP mygroup Alice COUNT 1 STREAMS mystream > +1) 1) "mystream" + 2) 1) 1) "1638125133432-0" + 2) 1) "foo" + 2) "bar" +> XINFO STREAM mystream FULL + 1) "length" + 2) (integer) 2 + 3) "radix-tree-keys" + 4) (integer) 1 + 5) "radix-tree-nodes" + 6) (integer) 2 + 7) "last-generated-id" + 8) "1638125141232-0" + 9) "max-deleted-entry-id" +10) "0-0" +11) "entries-added" +12) (integer) 2 +13) "entries" +14) 1) 1) "1638125133432-0" + 2) 1) "foo" + 2) "bar" + 2) 1) "1638125141232-0" + 2) 1) "foo" + 2) "bar2" +15) "groups" +16) 1) 1) "name" + 2) "mygroup" + 3) "last-delivered-id" + 4) "1638125133432-0" + 5) "entries-read" + 6) (integer) 1 + 7) "lag" + 8) (integer) 1 + 9) "pel-count" + 10) (integer) 1 + 11) "pending" + 12) 1) 1) "1638125133432-0" + 2) "Alice" + 3) (integer) 1638125153423 + 4) (integer) 1 + 13) "consumers" + 14) 1) 1) "name" + 2) "Alice" + 3) "seen-time" + 4) (integer) 1638125153423 + 5) "pel-count" + 6) (integer) 1 + 7) "pending" + 8) 1) 1) "1638125133432-0" + 2) (integer) 1638125153423 + 3) (integer) 1 +> +``` diff --git a/iredis/data/commands/xinfo.md b/iredis/data/commands/xinfo.md new file mode 100644 index 0000000..93fe9a2 --- /dev/null +++ b/iredis/data/commands/xinfo.md @@ -0,0 +1,3 @@ +This is a container command for stream introspection commands. + +To see the list of available commands you can call `XINFO HELP`. diff --git a/iredis/data/commands/xlen.md b/iredis/data/commands/xlen.md new file mode 100644 index 0000000..41c2010 --- /dev/null +++ b/iredis/data/commands/xlen.md @@ -0,0 +1,22 @@ +Returns the number of entries inside a stream. If the specified key does not +exist the command returns zero, as if the stream was empty. +However note that unlike other Redis types, zero-length streams are +possible, so you should call `TYPE` or `EXISTS` in order to check if +a key exists or not. + +Streams are not auto-deleted once they have no entries inside (for instance +after an `XDEL` call), because the stream may have consumer groups +associated with it. + +@return + +@integer-reply: the number of entries of the stream at `key`. + +@examples + +```cli +XADD mystream * item 1 +XADD mystream * item 2 +XADD mystream * item 3 +XLEN mystream +``` diff --git a/iredis/data/commands/xpending.md b/iredis/data/commands/xpending.md new file mode 100644 index 0000000..48840aa --- /dev/null +++ b/iredis/data/commands/xpending.md @@ -0,0 +1,137 @@ +Fetching data from a stream via a consumer group, and not acknowledging +such data, has the effect of creating *pending entries*. This is +well explained in the `XREADGROUP` command, and even better in our +[introduction to Redis Streams](/topics/streams-intro). The `XACK` command +will immediately remove the pending entry from the Pending Entries List (PEL) +since once a message is successfully processed, there is no longer need +for the consumer group to track it and to remember the current owner +of the message. + +The `XPENDING` command is the interface to inspect the list of pending +messages, and is as thus a very important command in order to observe +and understand what is happening with a streams consumer groups: what +clients are active, what messages are pending to be consumed, or to see +if there are idle messages. Moreover this command, together with `XCLAIM` +is used in order to implement recovering of consumers that are failing +for a long time, and as a result certain messages are not processed: a +different consumer can claim the message and continue. This is better +explained in the [streams intro](/topics/streams-intro) and in the +`XCLAIM` command page, and is not covered here. + +## Summary form of XPENDING + +When `XPENDING` is called with just a key name and a consumer group +name, it just outputs a summary about the pending messages in a given +consumer group. In the following example, we create a consumer group and +immediately create a pending message by reading from the group with +`XREADGROUP`. + +``` +> XGROUP CREATE mystream group55 0-0 +OK + +> XREADGROUP GROUP group55 consumer-123 COUNT 1 STREAMS mystream > +1) 1) "mystream" + 2) 1) 1) 1526984818136-0 + 2) 1) "duration" + 2) "1532" + 3) "event-id" + 4) "5" + 5) "user-id" + 6) "7782813" +``` + +We expect the pending entries list for the consumer group `group55` to +have a message right now: consumer named `consumer-123` fetched the +message without acknowledging its processing. The simple `XPENDING` +form will give us this information: + +``` +> XPENDING mystream group55 +1) (integer) 1 +2) 1526984818136-0 +3) 1526984818136-0 +4) 1) 1) "consumer-123" + 2) "1" +``` + +In this form, the command outputs the total number of pending messages for this +consumer group, which is one, followed by the smallest and greatest ID among the +pending messages, and then list every consumer in the consumer group with +at least one pending message, and the number of pending messages it has. + +## Extended form of XPENDING + +The summary provides a good overview, but sometimes we are interested in the +details. In order to see all the pending messages with more associated +information we need to also pass a range of IDs, in a similar way we do it with +`XRANGE`, and a non optional *count* argument, to limit the number +of messages returned per call: + +``` +> XPENDING mystream group55 - + 10 +1) 1) 1526984818136-0 + 2) "consumer-123" + 3) (integer) 196415 + 4) (integer) 1 +``` + +In the extended form we no longer see the summary information, instead there +is detailed information for each message in the pending entries list. For +each message four attributes are returned: + +1. The ID of the message. +2. The name of the consumer that fetched the message and has still to acknowledge it. We call it the current *owner* of the message. +3. The number of milliseconds that elapsed since the last time this message was delivered to this consumer. +4. The number of times this message was delivered. + +The deliveries counter, that is the fourth element in the array, is incremented +when some other consumer *claims* the message with `XCLAIM`, or when the +message is delivered again via `XREADGROUP`, when accessing the history +of a consumer in a consumer group (see the `XREADGROUP` page for more info). + +It is possible to pass an additional argument to the command, in order +to see the messages having a specific owner: + +``` +> XPENDING mystream group55 - + 10 consumer-123 +``` + +But in the above case the output would be the same, since we have pending +messages only for a single consumer. However what is important to keep in +mind is that this operation, filtering by a specific consumer, is not +inefficient even when there are many pending messages from many consumers: +we have a pending entries list data structure both globally, and for +every consumer, so we can very efficiently show just messages pending for +a single consumer. + +## Idle time filter + +It is also possible to filter pending stream entries by their idle-time, +given in milliseconds (useful for `XCLAIM`ing entries that have not been +processed for some time): + +``` +> XPENDING mystream group55 IDLE 9000 - + 10 +> XPENDING mystream group55 IDLE 9000 - + 10 consumer-123 +``` + +The first case will return the first 10 (or less) PEL entries of the entire group +that are idle for over 9 seconds, whereas in the second case only those of +`consumer-123`. + +## Exclusive ranges and iterating the PEL + +The `XPENDING` command allows iterating over the pending entries just like +`XRANGE` and `XREVRANGE` allow for the stream's entries. You can do this by +prefixing the ID of the last-read pending entry with the `(` character that +denotes an open (exclusive) range, and proving it to the subsequent call to the +command. + +@return + +@array-reply, specifically: + +The command returns data in different format depending on the way it is +called, as previously explained in this page. However the reply is always +an array of items. diff --git a/iredis/data/commands/xrange.md b/iredis/data/commands/xrange.md new file mode 100644 index 0000000..fc6d11d --- /dev/null +++ b/iredis/data/commands/xrange.md @@ -0,0 +1,223 @@ +The command returns the stream entries matching a given range of IDs. +The range is specified by a minimum and maximum ID. All the entries having +an ID between the two specified or exactly one of the two IDs specified +(closed interval) are returned. + +The `XRANGE` command has a number of applications: + +* Returning items in a specific time range. This is possible because + Stream IDs are [related to time](/topics/streams-intro). +* Iterating a stream incrementally, returning just + a few items at every iteration. However it is semantically much more + robust than the `SCAN` family of functions. +* Fetching a single entry from a stream, providing the ID of the entry + to fetch two times: as start and end of the query interval. + +The command also has a reciprocal command returning items in the +reverse order, called `XREVRANGE`, which is otherwise identical. + +## `-` and `+` special IDs + +The `-` and `+` special IDs mean respectively the minimum ID possible +and the maximum ID possible inside a stream, so the following command +will just return every entry in the stream: + +``` +> XRANGE somestream - + +1) 1) 1526985054069-0 + 2) 1) "duration" + 2) "72" + 3) "event-id" + 4) "9" + 5) "user-id" + 6) "839248" +2) 1) 1526985069902-0 + 2) 1) "duration" + 2) "415" + 3) "event-id" + 4) "2" + 5) "user-id" + 6) "772213" +... other entries here ... +``` + +The `-` ID is effectively just exactly as specifying `0-0`, while +`+` is equivalent to `18446744073709551615-18446744073709551615`, however +they are nicer to type. + +## Incomplete IDs + +Stream IDs are composed of two parts, a Unix millisecond time stamp and a +sequence number for entries inserted in the same millisecond. It is possible +to use `XRANGE` specifying just the first part of the ID, the millisecond time, +like in the following example: + +``` +> XRANGE somestream 1526985054069 1526985055069 +``` + +In this case, `XRANGE` will auto-complete the start interval with `-0` +and end interval with `-18446744073709551615`, in order to return all the +entries that were generated between a given millisecond and the end of +the other specified millisecond. This also means that repeating the same +millisecond two times, we get all the entries within such millisecond, +because the sequence number range will be from zero to the maximum. + +Used in this way `XRANGE` works as a range query command to obtain entries +in a specified time. This is very handy in order to access the history +of past events in a stream. + +## Exclusive ranges + +The range is close (inclusive) by default, meaning that the reply can include +entries with IDs matching the query's start and end intervals. It is possible +to specify an open interval (exclusive) by prefixing the ID with the +character `(`. This is useful for iterating the stream, as explained below. + +## Returning a maximum number of entries + +Using the **COUNT** option it is possible to reduce the number of entries +reported. This is a very important feature even if it may look marginal, +because it allows, for instance, to model operations such as *give me +the entry greater or equal to the following*: + +``` +> XRANGE somestream 1526985054069-0 + COUNT 1 +1) 1) 1526985054069-0 + 2) 1) "duration" + 2) "72" + 3) "event-id" + 4) "9" + 5) "user-id" + 6) "839248" +``` + +In the above case the entry `1526985054069-0` exists, otherwise the server +would have sent us the next one. Using `COUNT` is also the base in order to +use `XRANGE` as an iterator. + +## Iterating a stream + +In order to iterate a stream, we can proceed as follows. Let's assume that +we want two elements per iteration. We start fetching the first two +elements, which is trivial: + +``` +> XRANGE writers - + COUNT 2 +1) 1) 1526985676425-0 + 2) 1) "name" + 2) "Virginia" + 3) "surname" + 4) "Woolf" +2) 1) 1526985685298-0 + 2) 1) "name" + 2) "Jane" + 3) "surname" + 4) "Austen" +``` + +Then instead of starting the iteration again from `-`, as the start +of the range we use the entry ID of the *last* entry returned by the +previous `XRANGE` call as an exclusive interval. + +The ID of the last entry is `1526985685298-0`, so we just prefix it +with a '(', and continue our iteration: + +``` +> XRANGE writers (1526985685298-0 + COUNT 2 +1) 1) 1526985691746-0 + 2) 1) "name" + 2) "Toni" + 3) "surname" + 4) "Morrison" +2) 1) 1526985712947-0 + 2) 1) "name" + 2) "Agatha" + 3) "surname" + 4) "Christie" +``` + +And so forth. Eventually this will allow to visit all the entries in the +stream. Obviously, we can start the iteration from any ID, or even from +a specific time, by providing a given incomplete start ID. Moreover, we +can limit the iteration to a given ID or time, by providing an end +ID or incomplete ID instead of `+`. + +The command `XREAD` is also able to iterate the stream. +The command `XREVRANGE` can iterate the stream reverse, from higher IDs +(or times) to lower IDs (or times). + +### Iterating with earlier versions of Redis + +While exclusive range intervals are only available from Redis 6.2, it is still +possible to use a similar stream iteration pattern with earlier versions. You +start fetching from the stream the same way as described above to obtain the +first entries. + +For the subsequent calls, you'll need to programmatically advance the last +entry's ID returned. Most Redis client should abstract this detail, but the +implementation can also be in the application if needed. In the example above, +this means incrementing the sequence of `1526985685298-0` by one, from 0 to 1. +The second call would, therefore, be: + +``` +> XRANGE writers 1526985685298-1 + COUNT 2 +1) 1) 1526985691746-0 + 2) 1) "name" + 2) "Toni" +... +``` + +Also, note that once the sequence part of the last ID equals +18446744073709551615, you'll need to increment the timestamp and reset the +sequence part to 0. For example, incrementing the ID +`1526985685298-18446744073709551615` should result in `1526985685299-0`. + +A symmetrical pattern applies to iterating the stream with `XREVRANGE`. The +only difference is that the client needs to decrement the ID for the subsequent +calls. When decrementing an ID with a sequence part of 0, the timestamp needs +to be decremented by 1 and the sequence set to 18446744073709551615. + +## Fetching single items + +If you look for an `XGET` command you'll be disappointed because `XRANGE` +is effectively the way to go in order to fetch a single entry from a +stream. All you have to do is to specify the ID two times in the arguments +of XRANGE: + +``` +> XRANGE mystream 1526984818136-0 1526984818136-0 +1) 1) 1526984818136-0 + 2) 1) "duration" + 2) "1532" + 3) "event-id" + 4) "5" + 5) "user-id" + 6) "7782813" +``` + +## Additional information about streams + +For further information about Redis streams please check our +[introduction to Redis Streams document](/topics/streams-intro). + +@return + +@array-reply, specifically: + +The command returns the entries with IDs matching the specified range. +The returned entries are complete, that means that the ID and all the fields +they are composed are returned. Moreover, the entries are returned with +their fields and values in the exact same order as `XADD` added them. + +@examples + +```cli +XADD writers * name Virginia surname Woolf +XADD writers * name Jane surname Austen +XADD writers * name Toni surname Morrison +XADD writers * name Agatha surname Christie +XADD writers * name Ngozi surname Adichie +XLEN writers +XRANGE writers - + COUNT 2 +``` diff --git a/iredis/data/commands/xread.md b/iredis/data/commands/xread.md new file mode 100644 index 0000000..ea0f311 --- /dev/null +++ b/iredis/data/commands/xread.md @@ -0,0 +1,215 @@ +Read data from one or multiple streams, only returning entries with an +ID greater than the last received ID reported by the caller. +This command has an option to block if items are not available, in a similar +fashion to `BRPOP` or `BZPOPMIN` and others. + +Please note that before reading this page, if you are new to streams, +we recommend to read [our introduction to Redis Streams](/topics/streams-intro). + +## Non-blocking usage + +If the **BLOCK** option is not used, the command is synchronous, and can +be considered somewhat related to `XRANGE`: it will return a range of items +inside streams, however it has two fundamental differences compared to `XRANGE` +even if we just consider the synchronous usage: + +* This command can be called with multiple streams if we want to read at + the same time from a number of keys. This is a key feature of `XREAD` because + especially when blocking with **BLOCK**, to be able to listen with a single + connection to multiple keys is a vital feature. +* While `XRANGE` returns items in a range of IDs, `XREAD` is more suited in + order to consume the stream starting from the first entry which is greater + than any other entry we saw so far. So what we pass to `XREAD` is, for each + stream, the ID of the last element that we received from that stream. + +For example, if I have two streams `mystream` and `writers`, and I want to +read data from both the streams starting from the first element they contain, +I could call `XREAD` like in the following example. + +Note: we use the **COUNT** option in the example, so that for each stream +the call will return at maximum two elements per stream. + +``` +> XREAD COUNT 2 STREAMS mystream writers 0-0 0-0 +1) 1) "mystream" + 2) 1) 1) 1526984818136-0 + 2) 1) "duration" + 2) "1532" + 3) "event-id" + 4) "5" + 5) "user-id" + 6) "7782813" + 2) 1) 1526999352406-0 + 2) 1) "duration" + 2) "812" + 3) "event-id" + 4) "9" + 5) "user-id" + 6) "388234" +2) 1) "writers" + 2) 1) 1) 1526985676425-0 + 2) 1) "name" + 2) "Virginia" + 3) "surname" + 4) "Woolf" + 2) 1) 1526985685298-0 + 2) 1) "name" + 2) "Jane" + 3) "surname" + 4) "Austen" +``` + +The **STREAMS** option is mandatory and MUST be the final option because +such option gets a variable length of argument in the following format: + + STREAMS key_1 key_2 key_3 ... key_N ID_1 ID_2 ID_3 ... ID_N + +So we start with a list of keys, and later continue with all the associated +IDs, representing *the last ID we received for that stream*, so that the +call will serve us only greater IDs from the same stream. + +For instance in the above example, the last items that we received +for the stream `mystream` has ID `1526999352406-0`, while for the +stream `writers` has the ID `1526985685298-0`. + +To continue iterating the two streams I'll call: + +``` +> XREAD COUNT 2 STREAMS mystream writers 1526999352406-0 1526985685298-0 +1) 1) "mystream" + 2) 1) 1) 1526999626221-0 + 2) 1) "duration" + 2) "911" + 3) "event-id" + 4) "7" + 5) "user-id" + 6) "9488232" +2) 1) "writers" + 2) 1) 1) 1526985691746-0 + 2) 1) "name" + 2) "Toni" + 3) "surname" + 4) "Morrison" + 2) 1) 1526985712947-0 + 2) 1) "name" + 2) "Agatha" + 3) "surname" + 4) "Christie" +``` + +And so forth. Eventually, the call will not return any item, but just an +empty array, then we know that there is nothing more to fetch from our +stream (and we would have to retry the operation, hence this command +also supports a blocking mode). + +## Incomplete IDs + +To use incomplete IDs is valid, like it is valid for `XRANGE`. However +here the sequence part of the ID, if missing, is always interpreted as +zero, so the command: + +``` +> XREAD COUNT 2 STREAMS mystream writers 0 0 +``` + +is exactly equivalent to + +``` +> XREAD COUNT 2 STREAMS mystream writers 0-0 0-0 +``` + +## Blocking for data + +In its synchronous form, the command can get new data as long as there +are more items available. However, at some point, we'll have to wait for +producers of data to use `XADD` to push new entries inside the streams +we are consuming. In order to avoid polling at a fixed or adaptive interval +the command is able to block if it could not return any data, according +to the specified streams and IDs, and automatically unblock once one of +the requested keys accept data. + +It is important to understand that this command *fans out* to all the +clients that are waiting for the same range of IDs, so every consumer will +get a copy of the data, unlike to what happens when blocking list pop +operations are used. + +In order to block, the **BLOCK** option is used, together with the number +of milliseconds we want to block before timing out. Normally Redis blocking +commands take timeouts in seconds, however this command takes a millisecond +timeout, even if normally the server will have a timeout resolution near +to 0.1 seconds. This time it is possible to block for a shorter time in +certain use cases, and if the server internals will improve over time, it is +possible that the resolution of timeouts will improve. + +When the **BLOCK** command is passed, but there is data to return at +least in one of the streams passed, the command is executed synchronously +*exactly like if the BLOCK option would be missing*. + +This is an example of blocking invocation, where the command later returns +a null reply because the timeout has elapsed without new data arriving: + +``` +> XREAD BLOCK 1000 STREAMS mystream 1526999626221-0 +(nil) +``` + +## The special `$` ID. + +When blocking sometimes we want to receive just entries that are added +to the stream via `XADD` starting from the moment we block. In such a case +we are not interested in the history of already added entries. For +this use case, we would have to check the stream top element ID, and use +such ID in the `XREAD` command line. This is not clean and requires to +call other commands, so instead it is possible to use the special `$` +ID to signal the stream that we want only the new things. + +It is **very important** to understand that you should use the `$` +ID only for the first call to `XREAD`. Later the ID should be the one +of the last reported item in the stream, otherwise you could miss all +the entries that are added in between. + +This is how a typical `XREAD` call looks like in the first iteration +of a consumer willing to consume only new entries: + +``` +> XREAD BLOCK 5000 COUNT 100 STREAMS mystream $ +``` + +Once we get some replies, the next call will be something like: + +``` +> XREAD BLOCK 5000 COUNT 100 STREAMS mystream 1526999644174-3 +``` + +And so forth. + +## How multiple clients blocked on a single stream are served + +Blocking list operations on lists or sorted sets have a *pop* behavior. +Basically, the element is removed from the list or sorted set in order +to be returned to the client. In this scenario you want the items +to be consumed in a fair way, depending on the moment clients blocked +on a given key arrived. Normally Redis uses the FIFO semantics in this +use cases. + +However note that with streams this is not a problem: stream entries +are not removed from the stream when clients are served, so every +client waiting will be served as soon as an `XADD` command provides +data to the stream. + +@return + +@array-reply, specifically: + +The command returns an array of results: each element of the returned +array is an array composed of a two element containing the key name and +the entries reported for that key. The entries reported are full stream +entries, having IDs and the list of all the fields and values. Field and +values are guaranteed to be reported in the same order they were added +by `XADD`. + +When **BLOCK** is used, on timeout a null reply is returned. + +Reading the [Redis Streams introduction](/topics/streams-intro) is highly +suggested in order to understand more about the streams overall behavior +and semantics. diff --git a/iredis/data/commands/xreadgroup.md b/iredis/data/commands/xreadgroup.md new file mode 100644 index 0000000..4b516e5 --- /dev/null +++ b/iredis/data/commands/xreadgroup.md @@ -0,0 +1,147 @@ +The `XREADGROUP` command is a special version of the `XREAD` command +with support for consumer groups. Probably you will have to understand the +`XREAD` command before reading this page will makes sense. + +Moreover, if you are new to streams, we recommend to read our +[introduction to Redis Streams](/topics/streams-intro). +Make sure to understand the concept of consumer group in the introduction +so that following how this command works will be simpler. + +## Consumer groups in 30 seconds + +The difference between this command and the vanilla `XREAD` is that this +one supports consumer groups. + +Without consumer groups, just using `XREAD`, all the clients are served with all the entries arriving in a stream. Instead using consumer groups with `XREADGROUP`, it is possible to create groups of clients that consume different parts of the messages arriving in a given stream. If, for instance, the stream gets the new entries A, B, and C and there are two consumers reading via a consumer group, one client will get, for instance, the messages A and C, and the other the message B, and so forth. + +Within a consumer group, a given consumer (that is, just a client consuming messages from the stream), has to identify with a unique *consumer name*. Which is just a string. + +One of the guarantees of consumer groups is that a given consumer can only see the history of messages that were delivered to it, so a message has just a single owner. However there is a special feature called *message claiming* that allows other consumers to claim messages in case there is a non recoverable failure of some consumer. In order to implement such semantics, consumer groups require explicit acknowledgment of the messages successfully processed by the consumer, via the `XACK` command. This is needed because the stream will track, for each consumer group, who is processing what message. + +This is how to understand if you want to use a consumer group or not: + +1. If you have a stream and multiple clients, and you want all the clients to get all the messages, you do not need a consumer group. +2. If you have a stream and multiple clients, and you want the stream to be *partitioned* or *sharded* across your clients, so that each client will get a sub set of the messages arriving in a stream, you need a consumer group. + +## Differences between XREAD and XREADGROUP + +From the point of view of the syntax, the commands are almost the same, +however `XREADGROUP` *requires* a special and mandatory option: + + GROUP <group-name> <consumer-name> + +The group name is just the name of a consumer group associated to the stream. +The group is created using the `XGROUP` command. The consumer name is the +string that is used by the client to identify itself inside the group. +The consumer is auto created inside the consumer group the first time it +is saw. Different clients should select a different consumer name. + +When you read with `XREADGROUP`, the server will *remember* that a given +message was delivered to you: the message will be stored inside the +consumer group in what is called a Pending Entries List (PEL), that is +a list of message IDs delivered but not yet acknowledged. + +The client will have to acknowledge the message processing using `XACK` +in order for the pending entry to be removed from the PEL. The PEL +can be inspected using the `XPENDING` command. + +The `NOACK` subcommand can be used to avoid adding the message to the PEL in +cases where reliability is not a requirement and the occasional message loss +is acceptable. This is equivalent to acknowledging the message when it is read. + +The ID to specify in the **STREAMS** option when using `XREADGROUP` can +be one of the following two: + +* The special `>` ID, which means that the consumer want to receive only messages that were *never delivered to any other consumer*. It just means, give me new messages. +* Any other ID, that is, 0 or any other valid ID or incomplete ID (just the millisecond time part), will have the effect of returning entries that are pending for the consumer sending the command with IDs greater than the one provided. So basically if the ID is not `>`, then the command will just let the client access its pending entries: messages delivered to it, but not yet acknowledged. Note that in this case, both `BLOCK` and `NOACK` are ignored. + +Like `XREAD` the `XREADGROUP` command can be used in a blocking way. There +are no differences in this regard. + +## What happens when a message is delivered to a consumer? + +Two things: + +1. If the message was never delivered to anyone, that is, if we are talking about a new message, then a PEL (Pending Entries List) is created. +2. If instead the message was already delivered to this consumer, and it is just re-fetching the same message again, then the *last delivery counter* is updated to the current time, and the *number of deliveries* is incremented by one. You can access those message properties using the `XPENDING` command. + +## Usage example + +Normally you use the command like that in order to get new messages and +process them. In pseudo-code: + +``` +WHILE true + entries = XREADGROUP GROUP $GroupName $ConsumerName BLOCK 2000 COUNT 10 STREAMS mystream > + if entries == nil + puts "Timeout... try again" + CONTINUE + end + + FOREACH entries AS stream_entries + FOREACH stream_entries as message + process_message(message.id,message.fields) + + # ACK the message as processed + XACK mystream $GroupName message.id + END + END +END +``` + +In this way the example consumer code will fetch only new messages, process +them, and acknowledge them via `XACK`. However the example code above is +not complete, because it does not handle recovering after a crash. What +will happen if we crash in the middle of processing messages, is that our +messages will remain in the pending entries list, so we can access our +history by giving `XREADGROUP` initially an ID of 0, and performing the same +loop. Once providing an ID of 0 the reply is an empty set of messages, we +know that we processed and acknowledged all the pending messages: we +can start to use `>` as ID, in order to get the new messages and rejoin the +consumers that are processing new things. + +To see how the command actually replies, please check the `XREAD` command page. + +## What happens when a pending message is deleted? + +Entries may be deleted from the stream due to trimming or explicit calls to `XDEL` at any time. +By design, Redis doesn't prevent the deletion of entries that are present in the stream's PELs. +When this happens, the PELs retain the deleted entries' IDs, but the actual entry payload is no longer available. +Therefore, when reading such PEL entries, Redis will return a null value in place of their respective data. + +Example: + +``` +> XADD mystream 1 myfield mydata +"1-0" +> XGROUP CREATE mystream mygroup 0 +OK +> XREADGROUP GROUP mygroup myconsumer STREAMS STREAMS mystream > +1) 1) "mystream" + 2) 1) 1) "1-0" + 2) 1) "myfield" + 2) "mydata" +> XDEL mystream 1-0 +(integer) 1 +> XREADGROUP GROUP mygroup myconsumer STREAMS STREAMS mystream 0 +1) 1) "mystream" + 2) 1) 1) "1-0" + 2) (nil) +``` + +@return + +@array-reply, specifically: + +The command returns an array of results: each element of the returned +array is an array composed of a two element containing the key name and +the entries reported for that key. The entries reported are full stream +entries, having IDs and the list of all the fields and values. Field and +values are guaranteed to be reported in the same order they were added +by `XADD`. + +When **BLOCK** is used, on timeout a null reply is returned. + +Reading the [Redis Streams introduction](/topics/streams-intro) is highly +suggested in order to understand more about the streams overall behavior +and semantics. diff --git a/iredis/data/commands/xrevrange.md b/iredis/data/commands/xrevrange.md new file mode 100644 index 0000000..d61b3f5 --- /dev/null +++ b/iredis/data/commands/xrevrange.md @@ -0,0 +1,37 @@ +This command is exactly like `XRANGE`, but with the notable difference of +returning the entries in reverse order, and also taking the start-end +range in reverse order: in `XREVRANGE` you need to state the *end* ID +and later the *start* ID, and the command will produce all the element +between (or exactly like) the two IDs, starting from the *end* side. + +So for instance, to get all the elements from the higher ID to the lower +ID one could use: + + XREVRANGE somestream + - + +Similarly to get just the last element added into the stream it is +enough to send: + + XREVRANGE somestream + - COUNT 1 + +@return + +@array-reply, specifically: + +The command returns the entries with IDs matching the specified range, +from the higher ID to the lower ID matching. +The returned entries are complete, that means that the ID and all the fields +they are composed are returned. Moreover the entries are returned with +their fields and values in the exact same order as `XADD` added them. + +@examples + +```cli +XADD writers * name Virginia surname Woolf +XADD writers * name Jane surname Austen +XADD writers * name Toni surname Morrison +XADD writers * name Agatha surname Christie +XADD writers * name Ngozi surname Adichie +XLEN writers +XREVRANGE writers + - COUNT 1 +``` diff --git a/iredis/data/commands/xsetid.md b/iredis/data/commands/xsetid.md new file mode 100644 index 0000000..39b593c --- /dev/null +++ b/iredis/data/commands/xsetid.md @@ -0,0 +1,2 @@ +The `XSETID` command is an internal command. +It is used by a Redis master to replicate the last delivered ID of streams.
\ No newline at end of file diff --git a/iredis/data/commands/xtrim.md b/iredis/data/commands/xtrim.md new file mode 100644 index 0000000..08d55d5 --- /dev/null +++ b/iredis/data/commands/xtrim.md @@ -0,0 +1,57 @@ +`XTRIM` trims the stream by evicting older entries (entries with lower IDs) if needed. + +Trimming the stream can be done using one of these strategies: + +* `MAXLEN`: Evicts entries as long as the stream's length exceeds the specified `threshold`, where `threshold` is a positive integer. +* `MINID`: Evicts entries with IDs lower than `threshold`, where `threshold` is a stream ID. + +For example, this will trim the stream to exactly the latest 1000 items: + +``` +XTRIM mystream MAXLEN 1000 +``` + +Whereas in this example, all entries that have an ID lower than 649085820-0 will be evicted: + +``` +XTRIM mystream MINID 649085820 +``` + +By default, or when provided with the optional `=` argument, the command performs exact trimming. + +Depending on the strategy, exact trimming means: + +* `MAXLEN`: the trimmed stream's length will be exactly the minimum between its original length and the specified `threshold`. +* `MINID`: the oldest ID in the stream will be exactly the maximum between its original oldest ID and the specified `threshold`. + +Nearly exact trimming +--- + +Because exact trimming may require additional effort from the Redis server, the optional `~` argument can be provided to make it more efficient. + +For example: + +``` +XTRIM mystream MAXLEN ~ 1000 +``` + +The `~` argument between the `MAXLEN` strategy and the `threshold` means that the user is requesting to trim the stream so its length is **at least** the `threshold`, but possibly slightly more. +In this case, Redis will stop trimming early when performance can be gained (for example, when a whole macro node in the data structure can't be removed). +This makes trimming much more efficient, and it is usually what you want, although after trimming, the stream may have few tens of additional entries over the `threshold`. + +Another way to control the amount of work done by the command when using the `~`, is the `LIMIT` clause. +When used, it specifies the maximal `count` of entries that will be evicted. +When `LIMIT` and `count` aren't specified, the default value of 100 * the number of entries in a macro node will be implicitly used as the `count`. +Specifying the value 0 as `count` disables the limiting mechanism entirely. + +@return + +@integer-reply: The number of entries deleted from the stream. + +@examples + +```cli +XADD mystream * field1 A field2 B field3 C field4 D +XTRIM mystream MAXLEN 2 +XRANGE mystream - + +``` diff --git a/iredis/data/commands/zadd.md b/iredis/data/commands/zadd.md new file mode 100644 index 0000000..eb77de6 --- /dev/null +++ b/iredis/data/commands/zadd.md @@ -0,0 +1,79 @@ +Adds all the specified members with the specified scores to the sorted set +stored at `key`. +It is possible to specify multiple score / member pairs. +If a specified member is already a member of the sorted set, the score is +updated and the element reinserted at the right position to ensure the correct +ordering. + +If `key` does not exist, a new sorted set with the specified members as sole +members is created, like if the sorted set was empty. If the key exists but does not hold a sorted set, an error is returned. + +The score values should be the string representation of a double precision floating point number. `+inf` and `-inf` values are valid values as well. + +ZADD options +--- + +ZADD supports a list of options, specified after the name of the key and before +the first score argument. Options are: + +* **XX**: Only update elements that already exist. Don't add new elements. +* **NX**: Only add new elements. Don't update already existing elements. +* **LT**: Only update existing elements if the new score is **less than** the current score. This flag doesn't prevent adding new elements. +* **GT**: Only update existing elements if the new score is **greater than** the current score. This flag doesn't prevent adding new elements. +* **CH**: Modify the return value from the number of new elements added, to the total number of elements changed (CH is an abbreviation of *changed*). Changed elements are **new elements added** and elements already existing for which **the score was updated**. So elements specified in the command line having the same score as they had in the past are not counted. Note: normally the return value of `ZADD` only counts the number of new elements added. +* **INCR**: When this option is specified `ZADD` acts like `ZINCRBY`. Only one score-element pair can be specified in this mode. + +Note: The **GT**, **LT** and **NX** options are mutually exclusive. + +Range of integer scores that can be expressed precisely +--- + +Redis sorted sets use a *double 64-bit floating point number* to represent the score. In all the architectures we support, this is represented as an **IEEE 754 floating point number**, that is able to represent precisely integer numbers between `-(2^53)` and `+(2^53)` included. In more practical terms, all the integers between -9007199254740992 and 9007199254740992 are perfectly representable. Larger integers, or fractions, are internally represented in exponential form, so it is possible that you get only an approximation of the decimal number, or of the very big integer, that you set as score. + +Sorted sets 101 +--- + +Sorted sets are sorted by their score in an ascending way. +The same element only exists a single time, no repeated elements are +permitted. The score can be modified both by `ZADD` that will update the +element score, and as a side effect, its position on the sorted set, and +by `ZINCRBY` that can be used in order to update the score relatively to its +previous value. + +The current score of an element can be retrieved using the `ZSCORE` command, +that can also be used to verify if an element already exists or not. + +For an introduction to sorted sets, see the data types page on [sorted +sets][tdtss]. + +[tdtss]: /topics/data-types#sorted-sets + +Elements with the same score +--- + +While the same element can't be repeated in a sorted set since every element +is unique, it is possible to add multiple different elements *having the same score*. When multiple elements have the same score, they are *ordered lexicographically* (they are still ordered by score as a first key, however, locally, all the elements with the same score are relatively ordered lexicographically). + +The lexicographic ordering used is binary, it compares strings as array of bytes. + +If the user inserts all the elements in a sorted set with the same score (for example 0), all the elements of the sorted set are sorted lexicographically, and range queries on elements are possible using the command `ZRANGEBYLEX` (Note: it is also possible to query sorted sets by range of scores using `ZRANGEBYSCORE`). + +@return + +@integer-reply, specifically: + +* When used without optional arguments, the number of elements added to the sorted set (excluding score updates). +* If the `CH` option is specified, the number of elements that were changed (added or updated). + +If the `INCR` option is specified, the return value will be @bulk-string-reply: + +* The new score of `member` (a double precision floating point number) represented as string, or `nil` if the operation was aborted (when called with either the `XX` or the `NX` option). + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 1 "uno" +ZADD myzset 2 "two" 3 "three" +ZRANGE myzset 0 -1 WITHSCORES +``` diff --git a/iredis/data/commands/zcard.md b/iredis/data/commands/zcard.md new file mode 100644 index 0000000..5ad5043 --- /dev/null +++ b/iredis/data/commands/zcard.md @@ -0,0 +1,15 @@ +Returns the sorted set cardinality (number of elements) of the sorted set stored +at `key`. + +@return + +@integer-reply: the cardinality (number of elements) of the sorted set, or `0` +if `key` does not exist. + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZCARD myzset +``` diff --git a/iredis/data/commands/zcount.md b/iredis/data/commands/zcount.md new file mode 100644 index 0000000..82ce39b --- /dev/null +++ b/iredis/data/commands/zcount.md @@ -0,0 +1,21 @@ +Returns the number of elements in the sorted set at `key` with a score between +`min` and `max`. + +The `min` and `max` arguments have the same semantic as described for +`ZRANGEBYSCORE`. + +Note: the command has a complexity of just O(log(N)) because it uses elements ranks (see `ZRANK`) to get an idea of the range. Because of this there is no need to do a work proportional to the size of the range. + +@return + +@integer-reply: the number of elements in the specified score range. + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZADD myzset 3 "three" +ZCOUNT myzset -inf +inf +ZCOUNT myzset (1 3 +``` diff --git a/iredis/data/commands/zdiff.md b/iredis/data/commands/zdiff.md new file mode 100644 index 0000000..d9449b7 --- /dev/null +++ b/iredis/data/commands/zdiff.md @@ -0,0 +1,19 @@ +This command is similar to `ZDIFFSTORE`, but instead of storing the resulting +sorted set, it is returned to the client. + +@return + +@array-reply: the result of the difference (optionally with their scores, in case +the `WITHSCORES` option is given). + +@examples + +```cli +ZADD zset1 1 "one" +ZADD zset1 2 "two" +ZADD zset1 3 "three" +ZADD zset2 1 "one" +ZADD zset2 2 "two" +ZDIFF 2 zset1 zset2 +ZDIFF 2 zset1 zset2 WITHSCORES +``` diff --git a/iredis/data/commands/zdiffstore.md b/iredis/data/commands/zdiffstore.md new file mode 100644 index 0000000..abe3ba7 --- /dev/null +++ b/iredis/data/commands/zdiffstore.md @@ -0,0 +1,24 @@ +Computes the difference between the first and all successive input sorted sets +and stores the result in `destination`. The total number of input keys is +specified by `numkeys`. + +Keys that do not exist are considered to be empty sets. + +If `destination` already exists, it is overwritten. + +@return + +@integer-reply: the number of elements in the resulting sorted set at +`destination`. + +@examples + +```cli +ZADD zset1 1 "one" +ZADD zset1 2 "two" +ZADD zset1 3 "three" +ZADD zset2 1 "one" +ZADD zset2 2 "two" +ZDIFFSTORE out 2 zset1 zset2 +ZRANGE out 0 -1 WITHSCORES +``` diff --git a/iredis/data/commands/zincrby.md b/iredis/data/commands/zincrby.md new file mode 100644 index 0000000..0b8ccf0 --- /dev/null +++ b/iredis/data/commands/zincrby.md @@ -0,0 +1,26 @@ +Increments the score of `member` in the sorted set stored at `key` by +`increment`. +If `member` does not exist in the sorted set, it is added with `increment` as +its score (as if its previous score was `0.0`). +If `key` does not exist, a new sorted set with the specified `member` as its +sole member is created. + +An error is returned when `key` exists but does not hold a sorted set. + +The `score` value should be the string representation of a numeric value, and +accepts double precision floating point numbers. +It is possible to provide a negative value to decrement the score. + +@return + +@bulk-string-reply: the new score of `member` (a double precision floating point +number), represented as string. + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZINCRBY myzset 2 "one" +ZRANGE myzset 0 -1 WITHSCORES +``` diff --git a/iredis/data/commands/zinter.md b/iredis/data/commands/zinter.md new file mode 100644 index 0000000..5a7adcc --- /dev/null +++ b/iredis/data/commands/zinter.md @@ -0,0 +1,21 @@ +This command is similar to `ZINTERSTORE`, but instead of storing the resulting +sorted set, it is returned to the client. + +For a description of the `WEIGHTS` and `AGGREGATE` options, see `ZUNIONSTORE`. + +@return + +@array-reply: the result of intersection (optionally with their scores, in case +the `WITHSCORES` option is given). + +@examples + +```cli +ZADD zset1 1 "one" +ZADD zset1 2 "two" +ZADD zset2 1 "one" +ZADD zset2 2 "two" +ZADD zset2 3 "three" +ZINTER 2 zset1 zset2 +ZINTER 2 zset1 zset2 WITHSCORES +``` diff --git a/iredis/data/commands/zintercard.md b/iredis/data/commands/zintercard.md new file mode 100644 index 0000000..613849f --- /dev/null +++ b/iredis/data/commands/zintercard.md @@ -0,0 +1,25 @@ +This command is similar to `ZINTER`, but instead of returning the result set, it returns just the cardinality of the result. + +Keys that do not exist are considered to be empty sets. +With one of the keys being an empty set, the resulting set is also empty (since set intersection with an empty set always results in an empty set). + +By default, the command calculates the cardinality of the intersection of all given sets. +When provided with the optional `LIMIT` argument (which defaults to 0 and means unlimited), if the intersection cardinality reaches limit partway through the computation, the algorithm will exit and yield limit as the cardinality. +Such implementation ensures a significant speedup for queries where the limit is lower than the actual intersection cardinality. + +@return + +@integer-reply: the number of elements in the resulting intersection. + +@examples + +```cli +ZADD zset1 1 "one" +ZADD zset1 2 "two" +ZADD zset2 1 "one" +ZADD zset2 2 "two" +ZADD zset2 3 "three" +ZINTER 2 zset1 zset2 +ZINTERCARD 2 zset1 zset2 +ZINTERCARD 2 zset1 zset2 LIMIT 1 +``` diff --git a/iredis/data/commands/zinterstore.md b/iredis/data/commands/zinterstore.md new file mode 100644 index 0000000..0ecda0d --- /dev/null +++ b/iredis/data/commands/zinterstore.md @@ -0,0 +1,31 @@ +Computes the intersection of `numkeys` sorted sets given by the specified keys, +and stores the result in `destination`. +It is mandatory to provide the number of input keys (`numkeys`) before passing +the input keys and the other (optional) arguments. + +By default, the resulting score of an element is the sum of its scores in the +sorted sets where it exists. +Because intersection requires an element to be a member of every given sorted +set, this results in the score of every element in the resulting sorted set to +be equal to the number of input sorted sets. + +For a description of the `WEIGHTS` and `AGGREGATE` options, see `ZUNIONSTORE`. + +If `destination` already exists, it is overwritten. + +@return + +@integer-reply: the number of elements in the resulting sorted set at +`destination`. + +@examples + +```cli +ZADD zset1 1 "one" +ZADD zset1 2 "two" +ZADD zset2 1 "one" +ZADD zset2 2 "two" +ZADD zset2 3 "three" +ZINTERSTORE out 2 zset1 zset2 WEIGHTS 2 3 +ZRANGE out 0 -1 WITHSCORES +``` diff --git a/iredis/data/commands/zlexcount.md b/iredis/data/commands/zlexcount.md new file mode 100644 index 0000000..15484f7 --- /dev/null +++ b/iredis/data/commands/zlexcount.md @@ -0,0 +1,19 @@ +When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns the number of elements in the sorted set at `key` with a value between `min` and `max`. + +The `min` and `max` arguments have the same meaning as described for +`ZRANGEBYLEX`. + +Note: the command has a complexity of just O(log(N)) because it uses elements ranks (see `ZRANK`) to get an idea of the range. Because of this there is no need to do a work proportional to the size of the range. + +@return + +@integer-reply: the number of elements in the specified score range. + +@examples + +```cli +ZADD myzset 0 a 0 b 0 c 0 d 0 e +ZADD myzset 0 f 0 g +ZLEXCOUNT myzset - + +ZLEXCOUNT myzset [b [f +``` diff --git a/iredis/data/commands/zmpop.md b/iredis/data/commands/zmpop.md new file mode 100644 index 0000000..16848a0 --- /dev/null +++ b/iredis/data/commands/zmpop.md @@ -0,0 +1,36 @@ +Pops one or more elements, that are member-score pairs, from the first non-empty sorted set in the provided list of key names. + +`ZMPOP` and `BZMPOP` are similar to the following, more limited, commands: + +- `ZPOPMIN` or `ZPOPMAX` which take only one key, and can return multiple elements. +- `BZPOPMIN` or `BZPOPMAX` which take multiple keys, but return only one element from just one key. + +See `BZMPOP` for the blocking variant of this command. + +When the `MIN` modifier is used, the elements popped are those with the lowest scores from the first non-empty sorted set. The `MAX` modifier causes elements with the highest scores to be popped. +The optional `COUNT` can be used to specify the number of elements to pop, and is set to 1 by default. + +The number of popped elements is the minimum from the sorted set's cardinality and `COUNT`'s value. + +@return + +@array-reply: specifically: + +* A `nil` when no element could be popped. +* A two-element array with the first element being the name of the key from which elements were popped, and the second element is an array of the popped elements. Every entry in the elements array is also an array that contains the member and its score. + +@examples + +```cli +ZMPOP 1 notsuchkey MIN +ZADD myzset 1 "one" 2 "two" 3 "three" +ZMPOP 1 myzset MIN +ZRANGE myzset 0 -1 WITHSCORES +ZMPOP 1 myzset MAX COUNT 10 +ZADD myzset2 4 "four" 5 "five" 6 "six" +ZMPOP 2 myzset myzset2 MIN COUNT 10 +ZRANGE myzset 0 -1 WITHSCORES +ZMPOP 2 myzset myzset2 MAX COUNT 10 +ZRANGE myzset2 0 -1 WITHSCORES +EXISTS myzset myzset2 +``` diff --git a/iredis/data/commands/zmscore.md b/iredis/data/commands/zmscore.md new file mode 100644 index 0000000..c2317e9 --- /dev/null +++ b/iredis/data/commands/zmscore.md @@ -0,0 +1,16 @@ +Returns the scores associated with the specified `members` in the sorted set stored at `key`. + +For every `member` that does not exist in the sorted set, a `nil` value is returned. + +@return + +@array-reply: list of scores or `nil` associated with the specified `member` values (a double precision floating point number), +represented as strings. + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZMSCORE myzset "one" "two" "nofield" +``` diff --git a/iredis/data/commands/zpopmax.md b/iredis/data/commands/zpopmax.md new file mode 100644 index 0000000..8f6750a --- /dev/null +++ b/iredis/data/commands/zpopmax.md @@ -0,0 +1,20 @@ +Removes and returns up to `count` members with the highest scores in the sorted +set stored at `key`. + +When left unspecified, the default value for `count` is 1. Specifying a `count` +value that is higher than the sorted set's cardinality will not produce an +error. When returning multiple elements, the one with the highest score will +be the first, followed by the elements with lower scores. + +@return + +@array-reply: list of popped elements and scores. + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZADD myzset 3 "three" +ZPOPMAX myzset +``` diff --git a/iredis/data/commands/zpopmin.md b/iredis/data/commands/zpopmin.md new file mode 100644 index 0000000..16f7c97 --- /dev/null +++ b/iredis/data/commands/zpopmin.md @@ -0,0 +1,20 @@ +Removes and returns up to `count` members with the lowest scores in the sorted +set stored at `key`. + +When left unspecified, the default value for `count` is 1. Specifying a `count` +value that is higher than the sorted set's cardinality will not produce an +error. When returning multiple elements, the one with the lowest score will +be the first, followed by the elements with greater scores. + +@return + +@array-reply: list of popped elements and scores. + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZADD myzset 3 "three" +ZPOPMIN myzset +``` diff --git a/iredis/data/commands/zrandmember.md b/iredis/data/commands/zrandmember.md new file mode 100644 index 0000000..aae0b25 --- /dev/null +++ b/iredis/data/commands/zrandmember.md @@ -0,0 +1,39 @@ +When called with just the `key` argument, return a random element from the sorted set value stored at `key`. + +If the provided `count` argument is positive, return an array of **distinct elements**. +The array's length is either `count` or the sorted set's cardinality (`ZCARD`), whichever is lower. + +If called with a negative `count`, the behavior changes and the command is allowed to return the **same element multiple times**. +In this case, the number of returned elements is the absolute value of the specified `count`. + +The optional `WITHSCORES` modifier changes the reply so it includes the respective scores of the randomly selected elements from the sorted set. + +@return + +@bulk-string-reply: without the additional `count` argument, the command returns a Bulk Reply with the randomly selected element, or `nil` when `key` does not exist. + +@array-reply: when the additional `count` argument is passed, the command returns an array of elements, or an empty array when `key` does not exist. +If the `WITHSCORES` modifier is used, the reply is a list elements and their scores from the sorted set. + +@examples + +```cli +ZADD dadi 1 uno 2 due 3 tre 4 quattro 5 cinque 6 sei +ZRANDMEMBER dadi +ZRANDMEMBER dadi +ZRANDMEMBER dadi -5 WITHSCORES +``` + +## Specification of the behavior when count is passed + +When the `count` argument is a positive value this command behaves as follows: + +* No repeated elements are returned. +* If `count` is bigger than the cardinality of the sorted set, the command will only return the whole sorted set without additional elements. +* The order of elements in the reply is not truly random, so it is up to the client to shuffle them if needed. + +When the `count` is a negative value, the behavior changes as follows: + +* Repeating elements are possible. +* Exactly `count` elements, or an empty array if the sorted set is empty (non-existing key), are always returned. +* The order of elements in the reply is truly random. diff --git a/iredis/data/commands/zrange.md b/iredis/data/commands/zrange.md new file mode 100644 index 0000000..1a8e421 --- /dev/null +++ b/iredis/data/commands/zrange.md @@ -0,0 +1,129 @@ +Returns the specified range of elements in the sorted set stored at `<key>`. + +`ZRANGE` can perform different types of range queries: by index (rank), by the score, or by lexicographical order. + +Starting with Redis 6.2.0, this command can replace the following commands: `ZREVRANGE`, `ZRANGEBYSCORE`, `ZREVRANGEBYSCORE`, `ZRANGEBYLEX` and `ZREVRANGEBYLEX`. + +## Common behavior and options + +The order of elements is from the lowest to the highest score. Elements with the same score are ordered lexicographically. + +The optional `REV` argument reverses the ordering, so elements are ordered from highest to lowest score, and score ties are resolved by reverse lexicographical ordering. + +The optional `LIMIT` argument can be used to obtain a sub-range from the matching elements (similar to _SELECT LIMIT offset, count_ in SQL). +A negative `<count>` returns all elements from the `<offset>`. Keep in mind that if `<offset>` is large, the sorted set needs to be traversed for `<offset>` elements before getting to the elements to return, which can add up to O(N) time complexity. + +The optional `WITHSCORES` argument supplements the command's reply with the scores of elements returned. The returned list contains `value1,score1,...,valueN,scoreN` instead of `value1,...,valueN`. Client libraries are free to return a more appropriate data type (suggestion: an array with (value, score) arrays/tuples). + +## Index ranges + +By default, the command performs an index range query. The `<start>` and `<stop>` arguments represent zero-based indexes, where `0` is the first element, `1` is the next element, and so on. These arguments specify an **inclusive range**, so for example, `ZRANGE myzset 0 1` will return both the first and the second element of the sorted set. + +The indexes can also be negative numbers indicating offsets from the end of the sorted set, with `-1` being the last element of the sorted set, `-2` the penultimate element, and so on. + +Out of range indexes do not produce an error. + +If `<start>` is greater than either the end index of the sorted set or `<stop>`, an empty list is returned. + +If `<stop>` is greater than the end index of the sorted set, Redis will use the last element of the sorted set. + +## Score ranges + +When the `BYSCORE` option is provided, the command behaves like `ZRANGEBYSCORE` and returns the range of elements from the sorted set having scores equal or between `<start>` and `<stop>`. + +`<start>` and `<stop>` can be `-inf` and `+inf`, denoting the negative and positive infinities, respectively. This means that you are not required to know the highest or lowest score in the sorted set to get all elements from or up to a certain score. + +By default, the score intervals specified by `<start>` and `<stop>` are closed (inclusive). +It is possible to specify an open interval (exclusive) by prefixing the score +with the character `(`. + +For example: + +``` +ZRANGE zset (1 5 BYSCORE +``` + +Will return all elements with `1 < score <= 5` while: + +``` +ZRANGE zset (5 (10 BYSCORE +``` + +Will return all the elements with `5 < score < 10` (5 and 10 excluded). + +## Reverse ranges + +Using the `REV` option reverses the sorted set, with index 0 as the element with the highest score. + +By default, `<start>` must be less than or equal to `<stop>` to return anything. +However, if the `BYSCORE`, or `BYLEX` options are selected, the `<start>` is the highest score to consider, and `<stop>` is the lowest score to consider, therefore `<start>` must be greater than or equal to `<stop>` in order to return anything. + +For example: + +``` +ZRANGE zset 5 10 REV +``` + +Will return the elements between index 5 and 10 in the reversed index. + +``` +ZRANGE zset 10 5 REV BYSCORE +``` + +Will return all elements with scores less than 10 and greater than 5. + +## Lexicographical ranges + +When the `BYLEX` option is used, the command behaves like `ZRANGEBYLEX` and returns the range of elements from the sorted set between the `<start>` and `<stop>` lexicographical closed range intervals. + +Note that lexicographical ordering relies on all elements having the same score. The reply is unspecified when the elements have different scores. + +Valid `<start>` and `<stop>` must start with `(` or `[`, in order to specify +whether the range interval is exclusive or inclusive, respectively. + +The special values of `+` or `-` for `<start>` and `<stop>` mean positive and negative infinite strings, respectively, so for instance the command `ZRANGE myzset - + BYLEX` is guaranteed to return all the elements in the sorted set, providing that all the elements have the same score. + +The `REV` options reverses the order of the `<start>` and `<stop>` elements, where `<start>` must be lexicographically greater than `<stop>` to produce a non-empty result. + +### Lexicographical comparison of strings + +Strings are compared as a binary array of bytes. Because of how the ASCII character set is specified, this means that usually this also have the effect of comparing normal ASCII characters in an obvious dictionary way. However, this is not true if non-plain ASCII strings are used (for example, utf8 strings). + +However, the user can apply a transformation to the encoded string so that the first part of the element inserted in the sorted set will compare as the user requires for the specific application. For example, if I want to +add strings that will be compared in a case-insensitive way, but I still +want to retrieve the real case when querying, I can add strings in the +following way: + + ZADD autocomplete 0 foo:Foo 0 bar:BAR 0 zap:zap + +Because of the first *normalized* part in every element (before the colon character), we are forcing a given comparison. However, after the range is queried using `ZRANGE ... BYLEX`, the application can display to the user the second part of the string, after the colon. + +The binary nature of the comparison allows to use sorted sets as a general purpose index, for example, the first part of the element can be a 64-bit big-endian number. Since big-endian numbers have the most significant bytes in the initial positions, the binary comparison will match the numerical comparison of the numbers. This can be used in order to implement range queries on 64-bit values. As in the example below, after the first 8 bytes, we can store the value of the element we are indexing. + +@return + +@array-reply: list of elements in the specified range (optionally with +their scores, in case the `WITHSCORES` option is given). + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZADD myzset 3 "three" +ZRANGE myzset 0 -1 +ZRANGE myzset 2 3 +ZRANGE myzset -2 -1 +``` + +The following example using `WITHSCORES` shows how the command returns always an array, but this time, populated with *element_1*, *score_1*, *element_2*, *score_2*, ..., *element_N*, *score_N*. + +```cli +ZRANGE myzset 0 1 WITHSCORES +``` + +This example shows how to query the sorted set by score, excluding the value `1` and up to infinity, returning only the second element of the result: + +```cli +ZRANGE myzset (1 +inf BYSCORE LIMIT 1 1 +```
\ No newline at end of file diff --git a/iredis/data/commands/zrangebylex.md b/iredis/data/commands/zrangebylex.md new file mode 100644 index 0000000..4eefffc --- /dev/null +++ b/iredis/data/commands/zrangebylex.md @@ -0,0 +1,61 @@ +When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at `key` with a value between `min` and `max`. + +If the elements in the sorted set have different scores, the returned elements are unspecified. + +The elements are considered to be ordered from lower to higher strings as compared byte-by-byte using the `memcmp()` C function. Longer strings are considered greater than shorter strings if the common part is identical. + +The optional `LIMIT` argument can be used to only get a range of the matching +elements (similar to _SELECT LIMIT offset, count_ in SQL). A negative `count` +returns all elements from the `offset`. +Keep in mind that if `offset` is large, the sorted set needs to be traversed for +`offset` elements before getting to the elements to return, which can add up to +O(N) time complexity. + +## How to specify intervals + +Valid *start* and *stop* must start with `(` or `[`, in order to specify +if the range item is respectively exclusive or inclusive. +The special values of `+` or `-` for *start* and *stop* have the special +meaning or positively infinite and negatively infinite strings, so for +instance the command **ZRANGEBYLEX myzset - +** is guaranteed to return +all the elements in the sorted set, if all the elements have the same +score. + +## Details on strings comparison + +Strings are compared as binary array of bytes. Because of how the ASCII character +set is specified, this means that usually this also have the effect of comparing +normal ASCII characters in an obvious dictionary way. However this is not true +if non plain ASCII strings are used (for example utf8 strings). + +However the user can apply a transformation to the encoded string so that +the first part of the element inserted in the sorted set will compare as the +user requires for the specific application. For example if I want to +add strings that will be compared in a case-insensitive way, but I still +want to retrieve the real case when querying, I can add strings in the +following way: + + ZADD autocomplete 0 foo:Foo 0 bar:BAR 0 zap:zap + +Because of the first *normalized* part in every element (before the colon character), we are forcing a given comparison, however after the range is queries using `ZRANGEBYLEX` the application can display to the user the second part of the string, after the colon. + +The binary nature of the comparison allows to use sorted sets as a general +purpose index, for example the first part of the element can be a 64 bit +big endian number: since big endian numbers have the most significant bytes +in the initial positions, the binary comparison will match the numerical +comparison of the numbers. This can be used in order to implement range +queries on 64 bit values. As in the example below, after the first 8 bytes +we can store the value of the element we are actually indexing. + +@return + +@array-reply: list of elements in the specified score range. + +@examples + +```cli +ZADD myzset 0 a 0 b 0 c 0 d 0 e 0 f 0 g +ZRANGEBYLEX myzset - [c +ZRANGEBYLEX myzset - (c +ZRANGEBYLEX myzset [aaa (g +``` diff --git a/iredis/data/commands/zrangebyscore.md b/iredis/data/commands/zrangebyscore.md new file mode 100644 index 0000000..bc81708 --- /dev/null +++ b/iredis/data/commands/zrangebyscore.md @@ -0,0 +1,102 @@ +Returns all the elements in the sorted set at `key` with a score between `min` +and `max` (including elements with score equal to `min` or `max`). +The elements are considered to be ordered from low to high scores. + +The elements having the same score are returned in lexicographical order (this +follows from a property of the sorted set implementation in Redis and does not +involve further computation). + +The optional `LIMIT` argument can be used to only get a range of the matching +elements (similar to _SELECT LIMIT offset, count_ in SQL). A negative `count` +returns all elements from the `offset`. +Keep in mind that if `offset` is large, the sorted set needs to be traversed for +`offset` elements before getting to the elements to return, which can add up to +O(N) time complexity. + +The optional `WITHSCORES` argument makes the command return both the element and +its score, instead of the element alone. +This option is available since Redis 2.0. + +## Exclusive intervals and infinity + +`min` and `max` can be `-inf` and `+inf`, so that you are not required to know +the highest or lowest score in the sorted set to get all elements from or up to +a certain score. + +By default, the interval specified by `min` and `max` is closed (inclusive). +It is possible to specify an open interval (exclusive) by prefixing the score +with the character `(`. +For example: + +``` +ZRANGEBYSCORE zset (1 5 +``` + +Will return all elements with `1 < score <= 5` while: + +``` +ZRANGEBYSCORE zset (5 (10 +``` + +Will return all the elements with `5 < score < 10` (5 and 10 excluded). + +@return + +@array-reply: list of elements in the specified score range (optionally +with their scores). + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZADD myzset 3 "three" +ZRANGEBYSCORE myzset -inf +inf +ZRANGEBYSCORE myzset 1 2 +ZRANGEBYSCORE myzset (1 2 +ZRANGEBYSCORE myzset (1 (2 +``` + +## Pattern: weighted random selection of an element + +Normally `ZRANGEBYSCORE` is simply used in order to get range of items +where the score is the indexed integer key, however it is possible to do less +obvious things with the command. + +For example a common problem when implementing Markov chains and other algorithms +is to select an element at random from a set, but different elements may have +different weights that change how likely it is they are picked. + +This is how we use this command in order to mount such an algorithm: + +Imagine you have elements A, B and C with weights 1, 2 and 3. +You compute the sum of the weights, which is 1+2+3 = 6 + +At this point you add all the elements into a sorted set using this algorithm: + +``` +SUM = ELEMENTS.TOTAL_WEIGHT // 6 in this case. +SCORE = 0 +FOREACH ELE in ELEMENTS + SCORE += ELE.weight / SUM + ZADD KEY SCORE ELE +END +``` + +This means that you set: + +``` +A to score 0.16 +B to score .5 +C to score 1 +``` + +Since this involves approximations, in order to avoid C is set to, +like, 0.998 instead of 1, we just modify the above algorithm to make sure +the last score is 1 (left as an exercise for the reader...). + +At this point, each time you want to get a weighted random element, +just compute a random number between 0 and 1 (which is like calling +`rand()` in most languages), so you can just do: + + RANDOM_ELE = ZRANGEBYSCORE key RAND() +inf LIMIT 0 1 diff --git a/iredis/data/commands/zrangestore.md b/iredis/data/commands/zrangestore.md new file mode 100644 index 0000000..8dc744c --- /dev/null +++ b/iredis/data/commands/zrangestore.md @@ -0,0 +1,13 @@ +This command is like `ZRANGE`, but stores the result in the `<dst>` destination key. + +@return + +@integer-reply: the number of elements in the resulting sorted set. + +@examples + +```cli +ZADD srczset 1 "one" 2 "two" 3 "three" 4 "four" +ZRANGESTORE dstzset srczset 2 -1 +ZRANGE dstzset 0 -1 +``` diff --git a/iredis/data/commands/zrank.md b/iredis/data/commands/zrank.md new file mode 100644 index 0000000..1419adf --- /dev/null +++ b/iredis/data/commands/zrank.md @@ -0,0 +1,23 @@ +Returns the rank of `member` in the sorted set stored at `key`, with the scores +ordered from low to high. +The rank (or index) is 0-based, which means that the member with the lowest +score has rank `0`. + +Use `ZREVRANK` to get the rank of an element with the scores ordered from high +to low. + +@return + +* If `member` exists in the sorted set, @integer-reply: the rank of `member`. +* If `member` does not exist in the sorted set or `key` does not exist, + @bulk-string-reply: `nil`. + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZADD myzset 3 "three" +ZRANK myzset "three" +ZRANK myzset "four" +``` diff --git a/iredis/data/commands/zrem.md b/iredis/data/commands/zrem.md new file mode 100644 index 0000000..d97fd4b --- /dev/null +++ b/iredis/data/commands/zrem.md @@ -0,0 +1,21 @@ +Removes the specified members from the sorted set stored at `key`. +Non existing members are ignored. + +An error is returned when `key` exists and does not hold a sorted set. + +@return + +@integer-reply, specifically: + +* The number of members removed from the sorted set, not including non existing + members. + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZADD myzset 3 "three" +ZREM myzset "two" +ZRANGE myzset 0 -1 WITHSCORES +``` diff --git a/iredis/data/commands/zremrangebylex.md b/iredis/data/commands/zremrangebylex.md new file mode 100644 index 0000000..4264f1b --- /dev/null +++ b/iredis/data/commands/zremrangebylex.md @@ -0,0 +1,17 @@ +When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command removes all elements in the sorted set stored at `key` between the lexicographical range specified by `min` and `max`. + +The meaning of `min` and `max` are the same of the `ZRANGEBYLEX` command. Similarly, this command actually removes the same elements that `ZRANGEBYLEX` would return if called with the same `min` and `max` arguments. + +@return + +@integer-reply: the number of elements removed. + +@examples + +```cli +ZADD myzset 0 aaaa 0 b 0 c 0 d 0 e +ZADD myzset 0 foo 0 zap 0 zip 0 ALPHA 0 alpha +ZRANGE myzset 0 -1 +ZREMRANGEBYLEX myzset [alpha [omega +ZRANGE myzset 0 -1 +``` diff --git a/iredis/data/commands/zremrangebyrank.md b/iredis/data/commands/zremrangebyrank.md new file mode 100644 index 0000000..edd3cf3 --- /dev/null +++ b/iredis/data/commands/zremrangebyrank.md @@ -0,0 +1,22 @@ +Removes all elements in the sorted set stored at `key` with rank between `start` +and `stop`. +Both `start` and `stop` are `0` -based indexes with `0` being the element with +the lowest score. +These indexes can be negative numbers, where they indicate offsets starting at +the element with the highest score. +For example: `-1` is the element with the highest score, `-2` the element with +the second highest score and so forth. + +@return + +@integer-reply: the number of elements removed. + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZADD myzset 3 "three" +ZREMRANGEBYRANK myzset 0 1 +ZRANGE myzset 0 -1 WITHSCORES +``` diff --git a/iredis/data/commands/zremrangebyscore.md b/iredis/data/commands/zremrangebyscore.md new file mode 100644 index 0000000..fdf9a98 --- /dev/null +++ b/iredis/data/commands/zremrangebyscore.md @@ -0,0 +1,16 @@ +Removes all elements in the sorted set stored at `key` with a score between +`min` and `max` (inclusive). + +@return + +@integer-reply: the number of elements removed. + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZADD myzset 3 "three" +ZREMRANGEBYSCORE myzset -inf (2 +ZRANGE myzset 0 -1 WITHSCORES +``` diff --git a/iredis/data/commands/zrevrange.md b/iredis/data/commands/zrevrange.md new file mode 100644 index 0000000..3a19810 --- /dev/null +++ b/iredis/data/commands/zrevrange.md @@ -0,0 +1,21 @@ +Returns the specified range of elements in the sorted set stored at `key`. +The elements are considered to be ordered from the highest to the lowest score. +Descending lexicographical order is used for elements with equal score. + +Apart from the reversed ordering, `ZREVRANGE` is similar to `ZRANGE`. + +@return + +@array-reply: list of elements in the specified range (optionally with +their scores). + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZADD myzset 3 "three" +ZREVRANGE myzset 0 -1 +ZREVRANGE myzset 2 3 +ZREVRANGE myzset -2 -1 +``` diff --git a/iredis/data/commands/zrevrangebylex.md b/iredis/data/commands/zrevrangebylex.md new file mode 100644 index 0000000..c6772c9 --- /dev/null +++ b/iredis/data/commands/zrevrangebylex.md @@ -0,0 +1,16 @@ +When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at `key` with a value between `max` and `min`. + +Apart from the reversed ordering, `ZREVRANGEBYLEX` is similar to `ZRANGEBYLEX`. + +@return + +@array-reply: list of elements in the specified score range. + +@examples + +```cli +ZADD myzset 0 a 0 b 0 c 0 d 0 e 0 f 0 g +ZREVRANGEBYLEX myzset [c - +ZREVRANGEBYLEX myzset (c - +ZREVRANGEBYLEX myzset (g [aaa +``` diff --git a/iredis/data/commands/zrevrangebyscore.md b/iredis/data/commands/zrevrangebyscore.md new file mode 100644 index 0000000..e95d771 --- /dev/null +++ b/iredis/data/commands/zrevrangebyscore.md @@ -0,0 +1,27 @@ +Returns all the elements in the sorted set at `key` with a score between `max` +and `min` (including elements with score equal to `max` or `min`). +In contrary to the default ordering of sorted sets, for this command the +elements are considered to be ordered from high to low scores. + +The elements having the same score are returned in reverse lexicographical +order. + +Apart from the reversed ordering, `ZREVRANGEBYSCORE` is similar to +`ZRANGEBYSCORE`. + +@return + +@array-reply: list of elements in the specified score range (optionally +with their scores). + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZADD myzset 3 "three" +ZREVRANGEBYSCORE myzset +inf -inf +ZREVRANGEBYSCORE myzset 2 1 +ZREVRANGEBYSCORE myzset 2 (1 +ZREVRANGEBYSCORE myzset (2 (1 +``` diff --git a/iredis/data/commands/zrevrank.md b/iredis/data/commands/zrevrank.md new file mode 100644 index 0000000..6c64d98 --- /dev/null +++ b/iredis/data/commands/zrevrank.md @@ -0,0 +1,23 @@ +Returns the rank of `member` in the sorted set stored at `key`, with the scores +ordered from high to low. +The rank (or index) is 0-based, which means that the member with the highest +score has rank `0`. + +Use `ZRANK` to get the rank of an element with the scores ordered from low to +high. + +@return + +* If `member` exists in the sorted set, @integer-reply: the rank of `member`. +* If `member` does not exist in the sorted set or `key` does not exist, + @bulk-string-reply: `nil`. + +@examples + +```cli +ZADD myzset 1 "one" +ZADD myzset 2 "two" +ZADD myzset 3 "three" +ZREVRANK myzset "one" +ZREVRANK myzset "four" +``` diff --git a/iredis/data/commands/zscan.md b/iredis/data/commands/zscan.md new file mode 100644 index 0000000..3926307 --- /dev/null +++ b/iredis/data/commands/zscan.md @@ -0,0 +1 @@ +See `SCAN` for `ZSCAN` documentation. diff --git a/iredis/data/commands/zscore.md b/iredis/data/commands/zscore.md new file mode 100644 index 0000000..8b1e74d --- /dev/null +++ b/iredis/data/commands/zscore.md @@ -0,0 +1,16 @@ +Returns the score of `member` in the sorted set at `key`. + +If `member` does not exist in the sorted set, or `key` does not exist, `nil` is +returned. + +@return + +@bulk-string-reply: the score of `member` (a double precision floating point number), +represented as string. + +@examples + +```cli +ZADD myzset 1 "one" +ZSCORE myzset "one" +``` diff --git a/iredis/data/commands/zunion.md b/iredis/data/commands/zunion.md new file mode 100644 index 0000000..d77d81f --- /dev/null +++ b/iredis/data/commands/zunion.md @@ -0,0 +1,21 @@ +This command is similar to `ZUNIONSTORE`, but instead of storing the resulting +sorted set, it is returned to the client. + +For a description of the `WEIGHTS` and `AGGREGATE` options, see `ZUNIONSTORE`. + +@return + +@array-reply: the result of union (optionally with their scores, in case +the `WITHSCORES` option is given). + +@examples + +```cli +ZADD zset1 1 "one" +ZADD zset1 2 "two" +ZADD zset2 1 "one" +ZADD zset2 2 "two" +ZADD zset2 3 "three" +ZUNION 2 zset1 zset2 +ZUNION 2 zset1 zset2 WITHSCORES +``` diff --git a/iredis/data/commands/zunionstore.md b/iredis/data/commands/zunionstore.md new file mode 100644 index 0000000..49e2d50 --- /dev/null +++ b/iredis/data/commands/zunionstore.md @@ -0,0 +1,39 @@ +Computes the union of `numkeys` sorted sets given by the specified keys, and +stores the result in `destination`. +It is mandatory to provide the number of input keys (`numkeys`) before passing +the input keys and the other (optional) arguments. + +By default, the resulting score of an element is the sum of its scores in the +sorted sets where it exists. + +Using the `WEIGHTS` option, it is possible to specify a multiplication factor +for each input sorted set. +This means that the score of every element in every input sorted set is +multiplied by this factor before being passed to the aggregation function. +When `WEIGHTS` is not given, the multiplication factors default to `1`. + +With the `AGGREGATE` option, it is possible to specify how the results of the +union are aggregated. +This option defaults to `SUM`, where the score of an element is summed across +the inputs where it exists. +When this option is set to either `MIN` or `MAX`, the resulting set will contain +the minimum or maximum score of an element across the inputs where it exists. + +If `destination` already exists, it is overwritten. + +@return + +@integer-reply: the number of elements in the resulting sorted set at +`destination`. + +@examples + +```cli +ZADD zset1 1 "one" +ZADD zset1 2 "two" +ZADD zset2 1 "one" +ZADD zset2 2 "two" +ZADD zset2 3 "three" +ZUNIONSTORE out 2 zset1 zset2 WEIGHTS 2 3 +ZRANGE out 0 -1 WITHSCORES +``` diff --git a/iredis/data/dangerous_commands.csv b/iredis/data/dangerous_commands.csv new file mode 100644 index 0000000..f42caa5 --- /dev/null +++ b/iredis/data/dangerous_commands.csv @@ -0,0 +1,13 @@ +Command,Reason +FLUSHDB,"FLUSHDB will delete all the keys of the currently selected DB" +FLUSHALL,"FLUSHALL will delete all the keys of all the existing databases" +KEYS,"KEYS will hang redis server, use SCAN instead" +PEXPIRE,"PEXPIRE may delete keys" +DEL,"DEL will delete keys, it may cause high latency when the value is big" +CONFIG SET,"CONFIG SET will change the server's configs" +SHUTDOWN,"SHUTDOWN will shutdown the server" +SAVE,"SAVE performs a synchronous save, it will hang redis server" +SPOP,"SPOP will delete items" +SREM,"SREM will delete items" +RENAME,"RENAME use DELETE command to overwrite exist key, it may cause high latency when the value is big" +DEBUG,"It's a dangerous command" diff --git a/iredis/data/iredisrc b/iredis/data/iredisrc new file mode 100644 index 0000000..6db02a7 --- /dev/null +++ b/iredis/data/iredisrc @@ -0,0 +1,82 @@ +# vi: ft=dosini +[main] +# weather display raw redis response +raw = False + +# iredis use a LRU strategy to store the completions, like keys, set members, +# etc, this will set how many completions can iredis keep at most. +completer_max = 300 + +# Completion casing preference, options are: "lower", "upper", "auto" +completion_casing = auto + +# if in newbie_mode, a description of commands and options will showup along +# with completion, encourage to enable it to who is new to redis +newbie_mode = False + +# show prompt in a ranibow color +rainbow = False + +# retry times for connection error and timeout +retry_times = 2 + +socket_keepalive = True + +# IRedis support running shell command to parse the response, like this: +# > get json-str | jq . +# However that will allow any shell command to execute under iredis REPL, +# you can disable this feature by setting this to False. +# Default is True. +shell = True + +# decode redis response, default None +decode = + +# enable pager? default to True, you can disable it by changing it to False +enable_pager = True + +# pager setting when line is too tall +# By default 'PAGER' environment variable is used +# pager = less -SRXF + +# iredis will send a `INFO` command to get the server's version, this option can +# disable it +no_info = False + +# iredis will show command hint on bottom bar, this option can disable it +bottom_bar = True + +# Dangerous command warning mode will alert you before executing a dangerous +# command, that may cause harm to the redis-server or hang server, +# such as "KEYS", "DEL" or "SHUTDOWN". +warning = True + +# IRedis log for debugging, leave this blank will disable log. +# You don't need this unless you are debugging iredis. +# Be careful this will log your commands input (include AUTH with password) to +# log file. +# eg. ~/.iredis.log +log_location = + +# You can change the prompt str, if left blank, the default prompt would be: +# 127.0.0.1:6379> +# which is rendered by "{host}:{port}[{db}]> " +# supported interpolations: +# {client_name} +# {db} +# {host} +# {path} +# {port} +# {username} +# {client_addr} +# {client_id} +# The prompt string uses python string format engine +prompt = + +# History file location +history_location = ~/.iredis_history + +[alias_dsn] +# example_dsn = redis://[[username]:[password]]@localhost:6379/0 +# example_dsn = rediss://[[username]:[password]]@localhost:6379/0 +# example_dsn = unix://[[username]:[password]]@/path/to/socket.sock?db=0 diff --git a/iredis/entry.py b/iredis/entry.py new file mode 100644 index 0000000..c7ae76c --- /dev/null +++ b/iredis/entry.py @@ -0,0 +1,496 @@ +# -*- coding: utf-8 -*- +import os +import logging +import sys +import time +from pathlib import Path +import platform + +import click +from prompt_toolkit import PromptSession +from prompt_toolkit.history import FileHistory +from prompt_toolkit.auto_suggest import AutoSuggestFromHistory +from prompt_toolkit import print_formatted_text +from prompt_toolkit.formatted_text import FormattedText +from prompt_toolkit.key_binding.bindings.named_commands import ( + register as prompt_register, +) + +from .client import Client +from .key_bindings import kb as key_bindings +from .style import STYLE +from .config import config, load_config_files +from .processors import UserInputCommand, UpdateBottomProcessor, PasswordProcessor +from .bottom import BottomToolbar +from .utils import timer, exit, convert_formatted_text_to_bytes, parse_url +from .completers import IRedisCompleter +from .lexer import IRedisLexer +from . import __version__ + +logger = logging.getLogger(__name__) + + +class SkipAuthFileHistory(FileHistory): + """Exactlly like FileHistory, but won't save `AUTH` command into history + file.""" + + def append_string(self, string: str) -> None: + if string.lstrip().upper().startswith("AUTH"): + return + super().append_string(string) + + +def setup_log(): + if config.log_location: + logging.basicConfig( + filename=os.path.expanduser(config.log_location), + filemode="a", + format="%(levelname)5s %(message)s", + level="DEBUG", + ) + else: + logging.disable(logging.CRITICAL) + logger.info("------ iRedis ------") + + +def greetings(): + iredis_version = f"iredis {__version__} (Python {platform.python_version()})" + if config.no_version_reason: + reason = f"({config.no_version_reason})" + else: + reason = "" + + server_version = f"redis-server {config.version} {reason}" + home_page = "Home: https://iredis.io" + issues = "Issues: https://iredis.io/issues" + display = "\n".join([iredis_version, server_version, home_page, issues]) + if config.raw: + display = display.encode() + write_result(display) + + +def print_help_msg(command): + with click.Context(command) as ctx: + click.echo(command.get_help(ctx)) + + +def is_too_tall(text, max_height): + if isinstance(text, FormattedText): + text = convert_formatted_text_to_bytes(text) + lines = len(text.split(b"\n")) + return lines > max_height + + +def write_result(text, max_height=None): + """ + When config.raw set to True, write text(must be bytes in that case) + directly to stdout, same if text is bytes. + + :param text: is_raw: bytes or str, not raw: FormattedText + :is_raw: bool + """ + logger.info(f"Print result {type(text)}: {text}"[:200]) + + # this function only handle bytes or FormattedText + # if it's str, convert to bytes + if isinstance(text, str): + if config.decode: + text = text.encode(config.decode) + else: + text = text.encode() + + # using pager if too tall + if max_height and config.enable_pager and is_too_tall(text, max_height): + if isinstance(text, FormattedText): + text = convert_formatted_text_to_bytes(text) + os.environ["LESS"] = "-SRX" + # click.echo_via_pager only accepts str + if config.decode: + text = text.decode(config.decode) + else: + text = text.decode() + # TODO current pager doesn't support colors + click.echo_via_pager(text) + return + + if isinstance(text, bytes): + sys.stdout.buffer.write(text) + sys.stdout.write("\n") + else: + print_formatted_text(text, end="", style=STYLE) + print_formatted_text() + + +class Rainbow: + color = [ + "#cc2244", + "#bb4444", + "#996644", + "#cc8844", + "#ccaa44", + "#bbaa44", + "#99aa44", + "#778844", + "#55aa44", + "#33aa44", + "#11aa44", + "#11aa66", + "#11aa88", + "#11aaaa", + "#11aacc", + "#11aaee", + ] + + def __init__(self): + self.current = -1 + self.forword = 1 + + def __iter__(self): + return self + + def __next__(self): + self.current += self.forword + if 0 <= self.current < len(self.color): + # not to the end + return self.color[self.current] + else: + self.forword = -self.forword + self.current += 2 * self.forword + return self.color[self.current] + + +def prompt_message(client): + text = str(client) + if config.rainbow: + return list(zip(Rainbow(), text)) + return text + + +def repl(client, session, start_time): + command_holder = UserInputCommand() + timer(f"First REPL command enter, time cost: {time.time() - start_time}") + + while True: + logger.info("↓↓↓↓" * 10) + logger.info("REPL waiting for command...") + + try: + command = session.prompt( + prompt_message(client), + bottom_toolbar=BottomToolbar(command_holder).render + if config.bottom_bar + else None, + input_processors=[ + UpdateBottomProcessor(command_holder, session), + PasswordProcessor(), + ], + rprompt=lambda: "<transaction>" if config.transaction else None, + key_bindings=key_bindings, + enable_suspend=True, + ) + + except KeyboardInterrupt: + logger.warning("KeyboardInterrupt!") + continue + except EOFError: + exit() + command = command.strip() + logger.info(f"[Command] {command}") + + # blank input + if not command: + continue + + try: + answers = client.send_command(command, session.completer) + for answer in answers: + write_result( + answer, + # -1 is because 127.0.0.1:6379> takes one line + session.output.get_size().rows - session.reserve_space_for_menu - 1, + ) + # Error with previous command or exception + except Exception as e: + logger.exception(e) + # TODO red error color + print("(error)", str(e)) + + +RAW_HELP = """ +Use raw formatting for replies (default when STDOUT is not a tty). \ +However, you can use --no-raw to force formatted output even \ +when STDOUT is not a tty. +""" +DECODE_HELP = """ +decode response, default is No decode, which will output all bytes literals. +""" +RAINBOW = "Display colorful prompt." +DSN_HELP = """ +Use DSN configured into the [alias_dsn] section of iredisrc file. \ +(Can set with env `IREDIS_DSN`) +""" +URL_HELP = """ +Use Redis URL to indicate connection(Can set with env `IREDIS_URL`), Example: + redis://[[username]:[password]]@localhost:6379/0 + rediss://[[username]:[password]]@localhost:6379/0 + unix://[[username]:[password]]@/path/to/socket.sock?db=0 +""" +SHELL = """Allow to run shell commands, default to True.""" +PAGER_HELP = """Using pager when output is too tall for your window, default to True.""" +VERIFY_SSL_HELP = """Set the TLS certificate verification strategy""" + + +# command line entry here... +@click.command() +@click.pass_context +@click.option("-h", help="Server hostname (default: 127.0.0.1).", default="127.0.0.1") +@click.option("-p", help="Server port (default: 6379).", default="6379") +@click.option( + "-s", "--socket", default=None, help="Server socket (overrides hostname and port)." +) +@click.option("-n", help="Database number.(overwrites dsn/url's db number)", default=0) +@click.option( + "-u", + "--username", + help="User name used to auth, will be ignore for redis version < 6.", +) +@click.option("-a", "--password", help="Password to use when connecting to the server.") +@click.option("--url", default=None, envvar="IREDIS_URL", help=URL_HELP) +@click.option("-d", "--dsn", default=None, envvar="IREDIS_DSN", help=DSN_HELP) +@click.option( + "--newbie/--no-newbie", + default=None, + is_flag=True, + help="Show command hints and useful helps.", +) +@click.option( + "--iredisrc", + default="~/.iredisrc", + help="Config file for iredis, default is ~/.iredisrc.", +) +@click.option("--decode", default=None, help=DECODE_HELP) +@click.option("--client_name", help="Assign a name to the current connection.") +@click.option("--raw/--no-raw", default=None, is_flag=True, help=RAW_HELP) +@click.option("--rainbow/--no-rainbow", default=None, is_flag=True, help=RAINBOW) +@click.option("--shell/--no-shell", default=None, is_flag=True, help=SHELL) +@click.option("--pager/--no-pager", default=None, is_flag=True, help=PAGER_HELP) +@click.option( + "--verify-ssl", + default=None, + type=click.Choice(["none", "optional", "required"]), + help=VERIFY_SSL_HELP, +) +@click.option( + "--prompt", + default=None, + help=( + "Prompt format (supported interpolations: {client_name}, {db}, {host}, {path}," + " {port}, {username}, {client_addr}, {client_id})." + ), +) +@click.version_option() +@click.argument("cmd", nargs=-1) +def gather_args( + ctx, + h, + p, + n, + username, + password, + client_name, + newbie, + iredisrc, + decode, + raw, + rainbow, + cmd, + dsn, + url, + socket, + shell, + pager, + verify_ssl, + prompt, +): + """ + IRedis: Interactive Redis + + When no command is given, IRedis starts in interactive mode. + + \b + Examples: + - iredis + - iredis -d dsn + - iredis -h 127.0.0.1 -p 6379 + - iredis -h 127.0.0.1 -p 6379 -a <password> + - iredis --url redis://localhost:7890/3 + + Type "help" in interactive mode for information on available commands + and settings. + """ + load_config_files(iredisrc) + setup_log() + logger.info( + f"[commandline args] host={h}, port={p}, db={n}, user={username}," + f" newbie={newbie}, iredisrc={iredisrc}, decode={decode}, raw={raw}, cmd={cmd}," + f" rainbow={rainbow}." + ) + # raw config + if raw is not None: + config.raw = raw + if not sys.stdout.isatty(): + config.raw = True + + if newbie is not None: + config.newbie_mode = newbie + + if decode is not None: + config.decode = decode + if rainbow is not None: + config.rainbow = rainbow + if shell is not None: + config.shell = shell + if pager is not None: + config.enable_pager = pager + if verify_ssl is not None: + config.verify_ssl = verify_ssl + + return ctx + + +@prompt_register("edit-and-execute-command") +def edit_and_execute(event): + """Different from the prompt-toolkit default, we want to have a choice not + to execute a query after editing, hence validate_and_handle=False.""" + buff = event.current_buffer + # this will prevent running command immediately when exit editor. + buff.open_in_editor(validate_and_handle=False) + + +def resolve_dsn(dsn): + try: + dsn_uri = config.alias_dsn[dsn] + except KeyError: + click.secho( + "Could not find the specified DSN in the config file. " + 'Please check the "[alias_dsn]" section in your ' + "iredisrc.", + err=True, + fg="red", + ) + sys.exit(1) + return dsn_uri + + +def create_client(params): + """ + Create a Client. + :param params: commandline params. + """ + host = params["h"] + port = params["p"] + db = params["n"] + username = params["username"] + password = params["password"] + client_name = params["client_name"] + prompt = params["prompt"] + verify_ssl = params["verify_ssl"] + + dsn_from_url = None + dsn = params["dsn"] + if config.alias_dsn and dsn: + dsn_uri = resolve_dsn(dsn) + dsn_from_url = parse_url(dsn_uri) + if params["url"]: + dsn_from_url = parse_url(params["url"]) + if dsn_from_url: + # db from command lint options should be high priority + db = db if db else dsn_from_url.db + verify_ssl = verify_ssl or dsn_from_url.verify_ssl + return Client( + host=dsn_from_url.host, + port=dsn_from_url.port, + db=db, + password=dsn_from_url.password, + path=dsn_from_url.path, + scheme=dsn_from_url.scheme, + username=dsn_from_url.username, + client_name=client_name, + prompt=prompt, + verify_ssl=verify_ssl, + ) + if params["socket"]: + return Client( + scheme="unix", + path=params["socket"], + db=db, + username=username, + password=password, + client_name=client_name, + prompt=prompt, + ) + return Client( + host=host, + port=port, + db=db, + username=username, + password=password, + client_name=client_name, + prompt=prompt, + verify_ssl=verify_ssl, + ) + + +def main(): + enter_main_time = time.time() # just for logs + + # invoke in non-standalone mode to gather args + ctx = None + try: + ctx = gather_args.main(standalone_mode=False) + except click.exceptions.NoSuchOption as nosuchoption: + nosuchoption.show() + except click.exceptions.BadOptionUsage as badoption: + if badoption.option_name == "-h": + # -h without host, is short command for --help + # like redis-cli + print_help_msg(gather_args) + return + if not ctx: # called help + return + + # redis client + client = create_client(ctx.params) + + if not sys.stdin.isatty(): + for line in sys.stdin.readlines(): + logger.debug(f"[Command stdin] {line}") + for answer in client.send_command(line, None): + write_result(answer) + return + + # no interactive mode, directly run a command + if ctx.params["cmd"]: + answers = client.send_command(" ".join(ctx.params["cmd"]), None) + for answer in answers: + write_result(answer) + logger.warning("[OVER] command executed, exit...") + return + + # prompt session + session = PromptSession( + history=SkipAuthFileHistory(Path(os.path.expanduser(config.history_location))), + style=STYLE, + auto_suggest=AutoSuggestFromHistory(), + complete_while_typing=True, + lexer=IRedisLexer(), + completer=IRedisCompleter( + hint=config.newbie_mode, completion_casing=config.completion_casing + ), + enable_open_in_editor=True, + tempfile_suffix=".redis", + ) + + # print hello message + greetings() + repl(client, session, enter_main_time) diff --git a/iredis/exceptions.py b/iredis/exceptions.py new file mode 100644 index 0000000..6aa45a1 --- /dev/null +++ b/iredis/exceptions.py @@ -0,0 +1,22 @@ +class IRedisException(Exception): + pass + + +class UsageError(IRedisException): + pass + + +class InvalidArguments(IRedisException): + """Invalid argument(s)""" + + +class NotRedisCommand(IRedisException): + """Not a Redis command""" + + +class AmbiguousCommand(IRedisException): + """Command is not finished, don't it's command's name""" + + +class NotSupport(IRedisException): + """IRedis currently not support this.""" diff --git a/iredis/key_bindings.py b/iredis/key_bindings.py new file mode 100644 index 0000000..fad4127 --- /dev/null +++ b/iredis/key_bindings.py @@ -0,0 +1,22 @@ +import logging + +from prompt_toolkit.filters import completion_is_selected +from prompt_toolkit.key_binding import KeyBindings + +logger = logging.getLogger(__name__) + +kb = KeyBindings() + + +@kb.add("enter", filter=completion_is_selected) +def _(event): + """Makes the enter key work as the tab key only when showing the menu. + In other words, don't execute query when enter is pressed in + the completion dropdown menu, instead close the dropdown menu + (accept current selection). + """ + logger.debug("Detected enter key.") + + event.current_buffer.complete_state = None + b = event.app.current_buffer + b.complete_state = None diff --git a/iredis/lexer.py b/iredis/lexer.py new file mode 100644 index 0000000..d1cfd57 --- /dev/null +++ b/iredis/lexer.py @@ -0,0 +1,101 @@ +from typing import Callable, Hashable + +from prompt_toolkit.contrib.regular_languages.lexer import GrammarLexer +from prompt_toolkit.document import Document +from prompt_toolkit.formatted_text.base import StyleAndTextTuples +from prompt_toolkit.lexers import Lexer, PygmentsLexer, SimpleLexer +from pygments.lexers.scripting import LuaLexer + +from .commands import split_command_args +from .exceptions import InvalidArguments, AmbiguousCommand +from .redis_grammar import CONST, get_command_grammar + + +def get_lexer_mapping(): + """ + Input command render color with lexer mapping below + + This converts token to styles in style.py + """ + # pygments token + # http://pygments.org/docs/tokens/ + lexers_dict = { + "key": SimpleLexer("class:key"), + "keys": SimpleLexer("class:key"), + "newkey": SimpleLexer("class:important-key"), + "destination": SimpleLexer("class:important-key"), + "member": SimpleLexer("class:member"), + "members": SimpleLexer("class:member"), + "value": SimpleLexer("class:string"), + "element": SimpleLexer("class:string"), + "svalue": SimpleLexer("class:string"), + "values": SimpleLexer("class:string"), + "lexmin": SimpleLexer("class:string"), + "lexmax": SimpleLexer("class:string"), + "bit": SimpleLexer("class:bit"), + "expiration": SimpleLexer("class:integer"), + "second": SimpleLexer("class:integer"), + "millisecond": SimpleLexer("class:integer"), + "start": SimpleLexer("class:integer"), + "float": SimpleLexer("class:integer"), + "end": SimpleLexer("class:integer"), + # stream id + "stream_id": SimpleLexer("class:integer"), + "group": SimpleLexer("class:group"), + "delta": SimpleLexer("class:integer"), + "offset": SimpleLexer("class:integer"), + "count": SimpleLexer("class:integer"), + "rank": SimpleLexer("class:integer"), + "index": SimpleLexer("class:index"), + "clientid": SimpleLexer("class:integer"), + "password": SimpleLexer("class:password"), + "min": SimpleLexer("class:integer"), + "max": SimpleLexer("class:integer"), + "score": SimpleLexer("class:integer"), + "timeout": SimpleLexer("class:integer"), + "position": SimpleLexer("class:integer"), + "cursor": SimpleLexer("class:integer"), + "pattern": SimpleLexer("class:pattern"), + "type": SimpleLexer("class:string"), + "fields": SimpleLexer("class:field"), + "field": SimpleLexer("class:field"), + "sfield": SimpleLexer("class:field"), + "parameter": SimpleLexer("class:field"), + "channel": SimpleLexer("class:channel"), + "double_lua": PygmentsLexer(LuaLexer), + "single_lua": PygmentsLexer(LuaLexer), + "command": SimpleLexer("class:command"), + "approximately": SimpleLexer("class:const"), + "username": SimpleLexer("class:username"), + } + + lexers_dict.update({key: SimpleLexer("class:const") for key in CONST}) + return lexers_dict + + +class IRedisLexer(Lexer): + """ + Lexer class that can dynamically returns any Lexer. + + :param get_lexer: Callable that returns a :class:`.Lexer` instance. + """ + + def __init__(self) -> None: + self._current_lexer = self._dummy = SimpleLexer() + + def lex_document(self, document: Document) -> Callable[[int], StyleAndTextTuples]: + input_text = document.text + + try: + command, _ = split_command_args(input_text) + # compile grammar for this command + grammar = get_command_grammar(command) + self._current_lexer = GrammarLexer(grammar, lexers=get_lexer_mapping()) + except (InvalidArguments, AmbiguousCommand): + self._current_lexer = self._dummy + + return self._current_lexer.lex_document(document) + + def invalidation_hash(self) -> Hashable: + lexer = self.get_lexer() or self._dummy + return id(lexer) diff --git a/iredis/markdown.py b/iredis/markdown.py new file mode 100644 index 0000000..6f26642 --- /dev/null +++ b/iredis/markdown.py @@ -0,0 +1,66 @@ +""" +Markdown render. + +use https://github.com/lepture/mistune render to html, then print with my style. +""" + +import logging +import mistune +import re +from prompt_toolkit.formatted_text import to_formatted_text, HTML + + +logger = logging.getLogger(__name__) + + +class TerminalRender(mistune.HTMLRenderer): + def _to_title(self, text): + return f"{text}\n{'='*len(text)}\n" + + def paragraph(self, text): + return text + "\n\n" + + def block_code(self, code, info=None): + code = "\n".join([" " + line for line in code.splitlines()]) + return super().block_code(code) + + def heading(self, text, level): + if level == 2: + header_text = self._to_title(text) + return super().heading(header_text, 2) + return super().heading(self._to_title(text), level) + + def list(self, body, ordered, level, start=None): + """Rendering list tags like ``<ul>`` and ``<ol>``. + + :param body: body contents of the list. + :param ordered: whether this list is ordered or not. + """ + tag = "ul" + if ordered: + tag = "ol" + return "<%s>%s</%s>\n" % (tag, body, tag) + + def list_item(self, text, level): + """Rendering list item snippet. Like ``<li>``.""" + return "<li> * %s</li>\n" % text + + +renderer = TerminalRender() +markdown_render = mistune.Markdown(renderer) + +# replace redis doc's title (and following newlines & spaces) +# with markdown's second level title +redisdoc_title_re = re.compile(r"^@(\w+) *(?:\n+|$)") + + +def replace_to_markdown_title(original): + replaced = redisdoc_title_re.sub(r"## \g<1>", original) + return replaced + + +def render(text): + replaced = replace_to_markdown_title(text) + html_text = markdown_render(replaced) + logger.debug("[Document] {} ...".format(html_text)[:20]) + return to_formatted_text(HTML(html_text)) diff --git a/iredis/processors.py b/iredis/processors.py new file mode 100644 index 0000000..029f80d --- /dev/null +++ b/iredis/processors.py @@ -0,0 +1,79 @@ +import logging + +from prompt_toolkit.layout.processors import ( + Processor, + Transformation, + TransformationInput, +) + +from .exceptions import InvalidArguments, AmbiguousCommand +from .commands import split_command_args + +logger = logging.getLogger(__name__) + + +class UserInputCommand: + """ + User inputted command in real time. + + ``UpdateBottomProcessor`` update it, and ``BottomToolbar`` read it + """ + + def __init__(self): + # command will always be upper case + self.command = None + + +class UpdateBottomProcessor(Processor): + """ + Update Footer display text while user input. + """ + + def __init__(self, command_holder, session): + # processor will call for internal_refresh, when input_text didn't + # change, don't run + self.session = session + self.command_holder = command_holder + + def apply_transformation( + self, transformation_input: TransformationInput + ) -> Transformation: + input_text = transformation_input.document.text + try: + command, _ = split_command_args(input_text) + except (InvalidArguments, AmbiguousCommand): + self.command_holder.command = None + else: + self.command_holder.command = command.upper() + + return Transformation(transformation_input.fragments) + + +class PasswordProcessor(Processor): + """ + Processor that turns masks the input. (For passwords.) + + :param char: (string) Character to be used. "*" by default. + """ + + def __init__(self, char: str = "*") -> None: + self.char = char + + def apply_transformation(self, ti: TransformationInput) -> Transformation: + input_text = ti.document.text + default_transformation = Transformation(ti.fragments) + try: + command, _ = split_command_args(input_text) + except (InvalidArguments, AmbiguousCommand): + return default_transformation + + if command.upper() != "AUTH": + return default_transformation + + fragments = [] + for style, text, *handler in ti.fragments: + if style == "class:password": + fragments.append((style, self.char * len(text), *handler)) + else: + fragments.append((style, text, *handler)) + return Transformation(fragments) diff --git a/iredis/redis_grammar.py b/iredis/redis_grammar.py new file mode 100644 index 0000000..391cdd8 --- /dev/null +++ b/iredis/redis_grammar.py @@ -0,0 +1,696 @@ +# noqa: F541 +""" +This module describes how to match a redis command to grammar token based on +regex. + +command_nodex: x means node? +command_keys: ends with s means there can be multiple <key> +""" +import logging +from functools import lru_cache + +from prompt_toolkit.contrib.regular_languages.compiler import compile +from .commands import command2syntax + +logger = logging.getLogger(__name__) +CONST = { + "failoverchoice": "TAKEOVER FORCE", + "withscores": "WITHSCORES", + "withvalues_const": "WITHVALUES", + "limit": "LIMIT", + "expiration": "EX PX", + "exat_const": "EXAT", + "pxat_const": "PXAT", + "condition": "NX XX", + "keepttl": "KEEPTTL", + "operation": "AND OR XOR NOT", + "changed": "CH", + "incr": "INCR", + "resetchoice": "HARD SOFT", + "match": "MATCH", + "count_const": "COUNT", + "const_store": "STORE", + "const_storedist": "STOREDIST", + "type_const": "TYPE", + "type": "string list set zset hash stream", + "position_choice": "BEFORE AFTER", + "error": "TIMEOUT ERROR", + "async": "ASYNC SYNC", + "conntype": "NORMAL MASTER REPLICA PUBSUB", + "samples": "SAMPLES", + "slotsubcmd": "IMPORTING MIGRATING NODE STABLE", + "weights_const": "WEIGHTS", + "aggregate_const": "AGGREGATE", + "aggregate": "SUM MIN MAX", + "slowlogsub": "LEN RESET GET", + "shutdown": "SAVE NOSAVE", + "switch": "ON OFF SKIP", + "on_off": "ON OFF", + "const_id": "ID", + "addr": "ADDR", + "laddr": "LADDR", + "skipme": "SKIPME", + "yes": "YES NO", + "migratechoice": "COPY REPLACE", + "auth": "AUTH", + "const_keys": "KEYS", + "object": "REFCOUNT ENCODING IDLETIME FREQ HELP", + "subrestore": "REPLACE ABSTTL IDLETIME FREQ", + "distunit": "m km ft mi", + "geochoice": "WITHCOORD WITHDIST WITHHASH", + "order": "ASC DESC", + "pubsubcmd": "CHANNELS NUMSUB NUMPAT", + "scriptdebug": "YES NO SYNC", + "help": "HELP", + "stream": "STREAM", + "streams": "STREAMS", + "stream_create": "CREATE", + "stream_setid": "SETID", + "stream_destroy": "DESTROY", + "stream_delconsumer": "DELCONSUMER", + "stream_consumers": "CONSUMERS", + "stream_groups": "GROUPS", + "stream_group": "GROUP", + "maxlen": "MAXLEN", + "idle": "IDLE", + "time": "TIME", + "retrycount": "RETRYCOUNT", + "force": "FORCE", + "justid": "JUSTID", + "block": "BLOCK", + "noack": "NOACK", + "get": "GET", + "set": "SET", + "incrby": "INCRBY", + "overflow": "OVERFLOW", + "overflow_option": "WRAP SAT FAIL", + "version": "VERSION", + "schedule": "SCHEDULE", + "graphevent": ( + "ACTIVE-DEFRAG-CYCLE " + "AOF-FSYNC-ALWAYS " + "AOF-STAT " + "AOF-REWRITE-DIFF-WRITE " + "AOF-RENAME " + "AOF-WRITE " + "AOF-WRITE-ACTIVE-CHILD " + "AOF-WRITE-ALONE " + "AOF-WRITE-PENDING-FSYNC " + "COMMAND " + "EXPIRE-CYCLE " + "EVICTION-CYCLE " + "EVICTION-DEL " + "FAST-COMMAND " + "FORK " + "RDB-UNLINK-TEMP-FILE" + ), + "section": ( + "SERVER " + "CLIENTS " + "MEMORY " + "PERSISTENCE " + "STATS " + "REPLICATION " + "CPU " + "COMMANDSTATS " + "CLUSTER " + "KEYSPACE " + "ALL " + "DEFAULT " + ), + "redirect_const": "REDIRECT", + "prefix_const": "PREFIX", + "bcast_const": "BCAST", + "optin_const": "OPTIN", + "optout_const": "OPTOUT", + "noloop_const": "NOLOOP", + "reset_const": "RESET", + "const_user": "USER", + "full_const": "FULL", + "str_algo": "LCS", + "len_const": "LEN", + "idx_const": "IDX", + "minmatchlen_const": "MINMATCHLEN", + "withmatchlen_const": "WITHMATCHLEN", + "strings_const": "STRINGS", + "rank_const": "RANK", + "lr_const": "LEFT RIGHT", + "pause_type": "WRITE ALL", + "db_const": "DB", + "replace_const": "REPLACE", + "to_const": "TO", + "timeout_const": "TIMEOUT", + "abort_const": "ABORT", +} + + +def c(const_name): + const_values = CONST[const_name].split() + uppers = [x.lower() for x in const_values] + const_values.extend(uppers) + return "|".join(const_values) + + +VALID_TOKEN = r"""( +("([^"]|\\")*?") |# with double quotes +('([^']|\\')*?') |# with single quotes +([^\s"]+) # without quotes +)""" +PATTERN = rf"(?P<pattern>{VALID_TOKEN})" +VALID_SLOT = r"\d+" # TODO add range? max value:16384 +VALID_NODE = r"\w+" +NUM = r"\d+" +NNUM = r"-?\+?\(?\[?(\d+|inf)" # number cloud be negative +_FLOAT = r"-?(\d|\.|e)+" +DOUBLE = r"\d*(\.\d+)?" +LEXNUM = r"(\[\w+)|(\(\w+)|(\+)|(-)" + +SLOT = rf"(?P<slot>{VALID_SLOT})" +SLOTS = rf"(?P<slots>{VALID_SLOT}(\s+{VALID_SLOT})*)" +NODE = rf"(?P<node>{VALID_NODE})" +KEY = rf"(?P<key>{VALID_TOKEN})" +KEYS = rf"(?P<keys>{VALID_TOKEN}(\s+{VALID_TOKEN})*)" +PREFIX = rf"(?P<prefix>{VALID_TOKEN})" +PREFIXES = rf"(?P<prefixes>{VALID_TOKEN}(\s+{VALID_TOKEN})*?)" +DESTINATION = rf"(?P<destination>{VALID_TOKEN})" +NEWKEY = rf"(?P<newkey>{VALID_TOKEN})" +VALUE = rf"(?P<value>{VALID_TOKEN})" +VALUES = rf"(?P<values>{VALID_TOKEN}(\s+{VALID_TOKEN})*)" +ELEMENT = rf"(?P<element>{VALID_TOKEN})" # element for list +FIELDS = rf"(?P<fields>{VALID_TOKEN}(\s+{VALID_TOKEN})*)" +FIELD = rf"(?P<field>{VALID_TOKEN})" +SFIELD = rf"(?P<sfield>{VALID_TOKEN})" +SVALUE = rf"(?P<svalue>{VALID_TOKEN})" +MEMBER = rf"(?P<member>{VALID_TOKEN})" +MEMBERS = rf"(?P<members>{VALID_TOKEN}(\s+{VALID_TOKEN})*)" +COUNT = rf"(?P<count>{NNUM})" +LEN = rf"(?P<len>{NNUM})" +RANK = rf"(?P<rank>{NNUM})" +VERSION_NUM = rf"(?P<version_num>{NUM})" +MESSAGE = rf"(?P<message>{VALID_TOKEN})" +CHANNEL = rf"(?P<channel>{VALID_TOKEN})" +GROUP = rf"(?P<group>{VALID_TOKEN})" +CONSUMER = rf"(?P<consumer>{VALID_TOKEN})" +CATEGORYNAME = rf"(?P<categoryname>{VALID_TOKEN})" +USERNAME = rf"(?P<username>{VALID_TOKEN})" +RULE = rf"(?P<rule>{VALID_TOKEN})" +BIT = r"(?P<bit>0|1)" +FLOAT = rf"(?P<float>{_FLOAT})" +LONGITUDE = rf"(?P<longitude>{_FLOAT})" +LATITUDE = rf"(?P<latitude>{_FLOAT})" +CURSOR = rf"(?P<cursor>{NUM})" +PARAMETER = rf"(?P<parameter>{VALID_TOKEN})" +DOUBLE_LUA = r'(?P<double_lua>[^"]*)' +SINGLE_LUA = r"(?P<single_lua>[^']*)" +INTTYPE = r"(?P<inttype>(i|u)\d+)" +# IP re copied from: +# https://www.regular-expressions.info/ip.html +IP = r"""(?P<ip>(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\. + (25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\. + (25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\. + (25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]))""" +# Port re copied from: +# https://stackoverflow.com/questions/12968093/regex-to-validate-port-number +# pompt_toolkit limit: Exception: {4}-style repetition not yet supported +PORT = r"(?P<port>[1-9]|[1-5]?\d\d\d?\d?|6[1-4][0-9]\d\d\d|65[1-4]\d\d|655[1-2][0-9]|6553[1-5])" +EPOCH = rf"(?P<epoch>{NUM})" +PASSWORD = rf"(?P<password>{VALID_TOKEN})" +REPLICATIONID = rf"(?P<replicationid>{VALID_TOKEN})" +INDEX = r"(?P<index>(1[0-5]|\d))" +CLIENTID = rf"(?P<clientid>{NUM})" +CLIENTIDS = rf"(?P<clientids>{NUM}(\s+{NUM})*)" + +SECOND = rf"(?P<second>{NUM})" +TIMESTAMP = r"(?P<timestamp>[T\d:>+*\-\$]+)" +# TODO test lexer & completer for multi spaces in command +# For now, redis command can have one space at most +COMMAND = r"(\s* (?P<command>[\w -]+))" +MILLISECOND = rf"(?P<millisecond>{NUM})" +TIMESTAMPMS = r"(?P<timestampms>[T\d:>+*\-\$]+)" +ANY = r"(?P<any>.*)" # TODO deleted +START = rf"(?P<start>{NNUM})" +END = rf"(?P<end>{NNUM})" + +# for stream ids, special ids include: -, +, $, > and * +# please see: +# https://redis.io/topics/streams-intro#special-ids-in-the-streams-api +# stream id, DO NOT use r"" here, or the \+ will be two string +# NOTE: if miss the outer (), multi IDS won't work. +STREAM_ID = r"(?P<stream_id>[T\d:>+*\-\$]+)" + +DELTA = rf"(?P<delta>{NNUM})" +OFFSET = rf"(?P<offset>{NUM})" # string offset, can't be negative +SHARP_OFFSET = rf"(?P<offset>\#?{NUM})" # for bitfield command +MIN = rf"(?P<min>{NNUM})" +MAX = rf"(?P<max>{NNUM})" +POSITION = rf"(?P<position>{NNUM})" +SCORE = rf"(?P<score>{_FLOAT})" +LEXMIN = rf"(?P<lexmin>{LEXNUM})" +LEXMAX = rf"(?P<lexmax>{LEXNUM})" +WEIGHTS = rf"(?P<weights>{_FLOAT}(\s+{_FLOAT})*)" +IP_PORT = rf"(?P<ip_port>{IP}:{PORT})" +HOST = rf"(?P<host>{VALID_TOKEN})" +MIN = rf"(?P<min>{NNUM})" +MAX = rf"(?P<max>{NNUM})" +POSITION = rf"(?P<position>{NNUM})" +TIMEOUT = rf"(?P<timeout>{DOUBLE})" +SCORE = rf"(?P<score>{_FLOAT})" +LEXMIN = rf"(?P<lexmin>{LEXNUM})" +LEXMAX = rf"(?P<lexmax>{LEXNUM})" +WEIGHTS = rf"(?P<weights>{_FLOAT}(\s+{_FLOAT})*)" +IP_PORT = rf"(?P<ip_port>{IP}:{PORT})" +HOST = rf"(?P<host>{VALID_TOKEN})" + +# const choices +FAILOVERCHOICE = rf"(?P<failoverchoice>{c('failoverchoice')})" +WITHSCORES = rf"(?P<withscores>{c('withscores')})" +LIMIT = rf"(?P<limit>{c('limit')})" +EXPIRATION = rf"(?P<expiration>{c('expiration')})" +CONDITION = rf"(?P<condition>{c('condition')})" +OPERATION = rf"(?P<operation>{c('operation')})" +CHANGED = rf"(?P<changed>{c('changed')})" +INCR = rf"(?P<incr>{c('incr')})" +RESETCHOICE = rf"(?P<resetchoice>{c('resetchoice')})" +MATCH = rf"(?P<match>{c('match')})" +COUNT_CONST = rf"(?P<count_const>{c('count_const')})" +TYPE_CONST = rf"(?P<type_const>{c('type_const')})" +TYPE = rf"(?P<type>{c('type')})" +POSITION_CHOICE = rf"(?P<position_choice>{c('position_choice')})" +ERROR = rf"(?P<error>{c('error')})" +ASYNC = rf"(?P<async>{c('async')})" +CONNTYPE = rf"(?P<conntype>{c('conntype')})" +SAMPLES = rf"(?P<samples>{c('samples')})" +SLOTSUBCMD = rf"(?P<slotsubcmd>{c('slotsubcmd')})" +WEIGHTS_CONST = rf"(?P<weights_const>{c('weights_const')})" +AGGREGATE_CONST = rf"(?P<aggregate_const>{c('aggregate_const')})" +AGGREGATE = rf"(?P<aggregate>{c('aggregate')})" +SLOWLOGSUB = rf"(?P<slowlogsub>{c('slowlogsub')})" +SHUTDOWN = rf"(?P<shutdown>{c('shutdown')})" +SWITCH = rf"(?P<switch>{c('switch')})" +ON_OFF = rf"(?P<on_off>{c('on_off')})" +CONST_ID = rf"(?P<const_id>{c('const_id')})" +CONST_USER = rf"(?P<const_user>{c('const_user')})" +ADDR = rf"(?P<addr>{c('addr')})" +LADDR = rf"(?P<laddr>{c('laddr')})" +SKIPME = rf"(?P<skipme>{c('skipme')})" +YES = rf"(?P<yes>{c('yes')})" +MIGRATECHOICE = rf"(?P<migratechoice>{c('migratechoice')})" +AUTH = rf"(?P<auth>{c('auth')})" +CONST_KEYS = rf"(?P<const_keys>{c('const_keys')})" +OBJECT = rf"(?P<object>{c('object')})" +SUBRESTORE = rf"(?P<subrestore>{c('subrestore')})" +DISTUNIT = rf"(?P<distunit>{c('distunit')})" +GEOCHOICE = rf"(?P<geochoice>{c('geochoice')})" +ORDER = rf"(?P<order>{c('order')})" +CONST_STORE = rf"(?P<const_store>{c('const_store')})" +CONST_STOREDIST = rf"(?P<const_storedist>{c('const_storedist')})" +PUBSUBCMD = rf"(?P<pubsubcmd>{c('pubsubcmd')})" +SCRIPTDEBUG = rf"(?P<scriptdebug>{c('scriptdebug')})" +HELP = rf"(?P<help>{c('help')})" +STREAM = rf"(?P<stream>{c('stream')})" +STREAM_GROUPS = rf"(?P<stream_groups>{c('stream_groups')})" +STREAM_GROUP = rf"(?P<stream_group>{c('stream_group')})" +STREAM_CONSUMERS = rf"(?P<stream_consumers>{c('stream_consumers')})" +STREAM_CREATE = rf"(?P<stream_create>{c('stream_create')})" +STREAM_SETID = rf"(?P<stream_setid>{c('stream_setid')})" +STREAM_DESTROY = rf"(?P<stream_destroy>{c('stream_destroy')})" +STREAM_DELCONSUMER = rf"(?P<stream_delconsumer>{c('stream_delconsumer')})" +MAXLEN = rf"(?P<maxlen>{c('maxlen')})" +APPROXIMATELY = r"(?P<approximately>~)" +IDLE = rf"(?P<idle>{c('idle')})" +TIME = rf"(?P<time>{c('time')})" +RETRYCOUNT = rf"(?P<retrycount>{c('retrycount')})" +FORCE = rf"(?P<force>{c('force')})" +JUSTID = rf"(?P<justid>{c('justid')})" +BLOCK = rf"(?P<block>{c('block')})" +STREAMS = rf"(?P<streams>{c('streams')})" +NOACK = rf"(?P<noack>{c('noack')})" +GET = rf"(?P<get>{c('get')})" +SET = rf"(?P<set>{c('set')})" +INCRBY = rf"(?P<incrby>{c('incrby')})" +OVERFLOW = rf"(?P<overflow>{c('overflow')})" +OVERFLOW_OPTION = rf"(?P<overflow_option>{c('overflow_option')})" +KEEPTTL = rf"(?P<keepttl>{c('keepttl')})" +GRAPHEVENT = rf"(?P<graphevent>{c('graphevent')})" +VERSION = rf"(?P<version>{c('version')})" +SECTION = rf"(?P<section>{c('section')})" +SCHEDULE = rf"(?P<schedule>{c('schedule')})" + +REDIRECT_CONST = rf"(?P<redirect_const>{c('redirect_const')})" +PREFIX_CONST = rf"(?P<prefix_const>{c('prefix_const')})" +BCAST_CONST = rf"(?P<bcast_const>{c('bcast_const')})" +OPTIN_CONST = rf"(?P<optin_const>{c('optin_const')})" +OPTOUT_CONST = rf"(?P<optout_const>{c('optout_const')})" +NOLOOP_CONST = rf"(?P<noloop_const>{c('noloop_const')})" + +RESET_CONST = rf"(?P<reset_const>{c('reset_const')})" +FULL_CONST = rf"(?P<full_const>{c('full_const')})" + +STR_ALGO = rf"(?P<str_algo>{c('str_algo')})" +LEN_CONST = rf"(?P<len_const>{c('len_const')})" +IDX_CONST = rf"(?P<idx_const>{c('idx_const')})" +MINMATCHLEN_CONST = rf"(?P<minmatchlen_const>{c('minmatchlen_const')})" +WITHMATCHLEN_CONST = rf"(?P<withmatchlen_const>{c('withmatchlen_const')})" +STRINGS_CONST = rf"(?P<strings_const>{c('strings_const')})" +RANK_CONST = rf"(?P<rank_const>{c('rank_const')})" + +LR_CONST = rf"(?P<lr_const>{c('lr_const')})" +PAUSE_TYPE = rf"(?P<pause_type>{c('pause_type')})" +DB_CONST = rf"(?P<db_const>{c('db_const')})" +REPLACE_CONST = rf"(?P<replace_const>{c('replace_const')})" +TO_CONST = rf"(?P<to_const>{c('to_const')})" +TIMEOUT_CONST = rf"(?P<timeout_const>{c('timeout_const')})" +ABORT_CONST = rf"(?P<abort_const>{c('abort_const')})" +PXAT_CONST = rf"(?P<pxat_const>{c('pxat_const')})" +EXAT_CONST = rf"(?P<exat_const>{c('exat_const')})" +WITHVALUES_CONST = rf"(?P<withvalues_const>{c('withvalues_const')})" + +command_grammar = compile(COMMAND) + +# Here are the core grammars, those are tokens after ``command``. +# E.g. SET command's syntax is "SET key value" +# Then it's grammar here is r"\s+ key \s+ value \s*", we needn't add `command` +# here because every syntaxes starts with `command` so we will prepend `command` +# in get_command_grammar function. +GRAMMAR = { + "command_key": rf"\s+ {KEY} \s*", + "command_pattern": rf"\s+ {PATTERN} \s*", + "command_command": rf"\s+ {COMMAND} \s*", + "command_slots": rf"\s+ {SLOTS} \s*", + "command_node": rf"\s+ {NODE} \s*", + "command_slot": rf"\s+ {SLOT} \s*", + "command_failoverchoice": rf"\s+ {FAILOVERCHOICE} \s*", + "command_resetchoice": rf"\s+ {RESETCHOICE} \s*", + "command_slot_count": rf"\s+ {SLOT} \s+ {COUNT} \s*", + "command_key_samples_count": rf""" + \s+ {KEY} \s+ {SAMPLES} \s+ {COUNT} \s*""", + "command": r"\s*", + "command_ip_port": rf"\s+ {IP} \s+ {PORT} \s*", + "command_epoch": rf"\s+ {EPOCH} \s*", + "command_yes": rf"\s+ {YES} \s*", + "command_sectionx": rf"(\s+ {SECTION})? \s*", + "command_asyncx": rf"(\s+ {ASYNC})? \s*", + "command_slot_slotsubcmd_nodex": rf""" + \s+ {SLOT} \s+ {SLOTSUBCMD} (\s+ {NODE})? \s*""", + "command_password": rf"\s+ {PASSWORD} \s*", + "command_usernamex_password": rf"(\s+ {USERNAME})? \s+ {PASSWORD} \s*", + "command_message": rf"\s+ {MESSAGE} \s*", + "command_messagex": rf"(\s+{MESSAGE})? \s*", + "command_index": rf"\s+ {INDEX} \s*", + "command_index_index": rf"\s+ {INDEX} \s+ {INDEX} \s*", + "command_client_list": rf""" + ( + (\s+ {TYPE_CONST} \s+ {CONNTYPE})| + (\s+ {CONST_ID} \s+ {CLIENTIDS}) + )* + \s*""", + "command_clientid_errorx": rf"\s+ {CLIENTID} (\s+ {ERROR})? \s*", + "command_keys": rf"\s+ {KEYS} \s*", + "command_key_value": rf"\s+ {KEY} \s+ {VALUE} \s*", + "command_parameter_value": rf"\s+ {PARAMETER} \s+ {VALUE} \s*", + "command_parameter": rf"\s+ {PARAMETER} \s+ {VALUE} \s*", + "command_value": rf"\s+ {VALUE} \s*", + "command_key_second": rf"\s+ {KEY} \s+ {SECOND} \s*", + "command_key_timestamp": rf"\s+ {KEY} \s+ {TIMESTAMP} \s*", + "command_key_index": rf"\s+ {KEY} \s+ {INDEX} \s*", + "command_key_millisecond": rf"\s+ {KEY} \s+ {MILLISECOND} \s*", + "command_key_timestampms": rf"\s+ {KEY} \s+ {TIMESTAMPMS} \s*", + "command_key_newkey": rf"\s+ {KEY} \s+ {NEWKEY} \s*", + "command_newkey_keys": rf"\s+ {NEWKEY} \s+ {KEYS} \s*", + "command_key_newkey_timeout": rf"\s+ {KEY} \s+ {NEWKEY} \s+ {TIMEOUT} \s*", + "command_keys_timeout": rf"\s+ {KEYS} \s+ {TIMEOUT} \s*", + "command_count_timeout": rf"\s+ {COUNT} \s+ {TIMEOUT} \s*", + "command_pause": rf"\s+ {TIMEOUT} (\s+ {PAUSE_TYPE})? \s*", + "command_key_positionchoice_pivot_value": rf""" + \s+ {KEY} \s+ {POSITION_CHOICE} \s+ {VALUE} \s+ {VALUE} \s*""", + "command_pass": rf"\s+ {ANY} \s*", + "command_any": rf"\s+ {ANY} \s*", + "command_set": rf""" + \s+ {KEY} \s+ {VALUE} + ( + (\s+ {EXPIRATION} \s+ {MILLISECOND})| + (\s+ {CONDITION})| + (\s+ {KEEPTTL}) + )* + \s*""", + "command_key_start_end_x": rf"\s+ {KEY} (\s+ {START} \s+ {END})? \s*", + "command_key_start_end": rf"\s+ {KEY} \s+ {START} \s+ {END} \s*", + "command_key_delta": rf"\s+ {KEY} \s+ {DELTA} \s*", + "command_key_offset_value": rf"\s+ {KEY} \s+ {OFFSET} \s+ {VALUE} \s*", + "command_key_field_value": rf"\s+ {KEY} (\s+ {FIELD} \s+ {VALUE})+ \s*", + "command_key_offset_bit": rf"\s+ {KEY} \s+ {OFFSET} \s+ {BIT} \s*", + "command_key_offset": rf"\s+ {KEY} \s+ {OFFSET} \s*", + "command_key_position": rf"\s+ {KEY} \s+ {POSITION} \s*", + "command_key_position_value": rf"\s+ {KEY} \s+ {POSITION} \s+ {VALUE} \s*", + "command_key_second_value": rf"\s+ {KEY} \s+ {SECOND} \s+ {VALUE} \s*", + "command_key_float": rf"\s+ {KEY} \s+ {FLOAT} \s*", + "command_key_valuess": rf"(\s+ {KEY} \s+ {VALUE})+ \s*", + "command_key_values": rf"\s+ {KEY} \s+ {VALUES} \s*", + "command_key_millisecond_value": rf"\s+ {KEY} \s+ {MILLISECOND} \s+ {VALUE} \s*", + "command_operation_key_keys": rf"\s+ {OPERATION} \s+ {KEY} \s+ {KEYS} \s*", + "command_key_bit_start_end": rf"\s+ {KEY} \s+ {BIT} (\s+ {START})? (\s+ {END})? \s*", + "command_key_members": rf"\s+ {KEY} \s+ {MEMBERS} \s*", + "command_geodist": rf"\s+ {KEY} \s+ {MEMBER} \s+ {MEMBER} (\s+ {DISTUNIT})? \s*", + "command_key_longitude_latitude_members": rf""" + \s+ {KEY} + (\s+ {CONDITION})? + (\s+ {CHANGED})? + (\s+ {LONGITUDE} \s+ {LATITUDE} \s {MEMBER})+ + \s*""", + "command_destination_keys": rf"\s+ {DESTINATION} \s+ {KEYS} \s*", + "command_object_key": rf"\s+ {OBJECT} \s+ {KEY} \s*", + "command_key_member": rf"\s+ {KEY} \s+ {MEMBER} \s*", + "command_key_any": rf"\s+ {KEY} \s+ {ANY} \s*", + "command_key_key_any": rf"\s+ {KEY} \s+ {KEY} \s+ {ANY} \s*", + "command_key_newkey_member": rf"\s+ {KEY} \s+ {NEWKEY} \s+ {MEMBER} \s*", + "command_key_count_x": rf"\s+ {KEY} (\s+ {COUNT})? \s*", + "command_key_min_max": rf"\s+ {KEY} \s+ {MIN} \s+ {MAX} \s*", + "command_key_condition_changed_incr_score_members": rf""" + \s+ {KEY} (\s+ {CONDITION})? + (\s+ {CHANGED})? + (\s+ {INCR})? + (\s+ {SCORE} \s+ {MEMBER})+ \s*""", + "command_key_float_member": rf"\s+ {KEY} \s+ {FLOAT} \s+ {MEMBER} \s*", + "command_key_lexmin_lexmax": rf"\s+ {KEY} \s+ {LEXMIN} \s+ {LEXMAX} \s*", + "command_key_start_end_withscores_x": rf""" + \s+ {KEY} \s+ {START} \s+ {END} (\s+ {WITHSCORES})? \s*""", + "command_key_lexmin_lexmax_limit_offset_count": rf""" + \s+ {KEY} \s+ {LEXMIN} \s+ {LEXMAX} + (\s+ {LIMIT} \s+ {OFFSET} \s+ {COUNT})? \s*""", + "command_key_min_max_withscore_x_limit_offset_count_x": rf""" + \s+ {KEY} \s+ {MIN} \s+ {MAX} (\s+ {WITHSCORES})? + (\s+ {LIMIT} \s+ {OFFSET} \s+ {COUNT})? \s*""", + "command_cursor_match_pattern_count_type": rf""" + \s+ {CURSOR} (\s+ {MATCH} \s+ {PATTERN})? + (\s+ {COUNT_CONST} \s+ {COUNT})? (\s+ {TYPE_CONST} \s+ {TYPE})? \s*""", + "command_key_cursor_match_pattern_count": rf"""\s+ {KEY} + \s+ {CURSOR} (\s+ {MATCH} \s+ {PATTERN})? (\s+ {COUNT_CONST} \s+ {COUNT})? \s*""", + "command_key_fields": rf"\s+ {KEY} \s+ {FIELDS} \s*", + "command_key_field": rf"\s+ {KEY} \s+ {FIELD} \s*", + "command_key_field_delta": rf"\s+ {KEY} \s+ {FIELD} \s+ {DELTA} \s*", + "command_key_field_float": rf"\s+ {KEY} \s+ {FIELD} \s+ {FLOAT} \s*", + "command_key_fieldvalues": rf"\s+ {KEY} (\s+ {FIELD} \s+ {VALUE})+ \s*", + "command_slowlog": rf"\s+ {SLOWLOGSUB} \s+ {NUM} \s*", + "command_switch": rf"\s+ {SWITCH} \s*", + "command_schedulex": rf"(\s+ {SCHEDULE})? \s*", + "command_clientkill": rf""" + ( + (\s+ {IP_PORT})| + (\s+ {ADDR} \s+ {IP_PORT})| + (\s+ {LADDR} \s+ {IP_PORT})| + (\s+ {CONST_ID} \s+ {CLIENTID})| + (\s+ {TYPE_CONST} \s+ {CONNTYPE})| + (\s+ {CONST_USER} \s+ {USERNAME})| + (\s+ {SKIPME} \s+ {YES}) + )+ \s*""", + "command_migrate": rf""" + \s+ {HOST} \s+ {PORT} + \s+ {KEY} \s+ {INDEX} \s+ {TIMEOUT} + (\s+ {MIGRATECHOICE})? + ( + (\s+ {AUTH} \s+ {PASSWORD})| + (\s+ {AUTH} \s+ {USERNAME} \s+ {PASSWORD}) + )? + (\s+ {CONST_KEYS} \s+ {KEYS})? + \s*""", + "command_restore": rf"""\s+ {KEY} + \s+ {TIMEOUT} \s+ {VALUE} (\s+ {SUBRESTORE} \s+ {SECOND})? \s*""", + "command_pubsubcmd_channels": rf"\s+ {PUBSUBCMD} (\s+ {CHANNEL})+ \s*", + "command_channel_message": rf"\s+ {CHANNEL} \s+ {MESSAGE} \s*", + "command_channels": rf"(\s+ {CHANNEL})+ \s*", + "command_lua_any": rf"""(\s+"{DOUBLE_LUA}")? (\s+'{SINGLE_LUA}')? \s+ {ANY} \s*""", + "command_scriptdebug": rf"\s+ {SCRIPTDEBUG} \s*", + "command_shutdown": rf"\s+ {SHUTDOWN} \s*", + "command_key_start_end_countx": rf"""\s+ {KEY} + \s+ {STREAM_ID} + \s+ {STREAM_ID} + (\s+ {COUNT_CONST} \s+ {COUNT})? + \s*""", + "command_xgroup": rf""" + ( + (\s+ {STREAM_CREATE} \s+ {KEY} \s+ {GROUP} \s+ {STREAM_ID})| + (\s+ {STREAM_SETID} \s+ {KEY} \s+ {GROUP} \s+ {STREAM_ID})| + (\s+ {STREAM_DESTROY} \s+ {KEY} \s+ {GROUP})| + (\s+ {STREAM_DELCONSUMER} \s+ {KEY} \s+ {GROUP} \s+ {CONSUMER}) + ) + \s*""", + "command_key_group_ids": rf""" + \s+ {KEY} \s+ {GROUP} (\s+ {STREAM_ID})+ \s*""", + "command_key_ids": rf""" + \s+ {KEY} (\s+ {STREAM_ID})+ \s*""", + "command_xinfo": rf""" + ( + (\s+ {STREAM_CONSUMERS} \s+ {KEY} \s+ {GROUP})| + (\s+ {STREAM_GROUPS} \s+ {KEY})| + (\s+ {STREAM} \s+ {KEY} + (\s+ {FULL_CONST})? + (\s+ {COUNT_CONST} \s+ {COUNT})? + )| + (\s+ {HELP}) + ) + \s*""", + "command_xpending": rf""" + \s+ {KEY} \s+ {GROUP} + (\s+ {STREAM_ID} \s+ {STREAM_ID} \s+ {COUNT})? + (\s+ {CONSUMER})? + \s*""", + "command_xadd": rf""" + \s+ {KEY} + (\s+ {MAXLEN} (\s+ {APPROXIMATELY})? \s+ {COUNT})? + \s+ {STREAM_ID} + (\s+ {SFIELD} \s+ {SVALUE})+ \s*""", + "command_key_maxlen": rf""" + \s+ {KEY} \s+ {MAXLEN} (\s+ {APPROXIMATELY})? \s+ {COUNT} + \s*""", + "command_xclaim": rf""" + \s+ {KEY} \s+ {GROUP} \s+ {CONSUMER} \s+ {MILLISECOND} + (\s+ {STREAM_ID})+ + (\s+ {IDLE} \s+ {MILLISECOND})? + (\s+ {TIME} \s+ {TIMESTAMP})? + (\s+ {RETRYCOUNT} \s+ {COUNT})? + (\s+ {FORCE})? + (\s+ {JUSTID})? + \s*""", + "command_xread": rf""" + (\s+ {COUNT_CONST} \s+ {COUNT})? + (\s+ {BLOCK} \s+ {MILLISECOND})? + \s+ {STREAMS} + \s+ {KEYS} + (\s+ {STREAM_ID})+ + \s*""", + "command_xreadgroup": rf""" + \s+ {STREAM_GROUP} \s+ {GROUP} \s+ {CONSUMER} + (\s+ {COUNT_CONST} \s+ {COUNT})? + (\s+ {BLOCK} \s+ {MILLISECOND})? + (\s+ {NOACK})? + \s+ {STREAMS} + \s+ {KEYS} + (\s+ {STREAM_ID})+ + \s*""", + "command_bitfield": rf""" + \s+ {KEY} + ( + (\s+ {GET} \s+ {INTTYPE} \s+ {SHARP_OFFSET})| + (\s+ {SET} \s+ {INTTYPE} \s+ {SHARP_OFFSET} \s+ {VALUE})| + (\s+ {INCRBY} \s+ {INTTYPE} \s+ {SHARP_OFFSET} \s+ {VALUE})| + (\s+ {OVERFLOW} \s+ {OVERFLOW_OPTION}) + )+ + \s*""", + "command_replicationid_offset": rf"\s+ {REPLICATIONID} \s+ {OFFSET} \s*", + "command_graphevent": rf"\s+ {GRAPHEVENT} \s*", + "command_graphevents": rf"(\s+ {GRAPHEVENT})* \s*", + # before redis 5: lolwut 5 1 + # start from redis 6: lolwut VERSION 5 1 + "command_version": rf"(\s+ {VERSION} \s+ {VERSION_NUM})? (\s+ {ANY})? \s*", + "command_client_tracking": rf""" + \s+ {ON_OFF} + ( + (\s+ {REDIRECT_CONST} \s+ {CLIENTID})| + (\s+ {PREFIX_CONST} \s+ {PREFIXES})| + (\s+ {BCAST_CONST})| + (\s+ {OPTIN_CONST})| + (\s+ {OPTOUT_CONST})| + (\s+ {NOLOOP_CONST}) + )* + \s*""", + "command_categorynamex": rf"(\s+ {CATEGORYNAME})? \s*", + "command_usernames": rf"(\s+ {USERNAME})+ \s*", + "command_username": rf"\s+ {USERNAME} \s*", + "command_count_or_resetx": rf"( (\s+ {COUNT}) | (\s+ {RESET_CONST}) )? \s*", + "command_username_rules": rf"\s+ {USERNAME} (\s+ {RULE})* \s*", + "command_count": rf"(\s+ {COUNT})? \s*", + "command_stralgo": rf""" + ( + \s+ {STR_ALGO} + ( + (\s+ {CONST_KEYS} \s+ {KEYS})| + (\s+ {STRINGS_CONST} \s+ {VALUES}) + ) + (\s+ {IDX_CONST})? + (\s+ {LEN_CONST})? + (\s+ {MINMATCHLEN_CONST} \s+ {LEN})? + (\s+ {WITHMATCHLEN_CONST})? + ) + \s*""", + "command_lpos": rf""" + \s+ {KEY} \s+ {ELEMENT} + ( + (\s+ {RANK_CONST} \s+ {RANK})| + (\s+ {COUNT_CONST} \s+ {COUNT})| + (\s+ {MAXLEN} \s+ {LEN}) + )* + \s*""", + "command_key_key_lr_lr_timeout": rf""" + \s+ {KEY} \s+ {KEY} + \s+ {LR_CONST} \s+ {LR_CONST} + \s+ {TIMEOUT} \s*""", + "command_copy": rf""" + \s+ {KEY} \s+ {KEY} + (\s+ {DB_CONST} \s+ {INDEX})? + (\s+ {REPLACE_CONST})? + \s*""", + "command_failover": rf""" + (\s+ {TO_CONST} \s+ {HOST} \s+ {PORT} (\s+ {FORCE})? )? + (\s+ {ABORT_CONST})? + (\s+ {TIMEOUT_CONST} \s+ {MILLISECOND})? + \s*""", + "command_key_expire": rf""" + \s+ {KEY} + ( + (\s+ {EXPIRATION} \s+ {MILLISECOND})| + (\s+ {PXAT_CONST} \s+ {TIMESTAMPMS})| + (\s+ {EXAT_CONST} \s+ {TIMESTAMP}) + )? + \s*""", + "command_key_count_withvalues": rf""" + \s+ {KEY} + (\s+ {COUNT} (\s+ {WITHVALUES_CONST})?)? + \s*""", +} + +pipeline = r"(?P<shellcommand>\|.*)?" + + +@lru_cache(maxsize=256) +def get_command_grammar(command): + """ + :param command: command name in upper case. This command must be raw user + input, otherwise can't match in lexer, cause this command to be invalid; + """ + syntax_name = command2syntax[" ".join(command.split()).upper()] + syntax = GRAMMAR.get(syntax_name) + + # If a command is not supported yet, (e.g. command from latest version added + # by Redis recently, or command from third Redis module.) return a default + # grammar, so the lexer and completion won't be activated. + if syntax is None: + return command_grammar + # prepend command token for this syntax + command_allow_multi_spaces = command.replace(r" ", r"\s+") + syntax = rf"\s* (?P<command>{command_allow_multi_spaces}) " + syntax + # allow user input pipeline to redirect to shell, like `get json | jq .` + syntax += pipeline + + logger.info(f"syxtax: {syntax}") + + return compile(syntax) diff --git a/iredis/renders.py b/iredis/renders.py new file mode 100644 index 0000000..6791c19 --- /dev/null +++ b/iredis/renders.py @@ -0,0 +1,429 @@ +""" +Render redis-server responses. +This module will be auto loaded to callbacks. + +func(redis-response) -> formatted result(str) +""" +import logging +import time +from packaging.version import parse as version_parse + +from prompt_toolkit.formatted_text import FormattedText + +from .commands import command2callback +from .config import config +from .utils import double_quotes, ensure_str, nativestr + +logger = logging.getLogger(__name__) +NEWLINE_TUPLE = ("", "\n") +NIL_TUPLE = ("class:type", "(nil)") +NIL = FormattedText([NIL_TUPLE]) +EMPTY_LIST = FormattedText([("class:type", "(empty list or set)")]) + + +class OutputRender: + """Render redis output""" + + @staticmethod + def get_render(command_name): + """Dynamic render output due to command name.""" + command_upper = " ".join(command_name.split()).upper() + callback_name = command2callback.get(command_upper) + + # using `render_list_or_string` as default render. + if callback_name is None: + callback = OutputRender.render_list_or_string + else: + callback = getattr( + OutputRender, callback_name, OutputRender.render_list_or_string + ) + + logger.info( + f"[render] Find callback {callback_name}, for command: {command_name}" + ) + return callback + + @staticmethod + def render_raw(value): + """ + Render for all kinds, list, string, bulkstring, int + + :return : bytes + """ + if value is None: + return b"" + if isinstance(value, bytes): + return value + if isinstance(value, int): + return str(value).encode() + if isinstance(value, str): + return value.encode() + if isinstance(value, list): + return _render_raw_list(value) + + @staticmethod + def render_bulk_string(value): + if value is None: + return NIL + return double_quotes(ensure_str(value)) + + @staticmethod + def render_bulk_string_decode(value): + """ + Only for server group commands, no double quoted, always displayed as + utf-8 decoded. + """ + decoded = nativestr(value) + split = "\n".join(decoded.splitlines()) # get rid of last newline + return split + + @staticmethod + def render_nested_pair(value): + """ + For redis internal responses. + Always decode with utf-8 + Render nested list. + Items come as pairs. + """ + return FormattedText(_render_pair(value, 0)) + + @staticmethod + def render_int(value): + if value is None: + return NIL + return FormattedText([("class:type", "(integer) "), ("", str(value))]) + + @staticmethod + def render_unixtime(value): + rendered_int = OutputRender.render_int(value) + explained_date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(value))) + rendered_int.extend( + [ + NEWLINE_TUPLE, + ("class:type", "(local time)"), + ("", " "), + ("", explained_date), + ] + ) + return rendered_int + + @staticmethod + def render_time(value): + unix_timestamp, millisecond = value[0].decode(), value[1].decode() + explained_date = time.strftime( + "%Y-%m-%d %H:%M:%S", time.localtime(int(unix_timestamp)) + ) + rendered = [ + ("class:type", "(unix timestamp) "), + ("", unix_timestamp), + NEWLINE_TUPLE, + ("class:type", "(millisecond) "), + ("", millisecond), + NEWLINE_TUPLE, + ("class:type", "(convert to local timezone) "), + ("", f"{explained_date}.{millisecond}"), + ] + return FormattedText(rendered) + + @staticmethod + def render_list(text, style="class:string"): + """ + Render callback for redis Array Reply + Note: Cloud be null in it. + """ + str_items = [] + for item in text: + if item is None: + str_items.append(None) + else: + str_item = ensure_str(item) + double_quoted = double_quotes(str_item) + str_items.append(double_quoted) + rendered = _render_list(text, str_items, style) + return FormattedText(rendered) + + @staticmethod + def render_list_or_string(text): + if isinstance(text, list): + return OutputRender.render_list(text) + return OutputRender.render_bulk_string(text) + + @staticmethod + def render_string_or_int(text): + if isinstance(text, int): + return OutputRender.render_int(text) + return OutputRender.render_bulk_string(text) + + @staticmethod + def render_error(error_msg): + text = ensure_str(error_msg) + return FormattedText([("class:type", "(error) "), ("class:error", text)]) + + @staticmethod + def render_simple_string(text): + """ + If response is b'OK', render simple string always with success color. + If Error happens, error will be rendered by ``render_error`` + """ + if text is None: + return NIL + text = ensure_str(text) + return FormattedText([("class:success", text)]) + + @staticmethod + def render_help(raw): + """ + render help text message. + the command like ``ACL HELP`` and ``MEMORY HELP`` + will return a list of strings. + we render it as plain text + """ + return FormattedText([("class:string", _render_raw_list(raw).decode())]) + + @staticmethod + def render_transaction_queue(text): + """ + Used when client session is in a transaction. + + Response message should be "QUEUE" or Error. + """ + text = ensure_str(text) + return FormattedText([("class:queued", text)]) + + @staticmethod + def render_members(items): + if not config.withscores: + return OutputRender.render_list(items, "class:member") + + if not items: + return EMPTY_LIST + str_items = ensure_str(items) + + members = [item for item in str_items[::2]] + scores = [item for item in str_items[1::2]] + logger.debug(f"[MEMBERS] {members}") + logger.debug(f"[SCORES] {scores}") + # render display + double_quoted = double_quotes(members) + index_width = len(str(len(double_quoted))) + score_width = max(len(score) for score in scores) + rendered = [] + for index, item in enumerate(double_quoted): + index_const_width = f"{index+1:{index_width}})" + rendered.append(("", index_const_width)) + # add a space between index and member + rendered.append(("", " ")) + # add score + rendered.append(("class:integer", f"{scores[index]:{score_width}} ")) + # add member + if item is None: + rendered.append(NIL_TUPLE) + else: + rendered.append(("class:member", item)) + + # add a newline for eachline + if index + 1 < len(double_quoted): + rendered.append(NEWLINE_TUPLE) + return FormattedText(rendered) + + @staticmethod + def render_hash_pairs(response): + # render hash pairs + if not response: + return EMPTY_LIST + str_items = ensure_str(response) + fields = str_items[0::2] + values = str_items[1::2] + # render display + index_width = len(str(len(fields))) + values_quoted = double_quotes(values) + fields_quoted = double_quotes(fields) + rendered = [] + for index, item in enumerate(fields_quoted): + index_const_width = f"{index+1:{index_width}})" + rendered.append(("", index_const_width)) + rendered.append(("", " ")) + rendered.append(("class:field", item)) + rendered.append(NEWLINE_TUPLE) + rendered.append(("", " " * (len(index_const_width) + 1))) + value = values_quoted[index] + if value is None: + rendered.append(NIL_TUPLE) + else: + rendered.append(("class:string", value)) + + # add a newline for eachline + if index + 1 < len(fields): + rendered.append(NEWLINE_TUPLE) + return FormattedText(rendered) + + @staticmethod + def render_slowlog(raw): + fields = ["Slow log id", "Start at", "Running time(ms)", "Command"] + if version_parse(config.version) > version_parse("4.0"): + fields.extend(["Client IP and port", "Client name"]) + + rendered = [] + text = ensure_str(raw) + index_width = len(str(len(text))) + for index, slowlog in enumerate(text): + index_str = f"{index+1:{index_width}}) " + rendered.append(("", index_str)) + for field, value in zip(fields, slowlog): + if field == "Command": + value = " ".join(value) + if field != "Slow log id": + display_field = " " * len(index_str) + field + else: + display_field = field + logger.debug(f"field: {field}, value: {value}") + rendered.extend( + [ + ("class:field", f"{display_field}: "), + ("class:string", value), + NEWLINE_TUPLE, + ] + ) + + return FormattedText(rendered[:-1]) + + @staticmethod + def render_subscribe(raw): + """ + message type; + channel; + message; + see: https://redis.io/topics/pubsub#format-of-pushed-messages + """ + logger.info(raw) + if raw[1] is None: + raw[1] = "all" + mtype, *channel, message = ensure_str(raw) + # PUNSUBSCRIBE, 4 args + channel = ":".join(channel) + return FormattedText( + [ + ("", f"{mtype:<9} from "), # 9 is len("subscribe") + ("class:channel", channel), + ("", ": "), # 9 is len("subscribe") + ("class:string", f"{message}"), + ] + ) + + @staticmethod + def command_keys(items): + return OutputRender.render_list(items, "class:key") + + @staticmethod + def command_scan(response): + """ + Render Scan command result. + see: https://redis.io/commands/scan + """ + return _render_scan(OutputRender.command_keys, response) + + @staticmethod + def command_sscan(response): + return _render_scan(OutputRender.render_members, response) + + @staticmethod + def command_zscan(response): + return _render_scan(OutputRender.render_members, response) + + @staticmethod + def command_hscan(response): + return _render_scan(OutputRender.render_hash_pairs, response) + + @staticmethod + def command_hkeys(response): + return OutputRender.render_list(response, "class:field") + + @staticmethod + def render_bytes(response): + return response.rstrip(b"\n") # there is a new line in `write_result` + + @staticmethod + def default_render(text): + pass + + +def _render_raw_list(bytes_items): + flatten_items = [] + for item in bytes_items: + if item is None: + flatten_items.append(b"") + elif isinstance(item, bytes): + flatten_items.append(item) + elif isinstance(item, int): + flatten_items.append(str(item).encode()) + elif isinstance(item, str): + flatten_items.append(item.encode()) + elif isinstance(item, list): + flatten_items.append(_render_raw_list(item)) + return b"\n".join(flatten_items) + + +def _render_list(byte_items, str_items, style=None, pre_space=0): + """Complute the newline/number-width/lineno, + render list to FormattedText + """ + if not str_items: + return EMPTY_LIST + + index_width = len(str(len(str_items))) + rendered = [] + for index, item in enumerate(str_items): + indent_spaces = (index + 1 != 1) * pre_space * " " + if indent_spaces: + rendered.append(("", indent_spaces)) # add a space before item + + index_const_width = f"{index+1:{index_width}})" + rendered.append(("", index_const_width)) + # list item + rendered.append(("", " ")) # add a space before item + if item is None: + rendered.append(NIL_TUPLE) + elif isinstance(item, str): + rendered.append((style, item)) + else: # it's a nested list + # if config.raw == True, never will get there + sublist = _render_list(None, item, style, pre_space + index_width + 2) + rendered.extend(sublist) + + # add a newline for eachline + if index + 1 < len(str_items): + rendered.append(NEWLINE_TUPLE) + return rendered + + +def _render_scan(render_response, response): + cursor, responses = response + + rendered = [ + ("class:type", "(cursor) "), + ("class:integer", cursor if isinstance(cursor, str) else cursor.decode()), + ("", "\n"), + ] + rendered_keys = render_response(responses) + return FormattedText(rendered + rendered_keys) + + +def _render_pair(pairs, indent): + keys = [item for item in pairs[::2]] + values = [item for item in pairs[1::2]] + rendered = [] + for key, value in zip(keys, values): + key = ensure_str(key, decode="utf-8") + value = ensure_str(value, decode="utf-8") + rendered.append(("class:string", f"{' '*4*indent}{key}: ")) + if isinstance(value, list): + rendered.append(NEWLINE_TUPLE) + rendered.extend(_render_pair(value, indent + 1)) + else: + rendered.append(("class:value", value)) + rendered.append(NEWLINE_TUPLE) + return rendered[:-1] # remove last newline + + +# TODO +# special list render, bzpopmax, key-value pair diff --git a/iredis/style.py b/iredis/style.py new file mode 100644 index 0000000..7262072 --- /dev/null +++ b/iredis/style.py @@ -0,0 +1,100 @@ +from prompt_toolkit.styles import Style, merge_styles + +override_style = Style([("bottom-toolbar", "noreverse")]) + +style = REDIS_TOKEN = { + "key": "#33aa33", + "important-key": "#058B06", + "pattern": "bold #33aa33", + "string": "#FD971F", + "member": "#FD971F", + "command": "bold #008000", + "integer": "#AE81FF", + "const": "bold #AE81FF", + "time": "#aa22ff", + "double": "#bb6688", + "nil": "#808080", + "bit": "#8541FF", + "field": "cyan", + "group": "ansiblue", + "username": "blue", +} + +DOC = { + "doccommand": "bold", + "dockey": "#E6DB74", + "code": "#aaaaaa", + "h2": "bold #33aa33", +} + +GROUP = { + "group.cluster": "#E6DB74", + "group.connection": "#E6DB74", + "group.generic": "#E6DB74", + "group.geo": "#E6DB74", + "group.hash": "#E6DB74", + "group.hyperloglog": "#E6DB74", + "group.list": "#E6DB74", + "group.pubsub": "#E6DB74", + "group.server": "#E6DB74", + "group.set": "#E6DB74", + "group.sortedset": "#E6DB74", + "group.stream": "#E6DB74", + "group.string": "#E6DB74", + "group.transactions": "#E6DB74", +} + + +STYLE_DICT = { + # User input (default text). + "": "", + # Prompt. + "rprompt": "bg:#ff0066 #ffffff", + "hostname": "", + "index": "#ff0000", + "trailing-input": "bg:#ff0000 #000000", + "password": "hidden", + "success": "#00ff5f bold", + "queued": "#32CD32 bold", + "error": "#ff005f bold", + "type": "#888", + "channel": "#888", # FIXME + # colors below copied from mycli project, ~~love~~ + # bottom-toolbar + "bottom-toolbar": "bg:#222222 #aaaaaa", + "bottom-toolbar.on": "bg:#222222 #ffffff", + "bottom-toolbar.off": "bg:#222222 #888888", + "bottom-toolbar.loaded": "bg:#222222 #44aa44", + "bottom-toolbar.since": "bg:#222222 #bc7a00", + "bottom-toolbar.complexity": "bg:#222222 #666666", + "bottom-toolbar.group": "bg:#222222 #d2413a bold", + # completion + "completion-menu.completion.current": "bg:#ffffff #000000", + "completion-menu.completion": "bg:#008888 #ffffff", + "completion-menu.meta.completion.current": "bg:#44aaaa #000000", + "completion-menu.meta.completion": "bg:#448888 #ffffff", + "completion-menu.multi-column-meta": "bg:#aaffff #000000", + "scrollbar.arrow": "bg:#003333", + "scrollbar": "bg:#00aaaa", + "selected": "#ffffff bg:#6666aa", + "search": "#ffffff bg:#4444aa", + "search.current": "#ffffff bg:#44aa44", + "search-toolbar": "noinherit bold", + "search-toolbar.text": "nobold", + "system-toolbar": "noinherit bold", + "arg-toolbar": "noinherit bold", + "arg-toolbar.text": "nobold", +} + +BOTTOM_TOOLBAR_TOKEN = { + # redis token + f"bottom-toolbar.{token}": f"bg:#222222 {token_style}" + for token, token_style in REDIS_TOKEN.items() +} + +style.update(STYLE_DICT) +style.update(BOTTOM_TOOLBAR_TOKEN) +style.update(DOC) + + +STYLE = merge_styles([override_style, Style.from_dict(style)]) diff --git a/iredis/utils.py b/iredis/utils.py new file mode 100644 index 0000000..5a61425 --- /dev/null +++ b/iredis/utils.py @@ -0,0 +1,333 @@ +import re +import sys +import time +import logging +from collections import namedtuple +from urllib.parse import parse_qs, unquote, urlparse + +from prompt_toolkit.formatted_text import FormattedText + +from iredis.exceptions import InvalidArguments + +logger = logging.getLogger(__name__) + +_last_timer = time.time() +_timer_counter = 0 +separator = re.compile(r"\s") +logger.debug(f"[timer] start on {_last_timer}") + + +def timer(title): + global _last_timer + global _timer_counter + + now = time.time() + tick = now - _last_timer + logger.debug(f"[timer{_timer_counter:2}] {tick:.8f} -> {title}") + + _last_timer = now + _timer_counter += 1 + + +def nativestr(x): + return x if isinstance(x, str) else x.decode("utf-8", "replace") + + +def literal_bytes(b): + if isinstance(b, bytes): + return str(b)[2:-1] + return b + + +def _valid_token(words): + token = "".join(words).strip() + if token: + yield token + + +def strip_quote_args(s): + """ + Given string s, split it into args.(Like bash paring) + Handle with all quote cases. + + Raise ``InvalidArguments`` if quotes not match + + :return: args list. + """ + word = [] + in_quote = None + pre_back_slash = False + for char in s: + if in_quote: + # close quote + if char == in_quote: + if not pre_back_slash: + yield "".join(word) + word = [] + in_quote = None + else: + # previous char is \ , merge with current " + word[-1] = char + else: + word.append(char) + # not in quote + else: + # separator + if separator.match(char): + if word: + yield "".join(word) + word = [] + # open quotes + elif char in ["'", '"']: + in_quote = char + else: + word.append(char) + if char == "\\" and not pre_back_slash: + pre_back_slash = True + else: + pre_back_slash = False + + if word: + yield "".join(word) + # quote not close + if in_quote: + raise InvalidArguments("Invalid argument(s)") + + +type_convert = {"posix time": "time"} + + +def parse_argument_to_formatted_text( + name, _type, is_option, style_class="bottom-toolbar" +): + result = [] + if isinstance(name, str): + _type = type_convert.get(_type, _type) + if is_option: + result.append((f"class:{style_class}.{_type}", f" [{name}]")) + else: + result.append((f"class:{style_class}.{_type}", f" {name}")) + elif isinstance(name, list): + for inner_name, inner_type in zip(name, _type): + inner_type = type_convert.get(inner_type, inner_type) + if is_option: + result.append((f"class:{style_class}.{inner_type}", f" [{inner_name}]")) + else: + result.append((f"class:{style_class}.{inner_type}", f" {inner_name}")) + else: + raise Exception() + return result + + +def compose_command_syntax(command_info, style_class="bottom-toolbar"): + command_style = f"class:{style_class}.command" + const_style = f"class:{style_class}.const" + args = [] + if command_info.get("arguments"): + for argument in command_info["arguments"]: + if argument.get("command"): + # command [ + args.append((command_style, " [" + argument["command"])) + if argument.get("enum"): + enums = "|".join(argument["enum"]) + args.append((const_style, f" [{enums}]")) + elif argument.get("name"): + args.extend( + parse_argument_to_formatted_text( + argument["name"], + argument["type"], + argument.get("optional"), + style_class=style_class, + ) + ) + # ] + args.append((command_style, "]")) + elif argument.get("enum"): + enums = "|".join(argument["enum"]) + args.append((const_style, f" [{enums}]")) + + else: + args.extend( + parse_argument_to_formatted_text( + argument["name"], + argument["type"], + argument.get("optional"), + style_class=style_class, + ) + ) + return args + + +def command_syntax(command, command_info): + """ + Get command syntax based on redis-doc/commands.json + + :param command: Command name in uppercase + :param command_info: dict loaded from commands.json, only for + this command. + """ + comamnd_group = command_info["group"] + bottoms = [ + ("class:bottom-toolbar.group", f"({comamnd_group}) "), + ("class:bottom-toolbar.command", f"{command}"), + ] # final display FormattedText + + bottoms += compose_command_syntax(command_info) + + if "since" in command_info: + since = command_info["since"] + bottoms.append(("class:bottom-toolbar.since", f" since: {since}")) + if "complexity" in command_info: + complexity = command_info["complexity"] + bottoms.append(("class:bottom-toolbar.complexity", f" complexity:{complexity}")) + + return FormattedText(bottoms) + + +def _literal_bytes(b): + """ + convert bytes to printable text. + + backslash and double-quotes will be escaped by + backslash. + "hello\" -> \"hello\\\" + + we don't add outer double quotes here, since + completer also need this function's return value + to patch completers. + + b'hello' -> "hello" + b'double"quotes"' -> "double\"quotes\"" + """ + s = str(b) + s = s[2:-1] # remove b' ' + # unescape single quote + s = s.replace(r"\'", "'") + return s + + +def ensure_str(origin, decode=None): + """ + Ensure is string, for display and completion. + + Then add double quotes + + Note: this method do not handle nil, make sure check (nil) + out of this method. + """ + if origin is None: + return None + if isinstance(origin, str): + return origin + if isinstance(origin, int): + return str(origin) + elif isinstance(origin, list): + return [ensure_str(b) for b in origin] + elif isinstance(origin, bytes): + if decode: + return origin.decode(decode) + return _literal_bytes(origin) + else: + raise Exception(f"Unknown type: {type(origin)}, origin: {origin}") + + +def double_quotes(unquoted): + """ + Display String like redis-cli. + escape inner double quotes. + add outer double quotes. + + :param unquoted: list, or str + """ + if isinstance(unquoted, str): + # escape double quote + escaped = unquoted.replace('"', '\\"') + return f'"{escaped}"' # add outer double quotes + elif isinstance(unquoted, list): + return [double_quotes(item) for item in unquoted] + + +def exit(): + """ + Exit IRedis REPL + """ + print("Goodbye!") + sys.exit() + + +def convert_formatted_text_to_bytes(formatted_text): + to_render = [text for style, text in formatted_text] + return "".join(to_render).encode() + + +DSN = namedtuple("DSN", "scheme host port path db username password verify_ssl") + + +def parse_url(url, db=0): + """ + Return a Redis client object configured from the given URL + + For example:: + + redis://[[username]:[password]]@localhost:6379/0 + rediss://[[username]:[password]]@localhost:6379/0?ssl_cert_reqs=none + unix://[[username]:[password]]@/path/to/socket.sock?db=0 + + Three URL schemes are supported: + + - ```redis://`` + <http://www.iana.org/assignments/uri-schemes/prov/redis>`_ creates a + normal TCP socket connection + - ```rediss://`` + <http://www.iana.org/assignments/uri-schemes/prov/rediss>`_ creates a + SSL wrapped TCP socket connection + - ``unix://`` creates a Unix Domain Socket connection + + There are several ways to specify a database number. The parse function + will return the first specified option: + 1. A ``db`` querystring option, e.g. redis://localhost?db=0 + 2. If using the redis:// scheme, the path argument of the url, e.g. + redis://localhost/0 + 3. The ``db`` argument to this function. + + If none of these options are specified, db=0 is used. + """ + url = urlparse(url) + + scheme = url.scheme + path = unquote(url.path) if url.path else None + verify_ssl = None + # We only support redis://, rediss:// and unix:// schemes. + # if scheme is ``unix``, read ``db`` from query string + # otherwise read ``db`` from path + if url.scheme == "unix": + qs = parse_qs(url.query) + if "db" in qs: + db = int(qs["db"][0] or db) + elif url.scheme in ("redis", "rediss"): + scheme = url.scheme + if path: + try: + db = int(path.replace("/", "")) + path = None + except (AttributeError, ValueError): + pass + qs = parse_qs(url.query) + if "ssl_cert_reqs" in qs: + verify_ssl = qs["ssl_cert_reqs"][0] + if verify_ssl not in ["none", "optional", "required"]: + raise ValueError( + f"ssl_cert_reqs must be one of 'none', 'optional', 'required' or must be omitted: {verify_ssl}" + ) + else: + valid_schemes = ", ".join(("redis://", "rediss://", "unix://")) + raise ValueError( + "Redis URL must specify one of the following" "schemes (%s)" % valid_schemes + ) + + username = unquote(url.username) if url.username else None + password = unquote(url.password) if url.password else None + hostname = unquote(url.hostname) if url.hostname else None + port = url.port + + return DSN(scheme, hostname, port, path, db, username, password, verify_ssl) diff --git a/iredis/warning.py b/iredis/warning.py new file mode 100644 index 0000000..bb8231e --- /dev/null +++ b/iredis/warning.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + + +import sys +import click +from .commands import dangerous_commands + + +class ConfirmBoolParamType(click.ParamType): + name = "confirmation" + + def convert(self, value, param, ctx): + if isinstance(value, bool): + return bool(value) + value = value.lower() + if value in ("yes", "y"): + return True + elif value in ("no", "n"): + return False + self.fail("%s is not a valid boolean" % value, param, ctx) + + def __repr__(self): + return "BOOL" + + +BOOLEAN_TYPE = ConfirmBoolParamType() + + +def is_dangerous(command): + """ + :return : return True, reason str if command is dangerous; + return False, None otherwise. + """ + reason = dangerous_commands.get(command) + return reason is not None, reason + + +def prompt(*args, **kwargs): + """Prompt the user for input and handle any abort exceptions.""" + try: + return click.prompt(*args, **kwargs) + except click.Abort: + return False + + +def confirm_dangerous_command(upper_command): + """Check if the query is destructive and prompts the user to confirm. + + Returns: + * None if the query is non-destructive or we can't prompt the user. + * True if the query is destructive and the user wants to proceed. + * False if the query is destructive and the user doesn't want to proceed. + + """ + dangerous, reason = is_dangerous(upper_command) + prompt_text = f"{reason}.\n" "Do you want to proceed? (y/n)" + if dangerous and sys.stdin.isatty(): + return prompt(prompt_text, type=BOOLEAN_TYPE) diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..ab14deb --- /dev/null +++ b/poetry.lock @@ -0,0 +1,436 @@ +[[package]] +name = "async-timeout" +version = "4.0.2" +description = "Timeout context manager for asyncio programs" +category = "main" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +typing-extensions = {version = ">=3.6.5", markers = "python_version < \"3.8\""} + +[[package]] +name = "attrs" +version = "22.2.0" +description = "Classes Without Boilerplate" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.extras] +cov = ["attrs[tests]", "coverage-enable-subprocess", "coverage[toml] (>=5.3)"] +dev = ["attrs[docs,tests]"] +docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope.interface"] +tests = ["attrs[tests-no-zope]", "zope.interface"] +tests-no-zope = ["cloudpickle", "hypothesis", "mypy (>=0.971,<0.990)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +tests_no_zope = ["cloudpickle", "hypothesis", "mypy (>=0.971,<0.990)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] + +[[package]] +name = "click" +version = "7.1.2" +description = "Composable command line interface toolkit" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +category = "dev" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" + +[[package]] +name = "configobj" +version = "5.0.6" +description = "Config file reading, writing and validation." +category = "main" +optional = false +python-versions = "*" + +[package.dependencies] +six = "*" + +[[package]] +name = "exceptiongroup" +version = "1.1.0" +description = "Backport of PEP 654 (exception groups)" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +test = ["pytest (>=6)"] + +[[package]] +name = "importlib-metadata" +version = "5.2.0" +description = "Read metadata from Python packages" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} +zipp = ">=0.5" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +perf = ["ipython"] +testing = ["flake8 (<5)", "flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)"] + +[[package]] +name = "importlib-resources" +version = "5.10.2" +description = "Read resources from Python packages" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["flake8 (<5)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] + +[[package]] +name = "iniconfig" +version = "1.1.1" +description = "iniconfig: brain-dead simple config-ini parsing" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "mistune" +version = "2.0.4" +description = "A sane Markdown parser with useful plugins and renderers" +category = "main" +optional = false +python-versions = "*" + +[[package]] +name = "packaging" +version = "21.3" +description = "Core utilities for Python packages" +category = "main" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +pyparsing = ">=2.0.2,<3.0.5 || >3.0.5" + +[[package]] +name = "pendulum" +version = "2.1.2" +description = "Python datetimes made easy" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + +[package.dependencies] +python-dateutil = ">=2.6,<3.0" +pytzdata = ">=2020.1" + +[[package]] +name = "pexpect" +version = "4.8.0" +description = "Pexpect allows easy control of interactive console applications." +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +ptyprocess = ">=0.5" + +[[package]] +name = "pluggy" +version = "1.0.0" +description = "plugin and hook calling mechanisms for python" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + +[[package]] +name = "prompt-toolkit" +version = "3.0.36" +description = "Library for building powerful interactive command lines in Python" +category = "main" +optional = false +python-versions = ">=3.6.2" + +[package.dependencies] +wcwidth = "*" + +[[package]] +name = "ptyprocess" +version = "0.7.0" +description = "Run a subprocess in a pseudo terminal" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "Pygments" +version = "2.13.0" +description = "Pygments is a syntax highlighting package written in Python." +category = "main" +optional = false +python-versions = ">=3.6" + +[package.extras] +plugins = ["importlib-metadata"] + +[[package]] +name = "pyparsing" +version = "3.0.9" +description = "pyparsing module - Classes and methods to define and execute parsing grammars" +category = "main" +optional = false +python-versions = ">=3.6.8" + +[package.extras] +diagrams = ["jinja2", "railroad-diagrams"] + +[[package]] +name = "pytest" +version = "7.2.0" +description = "pytest: simple powerful testing with Python" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +attrs = ">=19.2.0" +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=0.12,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} + +[package.extras] +testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] + +[[package]] +name = "python-dateutil" +version = "2.8.2" +description = "Extensions to the standard Python datetime module" +category = "main" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" + +[package.dependencies] +six = ">=1.5" + +[[package]] +name = "pytzdata" +version = "2020.1" +description = "The Olson timezone database for Python." +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[[package]] +name = "redis" +version = "4.4.0" +description = "Python client for Redis database and key-value store" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +async-timeout = ">=4.0.2" +importlib-metadata = {version = ">=1.0", markers = "python_version < \"3.8\""} +typing-extensions = {version = "*", markers = "python_version < \"3.8\""} + +[package.extras] +hiredis = ["hiredis (>=1.0.0)"] +ocsp = ["cryptography (>=36.0.1)", "pyopenssl (==20.0.1)", "requests (>=2.26.0)"] + +[[package]] +name = "six" +version = "1.16.0" +description = "Python 2 and 3 compatibility utilities" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" + +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "typing-extensions" +version = "4.4.0" +description = "Backported and Experimental Type Hints for Python 3.7+" +category = "main" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "wcwidth" +version = "0.1.9" +description = "Measures number of Terminal column cells of wide-character codes" +category = "main" +optional = false +python-versions = "*" + +[[package]] +name = "zipp" +version = "3.11.0" +description = "Backport of pathlib-compatible object wrapper for zip files" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)"] +testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] + +[metadata] +lock-version = "1.1" +python-versions = "^3.7" +content-hash = "6ad42fae2cc7eab35a27500c86a45fffef1d406d3f324f173c56aee107d8a480" + +[metadata.files] +async-timeout = [ + {file = "async-timeout-4.0.2.tar.gz", hash = "sha256:2163e1640ddb52b7a8c80d0a67a08587e5d245cc9c553a74a847056bc2976b15"}, + {file = "async_timeout-4.0.2-py3-none-any.whl", hash = "sha256:8ca1e4fcf50d07413d66d1a5e416e42cfdf5851c981d679a09851a6853383b3c"}, +] +attrs = [ + {file = "attrs-22.2.0-py3-none-any.whl", hash = "sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836"}, + {file = "attrs-22.2.0.tar.gz", hash = "sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99"}, +] +click = [ + {file = "click-7.1.2-py2.py3-none-any.whl", hash = "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"}, + {file = "click-7.1.2.tar.gz", hash = "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"}, +] +colorama = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] +configobj = [ + {file = "configobj-5.0.6.tar.gz", hash = "sha256:a2f5650770e1c87fb335af19a9b7eb73fc05ccf22144eb68db7d00cd2bcb0902"}, +] +exceptiongroup = [ + {file = "exceptiongroup-1.1.0-py3-none-any.whl", hash = "sha256:327cbda3da756e2de031a3107b81ab7b3770a602c4d16ca618298c526f4bec1e"}, + {file = "exceptiongroup-1.1.0.tar.gz", hash = "sha256:bcb67d800a4497e1b404c2dd44fca47d3b7a5e5433dbab67f96c1a685cdfdf23"}, +] +importlib-metadata = [ + {file = "importlib_metadata-5.2.0-py3-none-any.whl", hash = "sha256:0eafa39ba42bf225fc00e67f701d71f85aead9f878569caf13c3724f704b970f"}, + {file = "importlib_metadata-5.2.0.tar.gz", hash = "sha256:404d48d62bba0b7a77ff9d405efd91501bef2e67ff4ace0bed40a0cf28c3c7cd"}, +] +importlib-resources = [ + {file = "importlib_resources-5.10.2-py3-none-any.whl", hash = "sha256:7d543798b0beca10b6a01ac7cafda9f822c54db9e8376a6bf57e0cbd74d486b6"}, + {file = "importlib_resources-5.10.2.tar.gz", hash = "sha256:e4a96c8cc0339647ff9a5e0550d9f276fc5a01ffa276012b58ec108cfd7b8484"}, +] +iniconfig = [ + {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, + {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, +] +mistune = [ + {file = "mistune-2.0.4-py2.py3-none-any.whl", hash = "sha256:182cc5ee6f8ed1b807de6b7bb50155df7b66495412836b9a74c8fbdfc75fe36d"}, + {file = "mistune-2.0.4.tar.gz", hash = "sha256:9ee0a66053e2267aba772c71e06891fa8f1af6d4b01d5e84e267b4570d4d9808"}, +] +packaging = [ + {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, + {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, +] +pendulum = [ + {file = "pendulum-2.1.2-cp27-cp27m-macosx_10_15_x86_64.whl", hash = "sha256:b6c352f4bd32dff1ea7066bd31ad0f71f8d8100b9ff709fb343f3b86cee43efe"}, + {file = "pendulum-2.1.2-cp27-cp27m-win_amd64.whl", hash = "sha256:318f72f62e8e23cd6660dbafe1e346950281a9aed144b5c596b2ddabc1d19739"}, + {file = "pendulum-2.1.2-cp35-cp35m-macosx_10_15_x86_64.whl", hash = "sha256:0731f0c661a3cb779d398803655494893c9f581f6488048b3fb629c2342b5394"}, + {file = "pendulum-2.1.2-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:3481fad1dc3f6f6738bd575a951d3c15d4b4ce7c82dce37cf8ac1483fde6e8b0"}, + {file = "pendulum-2.1.2-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:9702069c694306297ed362ce7e3c1ef8404ac8ede39f9b28b7c1a7ad8c3959e3"}, + {file = "pendulum-2.1.2-cp35-cp35m-win_amd64.whl", hash = "sha256:fb53ffa0085002ddd43b6ca61a7b34f2d4d7c3ed66f931fe599e1a531b42af9b"}, + {file = "pendulum-2.1.2-cp36-cp36m-macosx_10_15_x86_64.whl", hash = "sha256:c501749fdd3d6f9e726086bf0cd4437281ed47e7bca132ddb522f86a1645d360"}, + {file = "pendulum-2.1.2-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:c807a578a532eeb226150d5006f156632df2cc8c5693d778324b43ff8c515dd0"}, + {file = "pendulum-2.1.2-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:2d1619a721df661e506eff8db8614016f0720ac171fe80dda1333ee44e684087"}, + {file = "pendulum-2.1.2-cp36-cp36m-win_amd64.whl", hash = "sha256:f888f2d2909a414680a29ae74d0592758f2b9fcdee3549887779cd4055e975db"}, + {file = "pendulum-2.1.2-cp37-cp37m-macosx_10_15_x86_64.whl", hash = "sha256:e95d329384717c7bf627bf27e204bc3b15c8238fa8d9d9781d93712776c14002"}, + {file = "pendulum-2.1.2-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:4c9c689747f39d0d02a9f94fcee737b34a5773803a64a5fdb046ee9cac7442c5"}, + {file = "pendulum-2.1.2-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:1245cd0075a3c6d889f581f6325dd8404aca5884dea7223a5566c38aab94642b"}, + {file = "pendulum-2.1.2-cp37-cp37m-win_amd64.whl", hash = "sha256:db0a40d8bcd27b4fb46676e8eb3c732c67a5a5e6bfab8927028224fbced0b40b"}, + {file = "pendulum-2.1.2-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:f5e236e7730cab1644e1b87aca3d2ff3e375a608542e90fe25685dae46310116"}, + {file = "pendulum-2.1.2-cp38-cp38-manylinux1_i686.whl", hash = "sha256:de42ea3e2943171a9e95141f2eecf972480636e8e484ccffaf1e833929e9e052"}, + {file = "pendulum-2.1.2-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7c5ec650cb4bec4c63a89a0242cc8c3cebcec92fcfe937c417ba18277d8560be"}, + {file = "pendulum-2.1.2-cp38-cp38-win_amd64.whl", hash = "sha256:33fb61601083f3eb1d15edeb45274f73c63b3c44a8524703dc143f4212bf3269"}, + {file = "pendulum-2.1.2-cp39-cp39-manylinux1_i686.whl", hash = "sha256:29c40a6f2942376185728c9a0347d7c0f07905638c83007e1d262781f1e6953a"}, + {file = "pendulum-2.1.2-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:94b1fc947bfe38579b28e1cccb36f7e28a15e841f30384b5ad6c5e31055c85d7"}, + {file = "pendulum-2.1.2.tar.gz", hash = "sha256:b06a0ca1bfe41c990bbf0c029f0b6501a7f2ec4e38bfec730712015e8860f207"}, +] +pexpect = [ + {file = "pexpect-4.8.0-py2.py3-none-any.whl", hash = "sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937"}, + {file = "pexpect-4.8.0.tar.gz", hash = "sha256:fc65a43959d153d0114afe13997d439c22823a27cefceb5ff35c2178c6784c0c"}, +] +pluggy = [ + {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, + {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, +] +prompt-toolkit = [ + {file = "prompt_toolkit-3.0.36-py3-none-any.whl", hash = "sha256:aa64ad242a462c5ff0363a7b9cfe696c20d55d9fc60c11fd8e632d064804d305"}, + {file = "prompt_toolkit-3.0.36.tar.gz", hash = "sha256:3e163f254bef5a03b146397d7c1963bd3e2812f0964bb9a24e6ec761fd28db63"}, +] +ptyprocess = [ + {file = "ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35"}, + {file = "ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220"}, +] +Pygments = [ + {file = "Pygments-2.13.0-py3-none-any.whl", hash = "sha256:f643f331ab57ba3c9d89212ee4a2dabc6e94f117cf4eefde99a0574720d14c42"}, + {file = "Pygments-2.13.0.tar.gz", hash = "sha256:56a8508ae95f98e2b9bdf93a6be5ae3f7d8af858b43e02c5a2ff083726be40c1"}, +] +pyparsing = [ + {file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"}, + {file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"}, +] +pytest = [ + {file = "pytest-7.2.0-py3-none-any.whl", hash = "sha256:892f933d339f068883b6fd5a459f03d85bfcb355e4981e146d2c7616c21fef71"}, + {file = "pytest-7.2.0.tar.gz", hash = "sha256:c4014eb40e10f11f355ad4e3c2fb2c6c6d1919c73f3b5a433de4708202cade59"}, +] +python-dateutil = [ + {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, + {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, +] +pytzdata = [ + {file = "pytzdata-2020.1-py2.py3-none-any.whl", hash = "sha256:e1e14750bcf95016381e4d472bad004eef710f2d6417240904070b3d6654485f"}, + {file = "pytzdata-2020.1.tar.gz", hash = "sha256:3efa13b335a00a8de1d345ae41ec78dd11c9f8807f522d39850f2dd828681540"}, +] +redis = [ + {file = "redis-4.4.0-py3-none-any.whl", hash = "sha256:cae3ee5d1f57d8caf534cd8764edf3163c77e073bdd74b6f54a87ffafdc5e7d9"}, + {file = "redis-4.4.0.tar.gz", hash = "sha256:7b8c87d19c45d3f1271b124858d2a5c13160c4e74d4835e28273400fa34d5228"}, +] +six = [ + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, +] +tomli = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] +typing-extensions = [ + {file = "typing_extensions-4.4.0-py3-none-any.whl", hash = "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e"}, + {file = "typing_extensions-4.4.0.tar.gz", hash = "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa"}, +] +wcwidth = [ + {file = "wcwidth-0.1.9-py2.py3-none-any.whl", hash = "sha256:cafe2186b3c009a04067022ce1dcd79cb38d8d65ee4f4791b8888d6599d1bbe1"}, + {file = "wcwidth-0.1.9.tar.gz", hash = "sha256:ee73862862a156bf77ff92b09034fc4825dd3af9cf81bc5b360668d425f3c5f1"}, +] +zipp = [ + {file = "zipp-3.11.0-py3-none-any.whl", hash = "sha256:83a28fcb75844b5c0cdaf5aa4003c2d728c77e05f5aeabe8e95e56727005fbaa"}, + {file = "zipp-3.11.0.tar.gz", hash = "sha256:a7a22e05929290a67401440b39690ae6563279bced5f314609d9d03798f56766"}, +] diff --git a/pyoxidizer.template.bzl b/pyoxidizer.template.bzl new file mode 100644 index 0000000..ea67485 --- /dev/null +++ b/pyoxidizer.template.bzl @@ -0,0 +1,343 @@ +# This file defines how PyOxidizer application building and packaging is +# performed. See PyOxidizer's documentation at +# https://pyoxidizer.readthedocs.io/en/stable/ for details of this +# configuration file format. + +# Obtain the default PythonDistribution for our build target. We link +# this distribution into our produced executable and extract the Python +# standard library from it. +def make_dist(): + return default_python_distribution() + +# Configuration files consist of functions which define build "targets." +# This function creates a Python executable and installs it in a destination +# directory. +def make_exe(dist): + # This function creates a `PythonPackagingPolicy` instance, which + # influences how executables are built and how resources are added to + # the executable. You can customize the default behavior by assigning + # to attributes and calling functions. + policy = dist.make_python_packaging_policy() + + # Enable support for non-classified "file" resources to be added to + # resource collections. + # policy.allow_files = True + + # Control support for loading Python extensions and other shared libraries + # from memory. This is only supported on Windows and is ignored on other + # platforms. + # policy.allow_in_memory_shared_library_loading = True + + # Control whether to generate Python bytecode at various optimization + # levels. The default optimization level used by Python is 0. + # policy.bytecode_optimize_level_zero = True + # policy.bytecode_optimize_level_one = True + policy.bytecode_optimize_level_two = True + + # Package all available Python extensions in the distribution. + policy.extension_module_filter = "all" + + # Package the minimum set of Python extensions in the distribution needed + # to run a Python interpreter. Various functionality from the Python + # standard library won't work with this setting! But it can be used to + # reduce the size of generated executables by omitting unused extensions. + # policy.extension_module_filter = "minimal" + + # Package Python extensions in the distribution not having additional + # library dependencies. This will exclude working support for SSL, + # compression formats, and other functionality. + # policy.extension_module_filter = "no-libraries" + + # Package Python extensions in the distribution not having a dependency on + # copyleft licensed software like GPL. + # policy.extension_module_filter = "no-copyleft" + + # Controls whether the file scanner attempts to classify files and emit + # resource-specific values. + # policy.file_scanner_classify_files = True + + # Controls whether `File` instances are emitted by the file scanner. + # policy.file_scanner_emit_files = False + + # Controls the `add_include` attribute of "classified" resources + # (`PythonModuleSource`, `PythonPackageResource`, etc). + # policy.include_classified_resources = True + + # Toggle whether Python module source code for modules in the Python + # distribution's standard library are included. + policy.include_distribution_sources = True + + # Toggle whether Python package resource files for the Python standard + # library are included. + policy.include_distribution_resources = False + + # Controls the `add_include` attribute of `File` resources. + policy.include_file_resources = False + + # Controls the `add_include` attribute of `PythonModuleSource` not in + # the standard library. + # policy.include_non_distribution_sources = True + + # Toggle whether files associated with tests are included. + policy.include_test = False + + # Resources are loaded from "in-memory" or "filesystem-relative" paths. + # The locations to attempt to add resources to are defined by the + # `resources_location` and `resources_location_fallback` attributes. + # The former is the first/primary location to try and the latter is + # an optional fallback. + + # Use in-memory location for adding resources by default. + # policy.resources_location = "in-memory" + + # Use filesystem-relative location for adding resources by default. + policy.resources_location = "filesystem-relative:lib" + + # Attempt to add resources relative to the built binary when + # `resources_location` fails. + # policy.resources_location_fallback = "filesystem-relative:prefix" + + # Clear out a fallback resource location. + # policy.resources_location_fallback = None + + # Define a preferred Python extension module variant in the Python distribution + # to use. + # policy.set_preferred_extension_module_variant("foo", "bar") + + # Configure policy values to classify files as typed resources. + # (This is the default.) + # policy.set_resource_handling_mode("classify") + + # Configure policy values to handle files as files and not attempt + # to classify files as specific types. + # policy.set_resource_handling_mode("files") + + # This variable defines the configuration of the embedded Python + # interpreter. By default, the interpreter will run a Python REPL + # using settings that are appropriate for an "isolated" run-time + # environment. + # + # The configuration of the embedded Python interpreter can be modified + # by setting attributes on the instance. Some of these are + # documented below. + python_config = dist.make_python_interpreter_config() + + # Make the embedded interpreter behave like a `python` process. + # python_config.config_profile = "python" + + # Set initial value for `sys.path`. If the string `$ORIGIN` exists in + # a value, it will be expanded to the directory of the built executable. + python_config.module_search_paths = ["$ORIGIN/lib"] + + # Use jemalloc as Python's memory allocator. + # python_config.allocator_backend = "jemalloc" + + # Use mimalloc as Python's memory allocator. + # python_config.allocator_backend = "mimalloc" + + # Use snmalloc as Python's memory allocator. + # python_config.allocator_backend = "snmalloc" + + # Let Python choose which memory allocator to use. (This will likely + # use the malloc()/free() linked into the program. + python_config.allocator_backend = "default" + + # Enable the use of a custom allocator backend with the "raw" memory domain. + # python_config.allocator_raw = True + + # Enable the use of a custom allocator backend with the "mem" memory domain. + # python_config.allocator_mem = True + + # Enable the use of a custom allocator backend with the "obj" memory domain. + # python_config.allocator_obj = True + + # Enable the use of a custom allocator backend with pymalloc's arena + # allocator. + # python_config.allocator_pymalloc_arena = True + + # Enable Python memory allocator debug hooks. + # python_config.allocator_debug = True + + # Control whether `oxidized_importer` is the first importer on + # `sys.meta_path`. + # python_config.oxidized_importer = False + + # Enable the standard path-based importer which attempts to load + # modules from the filesystem. + # python_config.filesystem_importer = True + + # Set `sys.frozen = True` + # python_config.sys_frozen = True + + # Set `sys.meipass` + # python_config.sys_meipass = True + + # Write files containing loaded modules to the directory specified + # by the given environment variable. + # python_config.write_modules_directory_env = "/tmp/oxidized/loaded_modules" + + # Evaluate a string as Python code when the interpreter starts. + python_config.run_command = "from iredis.entry import main; main()" + + # Run a Python module as __main__ when the interpreter starts. + # python_config.run_module = "<module>" + + # Run a Python file when the interpreter starts. + # python_config.run_filename = "/path/to/file" + + # Produce a PythonExecutable from a Python distribution, embedded + # resources, and other options. The returned object represents the + # standalone executable that will be built. + exe = dist.to_python_executable( + name="iredis", + + # If no argument passed, the default `PythonPackagingPolicy` for the + # distribution is used. + packaging_policy=policy, + + # If no argument passed, the default `PythonInterpreterConfig` is used. + config=python_config, + ) + + # Install tcl/tk support files to a specified directory so the `tkinter` Python + # module works. + # exe.tcl_files_path = "lib" + + # Never attempt to copy Windows runtime DLLs next to the built executable. + # exe.windows_runtime_dlls_mode = "never" + + # Copy Windows runtime DLLs next to the built executable when they can be + # located. + # exe.windows_runtime_dlls_mode = "when-present" + + # Copy Windows runtime DLLs next to the build executable and error if this + # cannot be done. + # exe.windows_runtime_dlls_mode = "always" + + # Make the executable a console application on Windows. + # exe.windows_subsystem = "console" + + # Make the executable a non-console application on Windows. + # exe.windows_subsystem = "windows" + + # Invoke `pip download` to install a single package using wheel archives + # obtained via `pip download`. `pip_download()` returns objects representing + # collected files inside Python wheels. `add_python_resources()` adds these + # objects to the binary, with a load location as defined by the packaging + # policy's resource location attributes. + #exe.add_python_resources(exe.pip_download(["pyflakes==2.2.0"])) + + # Invoke `pip install` with our Python distribution to install a single package. + # `pip_install()` returns objects representing installed files. + # `add_python_resources()` adds these objects to the binary, with a load + # location as defined by the packaging policy's resource location + # attributes. + exe.add_python_resources(exe.pip_install(["$WHEEL_PATH"])) + + # Invoke `pip install` using a requirements file and add the collected resources + # to our binary. + #exe.add_python_resources(exe.pip_install(["-r", "requirements.txt"])) + + + + # Read Python files from a local directory and add them to our embedded + # context, taking just the resources belonging to the `foo` and `bar` + # Python packages. + #exe.add_python_resources(exe.read_package_root( + # path="/src/mypackage", + # packages=["foo", "bar"], + #)) + + # Discover Python files from a virtualenv and add them to our embedded + # context. + #exe.add_python_resources(exe.read_virtualenv(path="/path/to/venv")) + + # Filter all resources collected so far through a filter of names + # in a file. + #exe.filter_from_files(files=["/path/to/filter-file"])) + + # Return our `PythonExecutable` instance so it can be built and + # referenced by other consumers of this target. + return exe + +def make_embedded_resources(exe): + return exe.to_embedded_resources() + +def make_install(exe): + # Create an object that represents our installed application file layout. + files = FileManifest() + + # Add the generated executable to our install layout in the root directory. + files.add_python_resource(".", exe) + + return files + +def make_msi(exe): + # See the full docs for more. But this will convert your Python executable + # into a `WiXMSIBuilder` Starlark type, which will be converted to a Windows + # .msi installer when it is built. + return exe.to_wix_msi_builder( + # Simple identifier of your app. + "iredis", + # The name of your application. + "iredis", + # The version of your application. + "1.9.1", + # The author/manufacturer of your application. + "laixintao" + ) + + +# Dynamically enable automatic code signing. +def register_code_signers(): + # You will need to run with `pyoxidizer build --var ENABLE_CODE_SIGNING 1` for + # this if block to be evaluated. + if not VARS.get("ENABLE_CODE_SIGNING"): + return + + # Use a code signing certificate in a .pfx/.p12 file, prompting the + # user for its path and password to open. + # pfx_path = prompt_input("path to code signing certificate file") + # pfx_password = prompt_password( + # "password for code signing certificate file", + # confirm = True + # ) + # signer = code_signer_from_pfx_file(pfx_path, pfx_password) + + # Use a code signing certificate in the Windows certificate store, specified + # by its SHA-1 thumbprint. (This allows you to use YubiKeys and other + # hardware tokens if they speak to the Windows certificate APIs.) + # sha1_thumbprint = prompt_input( + # "SHA-1 thumbprint of code signing certificate in Windows store" + # ) + # signer = code_signer_from_windows_store_sha1_thumbprint(sha1_thumbprint) + + # Choose a code signing certificate automatically from the Windows + # certificate store. + # signer = code_signer_from_windows_store_auto() + + # Activate your signer so it gets called automatically. + # signer.activate() + + +# Call our function to set up automatic code signers. +register_code_signers() + +# Tell PyOxidizer about the build targets defined above. +register_target("dist", make_dist) +register_target("exe", make_exe, depends=["dist"]) +register_target("resources", make_embedded_resources, depends=["exe"], default_build_script=True) +register_target("install", make_install, depends=["exe"], default=True) +register_target("msi_installer", make_msi, depends=["exe"]) + +# Resolve whatever targets the invoker of this configuration file is requesting +# be resolved. +resolve_targets() + +# END OF COMMON USER-ADJUSTED SETTINGS. +# +# Everything below this is typically managed by PyOxidizer and doesn't need +# to be updated by people. + +PYOXIDIZER_VERSION = "0.14.1" +PYOXIDIZER_COMMIT = "UNKNOWN" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c9a676a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,55 @@ +[tool.poetry] +name = "iredis" +version = "1.13.0" +description = "Terminal client for Redis with auto-completion and syntax highlighting." +authors = ["laixintao <laixintao1995@163.com>"] +readme = 'README.md' +license = "BSD-3-Clause" +repository = 'https://github.com/laixintao/iredis' +homepage = "https://github.com/laixintao/iredis" +keywords=["Redis", "key-value store", "Commandline tools", "Redis Client"] +classifiers = [ +# see https://pypi.org/pypi?%3Aaction=list_classifiers + "Development Status :: 4 - Beta", + "Environment :: Console", + "Environment :: Console :: Curses", + "Environment :: MacOS X", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Database", + "License :: OSI Approved :: MIT License", + "Intended Audience :: Developers", +] + +packages = [ + { include = "iredis" }, + { include = "tests", format = "sdist" }, +] + +[tool.poetry.dependencies] +python = "^3.7" +prompt_toolkit = "^3" +Pygments = "^2" +mistune = "^2.0" +configobj = "^5.0" +click = "^7.0" +pendulum = "^2.0" +importlib-resources = "^5.1.0" +# wcwidth 0.2.x uses pkg_resources which is not supported by PyOxidizer +wcwidth = "0.1.9" +packaging = "^21.3" +redis = "^4.3.4" + +[tool.poetry.dev-dependencies] +pytest = "^7.2" +pexpect = "^4.7" + +[tool.poetry.scripts] +iredis = 'iredis.entry:main' + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/scripts/add_fooset_commands.txt b/scripts/add_fooset_commands.txt new file mode 100644 index 0000000..92b0312 --- /dev/null +++ b/scripts/add_fooset_commands.txt @@ -0,0 +1 @@ +SADD fooset alligator ant bear bee bird camel cat cheetah chicken chimpanzee cow crocodile deer dog dolphin duck eagle elephant fish fly fox frog giraffe goat goldfish hamster hippopotamus horse kangaroo kitten lion lobster monkey octopus owl panda pig puppy rabbit rat scorpion seal shark sheep snail snake spider squirrel tiger turtle wolf zebra diff --git a/scripts/add_hash.txt b/scripts/add_hash.txt new file mode 100644 index 0000000..b42e716 --- /dev/null +++ b/scripts/add_hash.txt @@ -0,0 +1,3 @@ +HMSET hash1 Tolerant intolerant Decent indecent Discrete indiscreet Excusable inexcusable +HMSET hash2 Behave misbehave Interpret misinterpret Lead mislead Trust mistrust Likely unlikely Able unable Fortunate unfortunate Forgiving unforgiving +HMSET hash3 Entity nonentity Conformist nonconformist Payment nonpayment Sense nonsense diff --git a/scripts/add_lists.txt b/scripts/add_lists.txt new file mode 100644 index 0000000..f8b7542 --- /dev/null +++ b/scripts/add_lists.txt @@ -0,0 +1,3 @@ +LPUSH list:animals alligator ant bear bee bird camel cat cheetah chicken chimpanzee cow crocodile deer dog dolphin duck eagle elephant fish fly fox frog giraffe goat goldfish hamster hippopotamus horse kangaroo kitten lion lobster monkey octopus owl panda pig puppy rabbit rat scorpion seal shark sheep snail snake spider squirrel tiger turtle wolf zebra +LPUSH list:buildings "airport" "apartment building" "bank" "barber shop" "book store" "bowling alley" "bus stop" "church" "convenience store" "department store" "fire department" "gas station" "hospital" "house" "library" "movie theater" "museum" "office building" "post office" "restaurant" "school" "mall" "supermarket" "train station" +LPUSH list:restaurant bill breakfast check cup dessert dinner dressing drink fork hamburger knife lunch menu napkin order salt spoon water coffee tea diff --git a/scripts/add_myzset_commands.txt b/scripts/add_myzset_commands.txt new file mode 100644 index 0000000..4532d60 --- /dev/null +++ b/scripts/add_myzset_commands.txt @@ -0,0 +1,52 @@ +ZADD myzset 28693 alligator +ZADD myzset 29596 ant +ZADD myzset 11320 bear +ZADD myzset 28872 bee +ZADD myzset 26656 bird +ZADD myzset 708 camel +ZADD myzset 31829 cat +ZADD myzset 7424 cheetah +ZADD myzset 30668 chicken +ZADD myzset 154 chimpanzee +ZADD myzset 24709 cow +ZADD myzset 25916 crocodile +ZADD myzset 6888 deer +ZADD myzset 32034 dog +ZADD myzset 15528 dolphin +ZADD myzset 667 duck +ZADD myzset 202 eagle +ZADD myzset 19551 elephant +ZADD myzset 32231 fish +ZADD myzset 4002 fly +ZADD myzset 18679 fox +ZADD myzset 10147 frog +ZADD myzset 28405 giraffe +ZADD myzset 15557 goat +ZADD myzset 2062 goldfish +ZADD myzset 25018 hamster +ZADD myzset 19888 hippopotamus +ZADD myzset 24984 horse +ZADD myzset 16088 kangaroo +ZADD myzset 7907 kitten +ZADD myzset 9814 lion +ZADD myzset 32194 lobster +ZADD myzset 8036 monkey +ZADD myzset 19483 octopus +ZADD myzset 9398 owl +ZADD myzset 24987 panda +ZADD myzset 28153 pig +ZADD myzset 28829 puppy +ZADD myzset 9709 rabbit +ZADD myzset 14184 rat +ZADD myzset 11208 scorpion +ZADD myzset 11385 seal +ZADD myzset 1900 shark +ZADD myzset 6890 sheep +ZADD myzset 6897 snail +ZADD myzset 7659 snake +ZADD myzset 22338 spider +ZADD myzset 3676 squirrel +ZADD myzset 1490 tiger +ZADD myzset 31275 turtle +ZADD myzset 8113 wolf +ZADD myzset 1601 zebra diff --git a/scripts/check_renders.sh b/scripts/check_renders.sh new file mode 100755 index 0000000..f84602e --- /dev/null +++ b/scripts/check_renders.sh @@ -0,0 +1 @@ +rg -vw render_int iredis/data/command_syntax.csv | rg -vw render_simple_string | rg -wv render_bulk_string | rg -vw render_list | rg -vw render_members | rg -vw render_bulk_string_decode | rg -vw render_string_or_int | rg -wv render_list_or_string diff --git a/scripts/conf/slave/slave.conf b/scripts/conf/slave/slave.conf new file mode 100644 index 0000000..f8749d9 --- /dev/null +++ b/scripts/conf/slave/slave.conf @@ -0,0 +1,2 @@ +slaveof localhost 6379 +port 6479 diff --git a/scripts/display_all_command_hints.py b/scripts/display_all_command_hints.py new file mode 100644 index 0000000..9f13a4c --- /dev/null +++ b/scripts/display_all_command_hints.py @@ -0,0 +1,7 @@ +from iredis.utils import command_syntax +from iredis.style import STYLE +from iredis.commands import commands_summary +from prompt_toolkit import print_formatted_text + +for command, info in commands_summary.items(): + print_formatted_text(command_syntax(command, info), style=STYLE) diff --git a/scripts/download_redis_commands.py b/scripts/download_redis_commands.py new file mode 100755 index 0000000..4dda6b8 --- /dev/null +++ b/scripts/download_redis_commands.py @@ -0,0 +1,50 @@ +#!python3 + +""" +Download all Reids commands from https://redis.io/commands. +Output to csv format. +""" +import sys +import csv + +from lxml import etree +import requests + +stdout_writer = csv.writer(sys.stdout) + + +def eprint(*args, **kwargs): + print(*args, file=sys.stderr, **kwargs) + + +eprint("Download https://redis.io/commands page...") +page = requests.get("https://redis.io/commands").text +eprint("Download finished!") + +eprint("Start prase page...") +html = etree.HTML(page) +commands = html.xpath("//div[@class='container']/ul/li") +stdout_writer.writerow(["Group", "Command", "Args", "Summary", "Redis.io link"]) +command_rows = [] +# parse page +for command in commands: + group = command.attrib["data-group"] + command_name = command.xpath("./a/span[@class='command']/text()")[0].strip() + command_args = command.xpath( + "./a/span[@class='command']/span[@class='args']/text()" + )[0].strip() + command_summary = command.xpath("./a/span[@class='summary']/text()")[0].strip() + command_link = "https://redis.io" + command.xpath("./a/@href")[0].strip() + command_rows.append( + [ + group, + command_name, + " ".join(command_args.split()), + command_summary, + command_link, + ] + ) +# write to stdout +for row in sorted(command_rows): + stdout_writer.writerow(row) +eprint("Down.") diff --git a/scripts/multi_del.txt b/scripts/multi_del.txt new file mode 100644 index 0000000..685cb03 --- /dev/null +++ b/scripts/multi_del.txt @@ -0,0 +1,4 @@ +DEL key-001 +DEL key-002 +DEL key-003 +DEL key-004 diff --git a/scripts/redis.conf b/scripts/redis.conf new file mode 100644 index 0000000..368a34c --- /dev/null +++ b/scripts/redis.conf @@ -0,0 +1,4 @@ +port 7379 +unixsocket /tmp/redis.sock +unixsocketperm 775 +aclfile /tmp/redis.acl diff --git a/scripts/set_999_keys_in_redis.py b/scripts/set_999_keys_in_redis.py new file mode 100644 index 0000000..9a65f04 --- /dev/null +++ b/scripts/set_999_keys_in_redis.py @@ -0,0 +1,6 @@ +import redis + +client = redis.StrictRedis(db=3) + +for i in range(100000): + client.set(f"key-{i}", "hello world") diff --git a/scripts/tcp-proxy.sh b/scripts/tcp-proxy.sh new file mode 100755 index 0000000..ff0ce53 --- /dev/null +++ b/scripts/tcp-proxy.sh @@ -0,0 +1,20 @@ +#!/bin/sh -e +# Display TCP packets +# code from: +# https://notes.tweakblogs.net/blog/7955/using-netcat-to-build-a-simple-tcp-proxy-in-linux.html + +if [ $# != 3 ] +then + echo "usage: $0 <src-port> <dst-host> <dst-port>" + exit 0 +fi + +TMP=`mktemp -d` +BACK=$TMP/pipe.back +SENT=$TMP/pipe.sent +RCVD=$TMP/pipe.rcvd +trap 'rm -rf "$TMP"' EXIT +mkfifo -m 0600 "$BACK" "$SENT" "$RCVD" +sed 's/^/ => /' <"$SENT" & +sed 's/^/<= /' <"$RCVD" & +nc -l 127.0.0.1 "$1" <"$BACK" | tee "$SENT" | nc "$2" "$3" | tee "$RCVD" >"$BACK" diff --git a/scripts/update_command_from_redis_doc.sh b/scripts/update_command_from_redis_doc.sh new file mode 100755 index 0000000..7cc161f --- /dev/null +++ b/scripts/update_command_from_redis_doc.sh @@ -0,0 +1 @@ +wget https://raw.githubusercontent.com/antirez/redis-doc/master/commands.json -O commands.json diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__init__.py diff --git a/tests/cli_tests/__init__.py b/tests/cli_tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/cli_tests/__init__.py diff --git a/tests/cli_tests/test_cli_pubsub.py b/tests/cli_tests/test_cli_pubsub.py new file mode 100644 index 0000000..956e105 --- /dev/null +++ b/tests/cli_tests/test_cli_pubsub.py @@ -0,0 +1,31 @@ +def test_subscribe(cli, clean_redis): + cli.sendline("subscribe foo") + cli.expect("subscribe from") + cli.expect("foo") + cli.expect("1") + + clean_redis.publish("foo", "test message") + cli.expect("from") + cli.expect("foo") + cli.expect("test message") + + # unsubscribe, send ctrl-c + cli.send(chr(3)) + cli.expect("unsubscribe from") + cli.expect("0") + + +def test_subscribe_in_raw_mode(raw_cli, clean_redis): + raw_cli.sendline("subscribe foo") + raw_cli.expect("subscribe\r") + raw_cli.expect("foo\r") + raw_cli.expect("1\r") + + clean_redis.publish("foo", "test message") + raw_cli.expect("message\r") + raw_cli.expect("foo\r") + raw_cli.expect("test message") + + # unsubscribe, send ctrl-c + raw_cli.send(chr(3)) + raw_cli.expect("0\r") diff --git a/tests/cli_tests/test_cli_start.py b/tests/cli_tests/test_cli_start.py new file mode 100644 index 0000000..8045947 --- /dev/null +++ b/tests/cli_tests/test_cli_start.py @@ -0,0 +1,91 @@ +import pexpect +import pytest +from textwrap import dedent + + +def test_start_on_connection_error(): + cli = pexpect.spawn("iredis -p 12345", timeout=1) + cli.logfile_read = open("cli_test.log", "ab") + cli.expect(r"Error \d+ connecting to 127.0.0.1:12345. Connection refused.") + cli.close() + + +def test_start_with_client_name(): + cli = pexpect.spawn("iredis --client_name custom_name", timeout=2) + cli.expect("iredis") + cli.sendline("CLIENT GETNAME") + cli.expect("custom_name") + cli.close() + + +def test_short_help_option(config): + c = pexpect.spawn("iredis -h", timeout=2) + + c.expect("Show this message and exit.") + + c = pexpect.spawn("iredis -h 127.0.0.1") + c.expect("127.0.0.1:6379>") + + c.close() + + +@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) != 5") +def test_server_version_in_starting_on5(): + c = pexpect.spawn("iredis", timeout=2) + c.expect("redis-server 5") + c.close() + + +@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) != 6") +def test_server_version_in_starting_on6(): + c = pexpect.spawn("iredis", timeout=2) + c.expect("redis-server 6") + c.close() + + +def test_connection_using_url(clean_redis): + c = pexpect.spawn("iredis --url redis://localhost:6379/7", timeout=2) + c.logfile_read = open("cli_test.log", "ab") + c.expect(["iredis", "127.0.0.1:6379[7]>"]) + c.sendline("set current-db 7") + c.expect("OK") + c.close() + + +def test_connection_using_url_from_env(clean_redis, monkeypatch): + monkeypatch.setenv("IREDIS_URL", "redis://localhost:6379/7") + c = pexpect.spawn("iredis", timeout=2) + c.logfile_read = open("cli_test.log", "ab") + c.expect(["iredis", "localhost:6379[7]>"]) + c.sendline("set current-db 7") + c.expect("OK") + c.close() + + +@pytest.mark.xfail(reason="current test in github action, socket not supported.") +# https://github.community/t5/GitHub-Actions/Job-service-command/td-p/33901# +# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices +def test_connect_via_socket(fake_redis_socket): + config_content = dedent( + """ + [main] + log_location = /tmp/iredis1.log + no_info=True + """ + ) + with open("/tmp/iredisrc", "w+") as etc_config: + etc_config.write(config_content) + + c = pexpect.spawn("iredis --iredisrc /tmp/iredisrc -s /tmp/test.sock", timeout=2) + c.logfile_read = open("cli_test.log", "ab") + c.expect("redis /tmp/test.sock") + + c.close() + + +def test_iredis_start_with_prompt(): + cli = pexpect.spawn("iredis --prompt '{host}abc{port}def{client_name}'", timeout=2) + cli.logfile_read = open("cli_test.log", "ab") + cli.expect("iredis") + cli.expect("127.0.0.1abc6379defNone") + cli.close() diff --git a/tests/cli_tests/test_command_input.py b/tests/cli_tests/test_command_input.py new file mode 100644 index 0000000..75917cb --- /dev/null +++ b/tests/cli_tests/test_command_input.py @@ -0,0 +1,75 @@ +import os +import pytest + + +def test_wrong_select_db_index(cli): + cli.sendline("select 1") + cli.expect(["OK", "127.0.0.1"]) + + cli.sendline("select 128") + cli.expect(["DB index is out of range", "127.0.0.1:6379[1]>"]) + + if int(os.environ["REDIS_VERSION"]) > 5: + text = "value is not an integer or out of range" + else: + text = "invalid DB index" + + cli.sendline("select abc") + cli.expect([text, "127.0.0.1:6379[1]>"]) + + cli.sendline("select 15") + cli.expect("OK") + + +def test_set_command_with_shash(clean_redis, cli): + cli.sendline("set a \\hello\\") # legal redis command + cli.expect("OK") + + cli.sendline("get a") + cli.expect(r"hello") + + +def test_enter_key_binding(clean_redis, cli): + cli.send("set") + cli.expect("set") + cli.send("\033[B") # down + cli.sendline() # enter + + cli.sendline(" a 'hello'") + cli.expect("OK") + + cli.sendline("get a") + cli.expect(r"hello") + + +@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) < 6") +def test_auth_hidden_password_with_username(clean_redis, cli): + cli.send("auth default hello-world") + cli.expect("default") + cli.expect(r"\*{11}") + + +@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) > 5") +def test_auth_hidden_password(clean_redis, cli): + cli.send("auth hello-world") + cli.expect("auth") + cli.expect(r"\*{11}") + + +def test_hello_command_is_not_supported(cli): + cli.sendline("hello 3") + cli.expect("IRedis currently not support RESP3") + + +@pytest.mark.xfail(reason="unstable, maybe due to github action's signal handling") +def test_abort_reading_connection(cli): + cli.sendline("blpop mylist 30") + cli.send(chr(3)) + cli.expect( + r"KeyboardInterrupt received! User canceled reading response!", timeout=10 + ) + + cli.sendline("set foo bar") + cli.expect("OK") + cli.sendline("get foo") + cli.expect("bar") diff --git a/tests/cli_tests/test_completer.py b/tests/cli_tests/test_completer.py new file mode 100644 index 0000000..4ffd058 --- /dev/null +++ b/tests/cli_tests/test_completer.py @@ -0,0 +1,51 @@ +import pytest + + +def test_integer_type_completer(cli): + cli.expect("127.0.0.1") + cli.send("BITFIELD meykey GET ") + cli.expect(["i64", "u63", "u62"]) + cli.sendline("u4 #0") + cli.expect("127.0.0.1") + + cli.send("BITFIELD meykey GET ") + cli.expect(["u4", "i64", "u63", "u62"]) + + +def test_command_completion_when_a_command_is_another_command_substring( + cli, clean_redis +): + cli.expect("127.0.0.1") + cli.send("set") + cli.expect(["set", "setnx", "setex", "setbit", "setrange"]) + + cli.send("n") + cli.expect("setnx") + cli.send("x") + cli.expect("setnx") + cli.sendline("foo bar") + cli.expect(["1", "127.0.0.1"]) + + cli.send("setnx") + cli.expect("foo") + + +def test_command_completion_when_space_command(cli, clean_redis): + cli.expect("127.0.0.1") + + cli.send("command in") + cli.expect("command info") + + +@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) < 6") +def test_username_completer(cli, iredis_client): + iredis_client.execute("acl setuser", "foo1") + iredis_client.execute("acl setuser", "bar2") + + cli.expect("127.0.0.1") + cli.sendline("acl users") + cli.expect("foo1") + + cli.send("acl deluser ") + cli.expect("foo1") + cli.expect("bar2") diff --git a/tests/cli_tests/test_config.py b/tests/cli_tests/test_config.py new file mode 100644 index 0000000..1795c62 --- /dev/null +++ b/tests/cli_tests/test_config.py @@ -0,0 +1,59 @@ +import pexpect +from textwrap import dedent +from pathlib import Path + + +def test_log_location_config(): + config_content = dedent( + """ + [main] + log_location = /tmp/iredis1.log + """ + ) + with open("/tmp/iredisrc", "w+") as etc_config: + etc_config.write(config_content) + + cli = pexpect.spawn("iredis -n 15 --iredisrc /tmp/iredisrc", timeout=1) + cli.expect("127.0.0.1") + cli.close() + + log = Path("/tmp/iredis1.log") + assert log.exists() + with open(log, "r") as logfile: + content = logfile.read() + + assert len(content) > 100 + + +def test_load_prompt_from_config(iredis_client, clean_redis): + config_content = dedent( + """ + [main] + prompt = {host}abc{port}xx{db} + """ + ) + with open("/tmp/iredisrc", "w+") as etc_config: + etc_config.write(config_content) + + cli = pexpect.spawn("iredis -n 15 --iredisrc /tmp/iredisrc", timeout=1) + cli.expect("iredis") + cli.expect("127.0.0.1abc6379xx15") + cli.close() + + +def test_prompt_cli_overwrite_config(iredis_client, clean_redis): + config_content = dedent( + """ + [main] + prompt = {host}abc{port}xx{db} + """ + ) + with open("/tmp/iredisrc", "w+") as etc_config: + etc_config.write(config_content) + + cli = pexpect.spawn( + "iredis -n 15 --iredisrc /tmp/iredisrc --prompt='{db}-12345'", timeout=1 + ) + cli.expect("iredis") + cli.expect("15-12345") + cli.close() diff --git a/tests/cli_tests/test_dsn.py b/tests/cli_tests/test_dsn.py new file mode 100644 index 0000000..8c9528d --- /dev/null +++ b/tests/cli_tests/test_dsn.py @@ -0,0 +1,53 @@ +import os + +import pexpect +from textwrap import dedent +import pytest + + +def test_using_dsn(): + config_content = dedent( + """ + [alias_dsn] + local = redis://localhost:6379/15 + """ + ) + with open("/tmp/iredisrc", "w+") as etc_config: + etc_config.write(config_content) + + cli = pexpect.spawn("iredis --iredisrc /tmp/iredisrc --dsn local", timeout=1) + cli.logfile_read = open("cli_test.log", "ab") + cli.expect(["iredis", "localhost:6379[15]>"]) + cli.close() + + # overwrite with -n + cli = pexpect.spawn("iredis --iredisrc /tmp/iredisrc --dsn local -n 3", timeout=1) + cli.logfile_read = open("cli_test.log", "ab") + cli.expect(["iredis", "localhost:6379[3]>"]) + cli.close() + + # dsn not exists + cli = pexpect.spawn("iredis --iredisrc /tmp/iredisrc --dsn ghost-dsn", timeout=1) + cli.expect(["Could not find the specified DSN in the config file."]) + cli.close() + assert cli.status == 1 + + +@pytest.mark.skipif( + not os.path.exists("/tmp/redis/redis.sock"), reason="unix socket is not found" +) +def test_using_dsn_unix(): + config_content = dedent( + """ + [alias_dsn] + unix = unix:///tmp/redis/redis.sock?db=3 + """ + ) + with open("/tmp/iredisrc", "w+") as etc_config: + etc_config.write(config_content) + + cli = pexpect.spawn("iredis --iredisrc /tmp/iredisrc --dsn unix", timeout=2) + cli.logfile_read = open("cli_test.log", "ab") + cli.expect(["iredis", "redis /tmp/redis/redis.sock[3]>"]) + + cli.close() diff --git a/tests/cli_tests/test_history.py b/tests/cli_tests/test_history.py new file mode 100644 index 0000000..09e6c82 --- /dev/null +++ b/tests/cli_tests/test_history.py @@ -0,0 +1,42 @@ +import os +import pexpect +from pathlib import Path +from textwrap import dedent + + +def test_history_not_log_auth(cli): + cli.sendline("AUTH 123") + cli.expect(["Client sent AUTH, but no password is set", "127.0.0.1"]) + cli.sendline("set foo bar") + cli.expect("OK") + + with open(os.path.expanduser("~/.iredis_history"), "r") as history_file: + content = history_file.read() + + assert "set foo bar" in content + assert "AUTH" not in content + + +def test_history_create_and_writing_with_config(): + config_content = dedent( + """ + [main] + history_location = /tmp/iredis_history.txt + """ + ) + with open("/tmp/iredisrc", "w+") as etc_config: + etc_config.write(config_content) + + cli = pexpect.spawn("iredis -n 15 --iredisrc /tmp/iredisrc", timeout=2) + cli.expect("127.0.0.1") + cli.sendline("set hello world") + cli.expect("OK") + cli.close() + + log = Path("/tmp/iredis_history.txt") + assert log.exists() + + with open(log, "r") as logfile: + content = logfile.read() + + assert "set hello world" in content diff --git a/tests/cli_tests/test_on_error.py b/tests/cli_tests/test_on_error.py new file mode 100644 index 0000000..9ab8927 --- /dev/null +++ b/tests/cli_tests/test_on_error.py @@ -0,0 +1,12 @@ +def test_wrong_stream_type(clean_redis, cli): + clean_redis.lpush("mylist", "foo") + cli.sendline("xrange mylist 0 -1") + cli.expect("error") + cli.expect("Invalid stream ID specified as stream command argument") + + +def test_wrong_stream_type_in_raw_mode(clean_redis, raw_cli): + clean_redis.lpush("mylist", "foo") + raw_cli.sendline("xrange mylist 0 -1") + raw_cli.expect("ERROR") + raw_cli.expect("Invalid stream ID specified as stream command argument") diff --git a/tests/cli_tests/test_pager.py b/tests/cli_tests/test_pager.py new file mode 100644 index 0000000..38ced31 --- /dev/null +++ b/tests/cli_tests/test_pager.py @@ -0,0 +1,117 @@ +# noqa: F541 +import os +import sys +import pexpect +import pathlib +from contextlib import contextmanager +from textwrap import dedent + + +TEST_IREDISRC = "/tmp/.iredisrc.test" +TEST_PAGER_BOUNDARY = "---boundary---" +TEST_PAGER_BOUNDARY_NUMBER = "---88938347271---" + +env_pager = "{0} {1} {2}".format( + sys.executable, + os.path.join(pathlib.Path(__file__).parent, "wrappager.py"), + TEST_PAGER_BOUNDARY, +) +env_pager_numbers = "{0} {1} {2}".format( + sys.executable, + os.path.join(pathlib.Path(__file__).parent, "wrappager.py"), + TEST_PAGER_BOUNDARY_NUMBER, +) + + +@contextmanager +def pager_enabled_cli(): + env = os.environ + env["PAGER"] = env_pager + child = pexpect.spawn("iredis -n 15", timeout=3, env=env) + child.logfile_read = open("cli_test.log", "ab") + child.expect("127.0.0.1") + try: + yield child + finally: + child.close() + + +def test_using_pager_when_rows_too_high(clean_redis): + for index in range(100): + clean_redis.lpush("long-list", f"value-{index}") + with pager_enabled_cli() as child: + child.sendline("lrange long-list 0 -1") + child.expect(TEST_PAGER_BOUNDARY) + child.expect("value-1") + child.expect(TEST_PAGER_BOUNDARY) + + +def test_using_pager_works_for_help(): + with pager_enabled_cli() as child: + child.sendline("help set") + child.expect(TEST_PAGER_BOUNDARY) + child.expect("Set the string value of a key") + child.expect(TEST_PAGER_BOUNDARY) + + +def test_pager_works_for_peek(clean_redis): + for index in range(100): + clean_redis.lpush("long-list", f"value-{index}") + with pager_enabled_cli() as child: + child.sendline("peek long-list") + child.expect(TEST_PAGER_BOUNDARY) + child.expect("(quicklist)") + child.expect("value-1") + child.expect(TEST_PAGER_BOUNDARY) + + +def test_using_pager_from_config(clean_redis): + config_content = dedent( + f""" + [main] + log_location = /tmp/iredis1.log + pager = {env_pager_numbers} + """ + ) + + with open(TEST_IREDISRC, "w+") as test_iredisrc: + test_iredisrc.write(config_content) + + child = pexpect.spawn(f"iredis -n 15 --iredisrc {TEST_IREDISRC}", timeout=3) + child.logfile_read = open("cli_test.log", "ab") + child.expect("127.0.0.1") + for index in range(100): + clean_redis.lpush("long-list", f"value-{index}") + child.sendline("lrange long-list 0 -1") + child.expect(TEST_PAGER_BOUNDARY_NUMBER) + child.expect("value-1") + child.expect(TEST_PAGER_BOUNDARY_NUMBER) + child.close() + + +def test_using_pager_from_config_when_env_config_both_set(clean_redis): + config_content = dedent( + f""" + [main] + log_location = /tmp/iredis1.log + pager = {env_pager_numbers} + """ + ) + + with open(TEST_IREDISRC, "w+") as test_iredisrc: + test_iredisrc.write(config_content) + + env = os.environ + env["PAGER"] = env_pager + child = pexpect.spawn( + f"iredis -n 15 --iredisrc {TEST_IREDISRC}", timeout=3, env=env + ) + child.logfile_read = open("cli_test.log", "ab") + child.expect("127.0.0.1") + for index in range(100): + clean_redis.lpush("long-list", f"value-{index}") + child.sendline("lrange long-list 0 -1") + child.expect(TEST_PAGER_BOUNDARY_NUMBER) + child.expect("value-1") + child.expect(TEST_PAGER_BOUNDARY_NUMBER) + child.close() diff --git a/tests/cli_tests/test_self_implemented_command.py b/tests/cli_tests/test_self_implemented_command.py new file mode 100644 index 0000000..328d56b --- /dev/null +++ b/tests/cli_tests/test_self_implemented_command.py @@ -0,0 +1,14 @@ +""" +check ascii table: +http://ascii-table.com/ansi-escape-sequences.php +""" + + +def test_clear(cli): + cli.sendline("clear") + cli.expect("\\[2J") # clear screen + + +def test_exirt(cli): + cli.sendline("EXIT") + cli.expect("Goodbye!") diff --git a/tests/cli_tests/test_shell_pipeline.py b/tests/cli_tests/test_shell_pipeline.py new file mode 100644 index 0000000..8fe5e14 --- /dev/null +++ b/tests/cli_tests/test_shell_pipeline.py @@ -0,0 +1,21 @@ +import pexpect + + +def test_running_disable_shell_pipeline(): + cli = pexpect.spawn("iredis -n 15 --no-shell", timeout=2) + cli.expect("127.0.0.1") + cli.sendline("set foo hello") + cli.expect("OK") + cli.sendline("get foo | grep w") + cli.expect(r"hello") + cli.close() + + +def test_running_disable_shell_pipeline_with_decode_option(): + cli = pexpect.spawn("iredis -n 15 --decode=utf-8", timeout=2) + cli.expect("127.0.0.1") + cli.sendline("set foo hello") + cli.expect("OK") + cli.sendline("get foo | cat") + cli.expect(r"hello") + cli.close() diff --git a/tests/cli_tests/test_string_execute.py b/tests/cli_tests/test_string_execute.py new file mode 100644 index 0000000..310adab --- /dev/null +++ b/tests/cli_tests/test_string_execute.py @@ -0,0 +1,39 @@ +def test_set(cli): + cli.sendline("set foo bar") + cli.expect(["OK", "127.0.0.1"]) + + cli.sendline("set foo bar nx") + cli.expect(["(nil)", "127.0.0.1"]) + + cli.sendline("set foo bar xx") + cli.expect(["OK", "127.0.0.1"]) + + cli.sendline("set foo1 bar xx") + cli.expect(["(nil)", "127.0.0.1"]) + + +def test_get(cli): + cli.sendline("set foo bar") + cli.expect("OK") + + cli.sendline("get foo") + cli.expect('"bar"') + + +def test_delete_string(clean_redis, cli, config): + config.warning = True + cli.sendline("set foo bar") + cli.expect("OK") + cli.sendline("del foo") + cli.expect("Do you want to proceed") + cli.sendline("yes") + cli.expect("1") + + cli.sendline("get foo") + cli.expect("(nil)") + + +def test_on_dangerous_commands(cli, config): + config.warning = True + cli.sendline("keys *") + cli.expect("KEYS will hang redis server, use SCAN instead") diff --git a/tests/cli_tests/test_transaction.py b/tests/cli_tests/test_transaction.py new file mode 100644 index 0000000..b5c6b4e --- /dev/null +++ b/tests/cli_tests/test_transaction.py @@ -0,0 +1,70 @@ +import pytest +import pexpect + + +def test_trasaction_rprompt(clean_redis, cli): + cli.sendline("multi") + cli.expect(["OK", "transaction", "127.0.0.1"]) + + cli.sendline("get foo") + cli.expect(["QUEUED", "127.0.0.1", "transaction"]) + + cli.sendline("set hello world") + cli.expect(["QUEUED", "127.0.0.1", "transaction"]) + + cli.sendline("ping") + cli.expect(["QUEUED", "127.0.0.1", "transaction"]) + + cli.sendline("EXEC") + cli.expect("(nil)") + cli.expect("OK") + cli.expect("PONG") + cli.expect("127.0.0.1") + + with pytest.raises(pexpect.exceptions.TIMEOUT): + cli.expect("transaction") + + +def test_trasaction_syntax_error(cli): + cli.sendline("multi") + cli.sendline("get foo 1") + cli.expect(["wrong number of arguments for 'get' command", "transaction"]) + + cli.sendline("EXEC") + cli.expect("Transaction discarded because of previous errors.") + with pytest.raises(pexpect.exceptions.TIMEOUT): + cli.expect("transaction") + + +def test_trasaction_in_raw_mode(clean_redis, raw_cli): + clean_redis.set("foo", "bar") + + raw_cli.sendline("multi") + raw_cli.expect(["OK", "transaction", "127.0.0.1"]) + + raw_cli.sendline("get foo") + raw_cli.expect(["QUEUED", "127.0.0.1", "transaction"]) + + raw_cli.sendline("EXEC") + raw_cli.expect("bar") + raw_cli.expect("127.0.0.1") + + with pytest.raises(pexpect.exceptions.TIMEOUT): + raw_cli.expect("transaction") + + +def test_exec_return_nil_when_using_watch(clean_redis, cli): + cli.sendline("watch foo") + cli.expect("OK") + + cli.sendline("multi") + cli.expect("OK") + + cli.sendline("get bar") + cli.expect("QUEUED") + + # transaction will fail, return nil + clean_redis.set("foo", "hello!") + + cli.sendline("exec") + cli.expect("(nil)") diff --git a/tests/cli_tests/test_warning.py b/tests/cli_tests/test_warning.py new file mode 100644 index 0000000..402c51b --- /dev/null +++ b/tests/cli_tests/test_warning.py @@ -0,0 +1,51 @@ +from iredis.warning import is_dangerous + + +def test_is_dangerous(): + assert is_dangerous("KEYS") == ( + True, + "KEYS will hang redis server, use SCAN instead", + ) + + +def test_warning_for_dangerous_command(cli): + cli.sendline("config set save '900 1'") + cli.expect("Do you want to proceed?") + cli.sendline("yes") + + cli.sendline("config get save") + cli.expect("900 1") + + +def test_warnings_in_raw_mode(clean_redis, raw_cli): + clean_redis.set("foo", "bar") + raw_cli.sendline("keys *") + raw_cli.expect("Do you want to proceed?") + raw_cli.sendline("y") + raw_cli.expect("foo") + + +def test_warnings_in_raw_mode_canceled(clean_redis, raw_cli): + clean_redis.set("foo", "bar") + raw_cli.sendline("keys *") + raw_cli.expect("Do you want to proceed?") + raw_cli.sendline("n") + # the f should never appeared + raw_cli.expect("Canceled![^f]+127.0.0.1") + + +def test_warnings_confirmed(clean_redis, cli): + clean_redis.set("foo", "bar") + cli.sendline("keys *") + cli.expect("Do you want to proceed?") + cli.sendline("y") + cli.expect("foo") + + +def test_warnings_canceled(clean_redis, cli): + clean_redis.set("foo", "bar") + cli.sendline("keys *") + cli.expect("Do you want to proceed?") + cli.sendline("n") + # the f should never appeared + cli.expect("Canceled![^f]+127.0.0.1") diff --git a/tests/cli_tests/wrappager.py b/tests/cli_tests/wrappager.py new file mode 100644 index 0000000..dce86ce --- /dev/null +++ b/tests/cli_tests/wrappager.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +import sys +import fileinput + + +def wrappager(boundary): + print(boundary) + for line in fileinput.input(files="-"): + sys.stdout.write(line) + print(boundary) + + +if __name__ == "__main__": + wrappager(sys.argv[1]) diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..b70bf95 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,154 @@ +import os +import re +import tempfile +from textwrap import dedent + +import pexpect +import pytest +import redis + +from iredis.client import Client +from iredis.commands import split_command_args +from iredis.redis_grammar import get_command_grammar +from iredis.exceptions import InvalidArguments +from iredis.config import Config, config as global_config + + +TIMEOUT = 2 +HISTORY_FILE = ".iredis_history" + + +@pytest.fixture +def token_should_match(): + def match_func(token, tomatch): + assert re.fullmatch(token, tomatch) is not None + + return match_func + + +@pytest.fixture +def token_should_not_match(): + def match_func(token, tomatch): + assert re.fullmatch(token, tomatch) is None + + return match_func + + +@pytest.fixture +def judge_command(): + def judge_command_func(input_text, expect): + if expect == "invalid": + with pytest.raises(InvalidArguments): + split_command_args(input_text) + return + + command, _ = split_command_args(input_text) + grammar = get_command_grammar(command) + + m = grammar.match(input_text) + + # test on not match + if not expect: + assert m is None + return + + variables = m.variables() + print("Found variables: {}".format(variables)) + for expect_token, expect_value in expect.items(): + all_variables = variables.getall(expect_token) + if len(all_variables) > 1: + assert sorted(all_variables) == sorted(expect_value) + else: + assert variables.get(expect_token) == expect_value + + return judge_command_func + + +@pytest.fixture(scope="function") +def clean_redis(): + """ + Return a empty redis db. (redis-py client) + """ + client = redis.StrictRedis(db=15) + client.flushdb() + return client + + +@pytest.fixture +def iredis_client(): + return Client("127.0.0.1", "6379", db=15) + + +@pytest.fixture +def config(): + newconfig = Config() + global_config.__dict__ = newconfig.__dict__ + config.raw = False + return global_config + + +@pytest.fixture(scope="function") +def cli(): + """Open iredis subprocess to test""" + f = tempfile.TemporaryFile("w") + config_content = dedent( + """ + [main] + log_location = + warning = True + """ + ) + f.write(config_content) + f.close() + env = os.environ + env["PROMPT_TOOLKIT_NO_CPR"] = "1" + + child = pexpect.spawn(f"iredis -n 15 --iredisrc {f.name}", timeout=TIMEOUT, env=env) + child.logfile_read = open("cli_test.log", "ab") + child.expect(["https://iredis.io/issues", "127.0.0.1"]) + yield child + child.close() + + +@pytest.fixture(scope="function") +def raw_cli(): + """Open iredis subprocess to test""" + TEST_IREDISRC = "/tmp/.iredisrc.test" + config_content = dedent( + """ + [main] + log_location = + warning = True + """ + ) + + with open(TEST_IREDISRC, "w+") as test_iredisrc: + test_iredisrc.write(config_content) + + child = pexpect.spawn( + f"iredis --raw -n 15 --iredisrc {TEST_IREDISRC}", timeout=TIMEOUT + ) + child.logfile_read = open("cli_test.log", "ab") + child.expect(["https://iredis.io/issues", "127.0.0.1"]) + yield child + child.close() + + +@pytest.fixture(scope="function") +def cli_without_warning(): + f = tempfile.TemporaryFile("w") + config_content = dedent( + """ + [main] + log_location = /tmp/iredis1.log + warning = False + """ + ) + f.write(config_content) + f.close() + + cli = pexpect.spawn(f"iredis -n 15 --iredisrc {f.name}", timeout=1) + cli.logfile_read = open("cli_test.log", "ab") + yield cli + cli.close() + os.remove("/tmp/iredisrc") diff --git a/tests/helpers.py b/tests/helpers.py new file mode 100644 index 0000000..8cf2069 --- /dev/null +++ b/tests/helpers.py @@ -0,0 +1,11 @@ +import re + + +def formatted_text_rematch(value_to_test, expected_formatted_text): + """ + ``expected_formatted_text`` can be regex. + """ + for value, expected in zip(value_to_test, expected_formatted_text): + assert value[0] == expected[0] + print(expected[1], value[1]) + assert re.match(expected[1], value[1]) diff --git a/tests/unittests/__init__.py b/tests/unittests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/unittests/__init__.py diff --git a/tests/unittests/command_parse/test_base_token.py b/tests/unittests/command_parse/test_base_token.py new file mode 100644 index 0000000..545bc92 --- /dev/null +++ b/tests/unittests/command_parse/test_base_token.py @@ -0,0 +1,80 @@ +def test_ip_match(judge_command): + def ip_valid(ip, valid): + if valid: + judge_command( + f"cluster meet {ip} 6379", + {"command": "cluster meet", "ip": ip, "port": "6379"}, + ) + else: + judge_command(f"cluster meet {ip} 6379", None) + + ip_valid("192.168.0.1", True) + ip_valid("255.255.255.255", True) + ip_valid("192.168.0.256", False) + ip_valid("192.256.0.26", False) + ip_valid("192.255.256.26", False) + ip_valid("0.0.0.0", True) + ip_valid("99.999.100.1", False) + ip_valid("300.168.0.1", False) + + +def test_port_match(judge_command): + def port_valid(port, valid): + if valid: + judge_command( + f"cluster meet 192.168.0.1 {port}", + {"command": "cluster meet", "ip": "192.168.0.1", "port": port}, + ) + else: + judge_command(f"cluster meet 192.168.0.1 {port}", None) + + port_valid("65535", True) + port_valid("0", False) + port_valid("1", True) + port_valid("192.168.0.256", False) + port_valid("65536", False) + port_valid("65545", False) + port_valid("65635", False) + port_valid("66535", False) + port_valid("75535", False) + port_valid("1024", True) + port_valid("6553", True) + port_valid("99999", False) + port_valid("99999999", False) + + +def test_command_with_key_in_quotes(judge_command): + judge_command( + 'cluster keyslot "mykey"', {"command": "cluster keyslot", "key": '"mykey"'} + ) + judge_command( + 'cluster keyslot "\\"mykey"', + {"command": "cluster keyslot", "key": '"\\"mykey"'}, + ) + judge_command( + 'cluster keyslot "mykey "', {"command": "cluster keyslot", "key": '"mykey "'} + ) + + +def test_timeout(token_should_match, token_should_not_match): + from iredis.redis_grammar import TIMEOUT + + token_should_match(TIMEOUT, "1.1") + token_should_match(TIMEOUT, "1.0") + token_should_match(TIMEOUT, ".1") + token_should_match(TIMEOUT, "123123.1123") + token_should_not_match(TIMEOUT, "1.") + token_should_not_match(TIMEOUT, ".") + token_should_not_match(TIMEOUT, ".a") + + +def test_lr_const(token_should_match, token_should_not_match): + from iredis.redis_grammar import LR_CONST + + token_should_match(LR_CONST, "left") + token_should_match(LR_CONST, "right") + token_should_match(LR_CONST, "LEFT") + token_should_match(LR_CONST, "RIGHT") + token_should_not_match(LR_CONST, "righ") + token_should_not_match(LR_CONST, "ab") + token_should_not_match(LR_CONST, "123") diff --git a/tests/unittests/command_parse/test_cluster.py b/tests/unittests/command_parse/test_cluster.py new file mode 100644 index 0000000..6dd877f --- /dev/null +++ b/tests/unittests/command_parse/test_cluster.py @@ -0,0 +1,255 @@ +""" +redis command in `cluster` group parse test. +""" + + +def test_command_cluster_addslots(judge_command): + judge_command("cluster addslots 1", {"command": "cluster addslots", "slots": "1"}) + judge_command("CLUSTER ADDSLOTS 1", {"command": "CLUSTER ADDSLOTS", "slots": "1"}) + judge_command( + "cluster addslots 1 2 3 4", {"command": "cluster addslots", "slots": "1 2 3 4"} + ) + judge_command("cluster addslots 1 a", None) + judge_command("cluster addslots a", None) + judge_command("cluster addslots a 4", None) + judge_command("cluster addslots abc", None) + + +def test_command_cluster_count_failure_reports(judge_command): + judge_command( + "cluster count-failure-reports 1", + {"command": "cluster count-failure-reports", "node": "1"}, + ) + judge_command( + "CLUSTER COUNT-FAILURE-REPORTS 1", + {"command": "CLUSTER COUNT-FAILURE-REPORTS", "node": "1"}, + ) + judge_command("cluster count-failure-reports 1 2 3 4", None) + judge_command("cluster count-failure-reports 1 a", None) + judge_command( + "cluster count-failure-reports a", + {"command": "cluster count-failure-reports", "node": "a"}, + ) + judge_command("cluster count-failure-reports a 2", None) + judge_command( + "cluster count-failure-reports abc", + {"command": "cluster count-failure-reports", "node": "abc"}, + ) + + +def test_command_cluster_countkeysinslot(judge_command): + judge_command( + "cluster countkeysinslot 1", {"command": "cluster countkeysinslot", "slot": "1"} + ) + judge_command( + "CLUSTER COUNTKEYSINSLOT 1", {"command": "CLUSTER COUNTKEYSINSLOT", "slot": "1"} + ) + judge_command("cluster countkeysinslot 1 2 3 4", None) + judge_command("cluster countkeysinslot 1 a", None) + judge_command("cluster countkeysinslot a", None) + judge_command("cluster countkeysinslot a 4", None) + judge_command("cluster countkeysinslot abc", None) + + +def test_command_cluster_delslots(judge_command): + judge_command("cluster delslots 1", {"command": "cluster delslots", "slots": "1"}) + judge_command("CLUSTER DELSLOTS 1", {"command": "CLUSTER DELSLOTS", "slots": "1"}) + judge_command( + "cluster delslots 1 2 3 4", {"command": "cluster delslots", "slots": "1 2 3 4"} + ) + judge_command("cluster delslots 1 a", None) + judge_command("cluster delslots a", None) + judge_command("cluster delslots a 4", None) + judge_command("cluster delslots abc", None) + + +def test_command_cluster_failover(judge_command): + judge_command( + "cluster failover force", + {"command": "cluster failover", "failoverchoice": "force"}, + ) + judge_command( + "cluster failover takeover", + {"command": "cluster failover", "failoverchoice": "takeover"}, + ) + judge_command( + "CLUSTER FAILOVER FORCE", + {"command": "CLUSTER FAILOVER", "failoverchoice": "FORCE"}, + ) + judge_command( + "CLUSTER FAILOVER takeover", + {"command": "CLUSTER FAILOVER", "failoverchoice": "takeover"}, + ) + judge_command( + "CLUSTER FAILOVER TAKEOVER", + {"command": "CLUSTER FAILOVER", "failoverchoice": "TAKEOVER"}, + ) + + +def test_command_cluster_forget(judge_command): + judge_command("cluster forget 1", {"command": "cluster forget", "node": "1"}) + judge_command( + "CLUSTER COUNT-FAILURE-REPORTS 1", + {"command": "CLUSTER COUNT-FAILURE-REPORTS", "node": "1"}, + ) + judge_command("cluster forget 1 2 3 4", None) + judge_command("cluster forget 1 a", None) + judge_command("cluster forget a", {"command": "cluster forget", "node": "a"}) + judge_command("cluster forget a 2", None) + judge_command( + "cluster forget abc", + { + "command": "cluster forget", + "node": "abc", + }, + ) + judge_command( + "cluster forget 07c37dfeb235213a872192d90877d0cd55635b91", + { + "command": "cluster forget", + "node": "07c37dfeb235213a872192d90877d0cd55635b91", + }, + ) + + +def test_command_cluster_getkeysinslot(judge_command): + judge_command( + "cluster getkeysinslot 1 1", + {"command": "cluster getkeysinslot", "slot": "1", "count": "1"}, + ) + judge_command( + "CLUSTER GETKEYSINSLOT 1 1", + {"command": "CLUSTER GETKEYSINSLOT", "slot": "1", "count": "1"}, + ) + judge_command( + "cluster getkeysinslot 1123 1121", + {"command": "cluster getkeysinslot", "slot": "1123", "count": "1121"}, + ) + judge_command("cluster getkeysinslot 1 2 3 4", None) + judge_command("cluster getkeysinslot 1 a", None) + judge_command("cluster getkeysinslot a", None) + judge_command("cluster getkeysinslot a 4", None) + judge_command("cluster getkeysinslot abc", None) + + +def test_command_cluster_info(judge_command): + judge_command("cluster info", {"command": "cluster info"}) + judge_command("CLUSTER INFO", {"command": "CLUSTER INFO"}) + judge_command("CLUSTER INFO 1", None) + judge_command("Acluster info", "invalid") + + +def test_command_cluster_keyslot(judge_command): + judge_command( + "cluster keyslot mykey", {"command": "cluster keyslot", "key": "mykey"} + ) + judge_command( + "cluster keyslot MYKEY", {"command": "cluster keyslot", "key": "MYKEY"} + ) + judge_command( + "CLUSTER KEYSLOT MYKEY", {"command": "CLUSTER KEYSLOT", "key": "MYKEY"} + ) + + +def test_command_cluster_meet(judge_command): + judge_command( + "cluster meet 192.168.0.1 12200", + {"command": "cluster meet", "ip": "192.168.0.1", "port": "12200"}, + ) + judge_command( + "CLUSTER MEET 192.168.0.1 12200", + {"command": "CLUSTER MEET", "ip": "192.168.0.1", "port": "12200"}, + ) + + +def test_command_cluster_nodes(judge_command): + judge_command("cluster nodes", {"command": "cluster nodes"}) + judge_command("CLUSTER NODES", {"command": "CLUSTER NODES"}) + + +def test_command_cluster_reset(judge_command): + judge_command( + "cluster reset hard", {"command": "cluster reset", "resetchoice": "hard"} + ) + judge_command( + "cluster reset soft", {"command": "cluster reset", "resetchoice": "soft"} + ) + judge_command( + "CLUSTER RESET HARD", {"command": "CLUSTER RESET", "resetchoice": "HARD"} + ) + judge_command( + "CLUSTER RESET soft", {"command": "CLUSTER RESET", "resetchoice": "soft"} + ) + judge_command( + "CLUSTER RESET SOFT", {"command": "CLUSTER RESET", "resetchoice": "SOFT"} + ) + judge_command("CLUSTER RESET SOFT1", None) + judge_command("CLUSTER RESET SAOFT", None) + + +def test_command_cluster_set_config_epoch(judge_command): + judge_command("cluster set-config-epoch 123123 ad", None) + judge_command( + "cluster set-config-epoch 0 ", + {"command": "cluster set-config-epoch", "epoch": "0"}, + ) + judge_command( + "cluster set-config-epoch 123123 ", + {"command": "cluster set-config-epoch", "epoch": "123123"}, + ) + + +def test_command_cluster_set_slot(judge_command): + judge_command( + "cluster setslot 123 importing 123123", + { + "command": "cluster setslot", + "slot": "123", + "slotsubcmd": "importing", + "node": "123123", + }, + ) + judge_command( + "cluster setslot 123 migrating 123123", + { + "command": "cluster setslot", + "slot": "123", + "slotsubcmd": "migrating", + "node": "123123", + }, + ) + judge_command( + "cluster setslot 123 node 123123", + { + "command": "cluster setslot", + "slot": "123", + "slotsubcmd": "node", + "node": "123123", + }, + ) + judge_command( + "cluster setslot 123 node e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca", + { + "command": "cluster setslot", + "slot": "123", + "slotsubcmd": "node", + "node": "e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca", + }, + ) + judge_command( + "cluster setslot 123 MIGRATING 123123", + { + "command": "cluster setslot", + "slot": "123", + "slotsubcmd": "MIGRATING", + "node": "123123", + }, + ) + judge_command( + "cluster setslot 123 stable", + {"command": "cluster setslot", "slot": "123", "slotsubcmd": "stable"}, + ) + judge_command( + "cluster setslot 123 STABLE", + {"command": "cluster setslot", "slot": "123", "slotsubcmd": "STABLE"}, + ) diff --git a/tests/unittests/command_parse/test_connection.py b/tests/unittests/command_parse/test_connection.py new file mode 100644 index 0000000..2a1de26 --- /dev/null +++ b/tests/unittests/command_parse/test_connection.py @@ -0,0 +1,116 @@ +def test_auth(judge_command): + judge_command("auth 123", {"command": "auth", "password": "123"}) + + +def test_auth_redis6(judge_command): + from iredis.commands import command2syntax + from iredis.redis_grammar import get_command_grammar + + get_command_grammar.cache_clear() + + old = command2syntax["AUTH"] + command2syntax["AUTH"] = "command_usernamex_password" + judge_command( + "auth default 123", + {"command": "auth", "password": "123", "username": "default"}, + ) + judge_command("AUTH 123", {"command": "AUTH", "password": "123"}) + command2syntax["AUTH"] = old + + +def test_echo(judge_command): + judge_command("echo hello", {"command": "echo", "message": "hello"}) + + +def test_ping(judge_command): + judge_command("ping hello", {"command": "ping", "message": "hello"}) + judge_command("ping", {"command": "ping", "message": None}) + judge_command("ping hello world", None) + + +def test_select(judge_command): + for index in range(16): + judge_command(f"select {index}", {"command": "select", "index": str(index)}) + for index in range(16, 100): + judge_command(f"select {index}", None) + judge_command("select acb", None) + + +def test_swapdb(judge_command): + for index1 in range(16): + for index2 in range(16): + judge_command( + f"swapdb {index1} {index2}", + {"command": "swapdb", "index": [str(index1), str(index2)]}, + ) + judge_command("swapdb abc 1", None) + judge_command("swapdb 1", None) + + +def test_client_caching(judge_command): + judge_command("CLIENT CACHING YES", {"command": "CLIENT CACHING", "yes": "YES"}) + judge_command("CLIENT CACHING NO", {"command": "CLIENT CACHING", "yes": "NO"}) + judge_command("CLIENT CACHING", None) + judge_command("CLIENT CACHING abc", None) + + +def test_client_tracking(judge_command): + judge_command("CLIENT TRACKING on", {"command": "CLIENT TRACKING", "on_off": "on"}) + judge_command( + "CLIENT TRACKING ON REDIRECT 123", + { + "command": "CLIENT TRACKING", + "on_off": "ON", + "redirect_const": "REDIRECT", + "clientid": "123", + }, + ) + judge_command( + "CLIENT TRACKING ON PREFIX foo", + { + "command": "CLIENT TRACKING", + "on_off": "ON", + "prefix_const": "PREFIX", + "prefixes": "foo", + }, + ) + judge_command( + "CLIENT TRACKING ON PREFIX foo", + { + "command": "CLIENT TRACKING", + "on_off": "ON", + "prefix_const": "PREFIX", + "prefixes": "foo", + }, + ) + judge_command( + "CLIENT TRACKING ON PREFIX foo BCAST NOLOOP OPTIN", + { + "command": "CLIENT TRACKING", + "on_off": "ON", + "prefix_const": "PREFIX", + "prefixes": "foo", + "bcast_const": "BCAST", + "noloop_const": "NOLOOP", + "optin_const": "OPTIN", + }, + ) + judge_command( + "CLIENT TRACKING ON PREFIX foo bar ok BCAST NOLOOP OPTIN", + { + "command": "CLIENT TRACKING", + "on_off": "ON", + "prefix_const": "PREFIX", + "prefixes": "foo bar ok", + "bcast_const": "BCAST", + "noloop_const": "NOLOOP", + "optin_const": "OPTIN", + }, + ) + + +def test_client_pause(judge_command): + judge_command( + "CLIENT PAUSE 20 WRITE", + {"command": "CLIENT PAUSE", "timeout": "20", "pause_type": "WRITE"}, + ) diff --git a/tests/unittests/command_parse/test_generic_parse.py b/tests/unittests/command_parse/test_generic_parse.py new file mode 100644 index 0000000..6c4b0f3 --- /dev/null +++ b/tests/unittests/command_parse/test_generic_parse.py @@ -0,0 +1,218 @@ +def test_del(judge_command): + judge_command("DEL abc", {"command": "DEL", "keys": "abc"}) + judge_command("DEL bc1", {"command": "DEL", "keys": "bc1"}) + judge_command("DEL 1", {"command": "DEL", "keys": "1"}) + judge_command('DEL "hello world"', {"command": "DEL", "keys": '"hello world"'}) + judge_command( + r'DEL "hell\"o world"', {"command": "DEL", "keys": r'"hell\"o world"'} + ) + judge_command("DEL abc def", {"command": "DEL", "keys": "abc def"}) + judge_command("DEL 1 2", {"command": "DEL", "keys": "1 2"}) + judge_command("DEL 'he \"llo'", {"command": "DEL", "keys": "'he \"llo'"}) + judge_command( + """DEL 'he "llo' "abc" 'def' """, + {"command": "DEL", "keys": "'he \"llo' \"abc\" 'def'"}, + ) + + +def test_exists(judge_command): + judge_command("EXISTS foo bar", {"command": "EXISTS", "keys": "foo bar"}) + judge_command("EXISTS foo", {"command": "EXISTS", "keys": "foo"}) + judge_command("EXISTS 1", {"command": "EXISTS", "keys": "1"}) + judge_command('EXISTS "foo bar"', {"command": "EXISTS", "keys": '"foo bar"'}) + judge_command(r'EXISTS "\""', {"command": "EXISTS", "keys": r'"\""'}) + + +def test_expire(judge_command): + judge_command("EXPIRE key 12", {"command": "EXPIRE", "key": "key", "second": "12"}) + judge_command("EXPIRE key a12", None) + judge_command("EXPIRE 12 12", {"command": "EXPIRE", "key": "12", "second": "12"}) + judge_command("EXPIRE 12", None) + + +def test_expireat(judge_command): + judge_command( + "EXPIRE key 1565787643", + {"command": "EXPIRE", "key": "key", "second": "1565787643"}, + ) + judge_command("EXPIRE key a12", None) + + +def test_keys(judge_command): + judge_command("KEYS *", {"command": "KEYS", "pattern": "*"}) + judge_command("KEYS *abc", {"command": "KEYS", "pattern": "*abc"}) + judge_command("keys abc*", {"command": "keys", "pattern": "abc*"}) + + +def test_move(judge_command): + judge_command("MOVE key 14", {"command": "MOVE", "key": "key", "index": "14"}) + + +def test_pexpire(judge_command): + judge_command( + "PEXPIRE key 12", {"command": "PEXPIRE", "key": "key", "millisecond": "12"} + ) + judge_command("PEXPIRE key a12", None) + judge_command( + "PEXPIRE 12 12", {"command": "PEXPIRE", "key": "12", "millisecond": "12"} + ) + judge_command("PEXPIRE 12", None) + + +def test_pexpireat(judge_command): + judge_command( + "PEXPIREAT key 1565787643", + {"command": "PEXPIREAT", "key": "key", "timestampms": "1565787643"}, + ) + judge_command("PEXPIREAT key a12", None) + + +def test_rename(judge_command): + judge_command( + "rename key newkey", {"command": "rename", "key": "key", "newkey": "newkey"} + ) + judge_command( + "rename 123 newkey", {"command": "rename", "key": "123", "newkey": "newkey"} + ) + judge_command("rename 123 ", None) + + +def test_scan(judge_command): + judge_command( + "SCAN 0 MATCH task* COUNT 15 TYPE string", + { + "command": "SCAN", + "cursor": "0", + "match": "MATCH", + "pattern": "task*", + "count_const": "COUNT", + "count": "15", + "type_const": "TYPE", + "type": "string", + }, + ) + judge_command("SCAN 0", {"command": "SCAN", "cursor": "0"}) + judge_command( + "SCAN 0 MATCH task*", + {"command": "SCAN", "cursor": "0", "match": "MATCH", "pattern": "task*"}, + ) + judge_command( + "SCAN 0 COUNT 15 TYPE string", + { + "command": "SCAN", + "cursor": "0", + "count_const": "COUNT", + "count": "15", + "type_const": "TYPE", + "type": "string", + }, + ) + + +def test_migrate(judge_command): + judge_command( + 'MIGRATE 192.168.1.34 6379 " " 0 5000 KEYS key1 key2 key3', + { + "command": "MIGRATE", + "host": "192.168.1.34", + "port": "6379", + "key": '" "', + "index": "0", + "timeout": "5000", + "const_keys": "KEYS", + "keys": "key1 key2 key3", + }, + ) + judge_command( + "MIGRATE 192.168.1.34 6379 foo 0 5000 auth password1 KEYS key1 key2 key3", + { + "command": "MIGRATE", + "host": "192.168.1.34", + "port": "6379", + "key": "foo", + "index": "0", + "timeout": "5000", + "const_keys": "KEYS", + "keys": "key1 key2 key3", + "auth": "auth", + "password": "password1", + }, + ) + judge_command( + "MIGRATE 192.168.1.34 6379 foo 0 5000 auth username1 password1 KEYS key1 key2 key3", + { + "command": "MIGRATE", + "host": "192.168.1.34", + "port": "6379", + "key": "foo", + "index": "0", + "timeout": "5000", + "const_keys": "KEYS", + "keys": "key1 key2 key3", + "auth": "auth", + "password": "password1", + "username": "username1", + }, + ) + + +def test_object(judge_command): + judge_command( + "object refcount mylist", + {"command": "object", "object": "refcount", "key": "mylist"}, + ) + + +def test_wait(judge_command): + judge_command("WAIT 3 100", {"command": "WAIT", "count": "3", "timeout": "100"}) + + +def test_restore(judge_command): + judge_command( + 'RESTORE mykey 0 "\n\x17\x17\x00\x00\x00\x12\x00\x00\x00\x03\x00\x00\xc0\x01\x00\x04\xc0\x02\x00\x04\xc0\x03\x00\xff\x04\x00u#<\xc0;.\xe9\xdd"', # noqa + { + "command": "RESTORE", + "key": "mykey", + "timeout": "0", + "value": '"\n\x17\x17\x00\x00\x00\x12\x00\x00\x00\x03\x00\x00\xc0\x01\x00\x04\xc0\x02\x00\x04\xc0\x03\x00\xff\x04\x00u#<\xc0;.\xe9\xdd"', # noqa + }, + ) + + +def test_copy(judge_command): + judge_command( + "COPY foo bar DB 3 REPLACE", + { + "command": "COPY", + "key": ["foo", "bar"], + "db_const": "DB", + "index": "3", + "replace_const": "REPLACE", + }, + ) + judge_command( + "COPY foo bar REPLACE", + {"command": "COPY", "key": ["foo", "bar"], "replace_const": "REPLACE"}, + ) + judge_command("COPY foo bar", {"command": "COPY", "key": ["foo", "bar"]}) + + +def test_getex(judge_command): + judge_command("GETEX foo", {"command": "GETEX", "key": "foo"}) + judge_command( + "GETEX bar ex 5", + {"command": "GETEX", "key": "bar", "expiration": "ex", "millisecond": "5"}, + ) + judge_command( + "GETEX bar px 5", + {"command": "GETEX", "key": "bar", "expiration": "px", "millisecond": "5"}, + ) + judge_command( + "GETEX bar pxat 5", + {"command": "GETEX", "key": "bar", "pxat_const": "pxat", "timestampms": "5"}, + ) + judge_command( + "GETEX bar exat 5", + {"command": "GETEX", "key": "bar", "exat_const": "exat", "timestamp": "5"}, + ) + judge_command("GETEX bar ex 5 exat 5", None) diff --git a/tests/unittests/command_parse/test_geo.py b/tests/unittests/command_parse/test_geo.py new file mode 100644 index 0000000..8502696 --- /dev/null +++ b/tests/unittests/command_parse/test_geo.py @@ -0,0 +1,45 @@ +def test_geoadd(judge_command): + judge_command( + 'GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"', + { + "command": "GEOADD", + "key": "Sicily", + "longitude": "15.087269", + "latitude": "37.502669", + "member": '"Catania"', + }, + ) + judge_command( + 'GEOADD Sicily NX CH 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"', + { + "command": "GEOADD", + "condition": "NX", + "changed": "CH", + "key": "Sicily", + "longitude": "15.087269", + "latitude": "37.502669", + "member": '"Catania"', + }, + ) + + +def test_geosearch(judge_command): + judge_command( + "GEOSEARCH Sicily FROMLONLAT 15 37 BYBOX 400 400 km ASC WITHCOORD WITHDIST", + { + "command": "GEOSEARCH", + "key": "Sicily", + "any": "FROMLONLAT 15 37 BYBOX 400 400 km ASC WITHCOORD WITHDIST", + }, + ) + + +def test_geosearchstore(judge_command): + judge_command( + "GEOSEARCHSTORE key2 Sicily FROMLONLAT 15 37 BYBOX 400 400 km ASC COUNT 3 STOREDIST", + { + "command": "GEOSEARCHSTORE", + "key": ["Sicily", "key2"], + "any": "FROMLONLAT 15 37 BYBOX 400 400 km ASC COUNT 3 STOREDIST", + }, + ) diff --git a/tests/unittests/command_parse/test_hash_parse.py b/tests/unittests/command_parse/test_hash_parse.py new file mode 100644 index 0000000..2bde9e0 --- /dev/null +++ b/tests/unittests/command_parse/test_hash_parse.py @@ -0,0 +1,66 @@ +def test_hdel(judge_command): + judge_command("HDEL foo bar", {"command": "HDEL", "key": "foo", "fields": "bar"}) + judge_command( + "HDEL foo bar hello world", + {"command": "HDEL", "key": "foo", "fields": "bar hello world"}, + ) + + +def test_hmset(judge_command): + judge_command( + "HMSET foo bar hello-world", + {"command": "HMSET", "key": "foo", "field": "bar", "value": "hello-world"}, + ) + judge_command( + "HMSET foo bar hello-world key2 value2", + {"command": "HMSET", "key": "foo", "field": "key2", "value": "value2"}, + ) + + +def test_hexists(judge_command): + judge_command( + "HEXISTS foo bar", {"command": "HEXISTS", "key": "foo", "field": "bar"} + ) + judge_command("HEXISTS foo bar hello-world", None) + + +def test_hincrby(judge_command): + judge_command( + "HINCRBY foo bar 12", + {"command": "HINCRBY", "key": "foo", "field": "bar", "delta": "12"}, + ) + + +def test_hincrbyfloat(judge_command): + judge_command( + "HINCRBYFLOAT foo bar 12.1", + {"command": "HINCRBYFLOAT", "key": "foo", "field": "bar", "float": "12.1"}, + ) + + +def test_hset(judge_command): + judge_command( + "HSET foo bar hello", + {"command": "HSET", "key": "foo", "field": "bar", "value": "hello"}, + ) + + +def test_hrandfield(judge_command): + judge_command( + "HRANDFIELD coin", + {"command": "HRANDFIELD", "key": "coin"}, + ) + judge_command( + "HRANDFIELD coin -5 WITHVALUES", + { + "command": "HRANDFIELD", + "key": "coin", + "count": "-5", + "withvalues_const": "WITHVALUES", + }, + ) + judge_command( + "HRANDFIELD coin -5", + {"command": "HRANDFIELD", "key": "coin", "count": "-5"}, + ) + judge_command("HRANDFIELD coin WITHVALUES", None) diff --git a/tests/unittests/command_parse/test_hll_parse.py b/tests/unittests/command_parse/test_hll_parse.py new file mode 100644 index 0000000..b139eed --- /dev/null +++ b/tests/unittests/command_parse/test_hll_parse.py @@ -0,0 +1,5 @@ +def test_pfmerge(judge_command): + judge_command( + "PFMERGE hll3 hll1 hll2", + {"command": "PFMERGE", "newkey": "hll3", "keys": "hll1 hll2"}, + ) diff --git a/tests/unittests/command_parse/test_list_parse.py b/tests/unittests/command_parse/test_list_parse.py new file mode 100644 index 0000000..69a294e --- /dev/null +++ b/tests/unittests/command_parse/test_list_parse.py @@ -0,0 +1,143 @@ +def test_rpush(judge_command): + judge_command( + "RPUSH list1 foo bar hello world", + {"command": "RPUSH", "key": "list1", "values": "foo bar hello world"}, + ) + judge_command( + "LPUSH list1 foo", {"command": "LPUSH", "key": "list1", "values": "foo"} + ) + + +def test_lindex(judge_command): + judge_command( + "LINDEX list1 10", {"command": "LINDEX", "key": "list1", "position": "10"} + ) + judge_command( + "LINDEX list1 -10", {"command": "LINDEX", "key": "list1", "position": "-10"} + ) + judge_command("LINDEX list1 1.1", None) + + +def test_lset(judge_command): + judge_command( + "LSET list1 10 newbie", + {"command": "LSET", "key": "list1", "position": "10", "value": "newbie"}, + ) + judge_command( + "LSET list1 -1 newbie", + {"command": "LSET", "key": "list1", "position": "-1", "value": "newbie"}, + ) + + +def test_brpoplpush(judge_command): + judge_command( + "BRPOPLPUSH list1 list2 10", + {"command": "BRPOPLPUSH", "key": "list1", "newkey": "list2", "timeout": "10"}, + ) + judge_command( + "BRPOPLPUSH list1 list2 0", + {"command": "BRPOPLPUSH", "key": "list1", "newkey": "list2", "timeout": "0"}, + ) + judge_command("BRPOPLPUSH list1 list2 -1", None) + + +def test_brpoplpush_with_double_timeout(judge_command): + judge_command( + "BRPOPLPUSH list1 list2 10.0", + {"command": "BRPOPLPUSH", "key": "list1", "newkey": "list2", "timeout": "10.0"}, + ) + judge_command( + "BRPOPLPUSH list1 list2 .2", + {"command": "BRPOPLPUSH", "key": "list1", "newkey": "list2", "timeout": ".2"}, + ) + judge_command("BRPOPLPUSH list1 list2 12.", None) + + +def test_linsert(judge_command): + judge_command( + 'LINSERT mylist BEFORE "World" "There"', + { + "command": "LINSERT", + "key": "mylist", + "position_choice": "BEFORE", + "value": ['"World"', '"There"'], + }, + ) + judge_command( + 'LINSERT mylist after "World" "There"', + { + "command": "LINSERT", + "key": "mylist", + "position_choice": "after", + "value": ['"World"', '"There"'], + }, + ) + + +def test_lpos(judge_command): + judge_command("LPOS mylist c", {"command": "LPOS", "key": "mylist", "element": "c"}) + judge_command( + "LPOS mylist c RANK 2", + { + "command": "LPOS", + "key": "mylist", + "element": "c", + "rank_const": "RANK", + "rank": "2", + }, + ) + judge_command( + "LPOS mylist c RANK -1", + { + "command": "LPOS", + "key": "mylist", + "element": "c", + "rank_const": "RANK", + "rank": "-1", + }, + ) + judge_command( + "LPOS mylist c COUNT 2", + { + "command": "LPOS", + "key": "mylist", + "element": "c", + "count_const": "COUNT", + "count": "2", + }, + ) + judge_command( + "LPOS mylist c RANK -1 COUNT 2", + { + "command": "LPOS", + "key": "mylist", + "element": "c", + "count_const": "COUNT", + "count": "2", + "rank_const": "RANK", + "rank": "-1", + }, + ) + + +def test_blmove(judge_command): + judge_command( + "blmove list1 list2 left right 1.2", + { + "command": "blmove", + "key": ["list1", "list2"], + "lr_const": ["left", "right"], + "timeout": "1.2", + }, + ) + judge_command( + "blmove list1 list2 right right .2", + { + "command": "blmove", + "key": ["list1", "list2"], + "lr_const": ["right", "right"], + "timeout": ".2", + }, + ) + judge_command("blmove list1 list2 right right", None) + judge_command("blmove list1 right right 1", None) diff --git a/tests/unittests/command_parse/test_pubsub.py b/tests/unittests/command_parse/test_pubsub.py new file mode 100644 index 0000000..c7a2b54 --- /dev/null +++ b/tests/unittests/command_parse/test_pubsub.py @@ -0,0 +1,15 @@ +def test_publish(judge_command): + judge_command( + "publish foo bar", {"command": "publish", "channel": "foo", "message": "bar"} + ) + + +def test_subscribe(judge_command): + judge_command("subscribe foo bar", {"command": "subscribe", "channel": "bar"}) + + +def test_pubsub(judge_command): + judge_command( + "PUBSUB NUMSUB foo bar", + {"command": "PUBSUB", "pubsubcmd": "NUMSUB", "channel": "bar"}, + ) diff --git a/tests/unittests/command_parse/test_script.py b/tests/unittests/command_parse/test_script.py new file mode 100644 index 0000000..3b984c3 --- /dev/null +++ b/tests/unittests/command_parse/test_script.py @@ -0,0 +1,22 @@ +def test_eval(judge_command): + judge_command( + 'eval "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}" 2 key1 key2 first second', + { + "command": "eval", + "double_lua": "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", + "any": "2 key1 key2 first second", + }, + ) + judge_command( + "eval 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}' 2 key1 key2 first second", + { + "command": "eval", + "single_lua": "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", + "any": "2 key1 key2 first second", + }, + ) + + +def test_scriptdebug(judge_command): + judge_command("SCRIPT DEBUG YES", {"command": "SCRIPT DEBUG", "scriptdebug": "YES"}) + judge_command("SCRIPT DEBUG no", {"command": "SCRIPT DEBUG", "scriptdebug": "no"}) diff --git a/tests/unittests/command_parse/test_server.py b/tests/unittests/command_parse/test_server.py new file mode 100644 index 0000000..5ecccbf --- /dev/null +++ b/tests/unittests/command_parse/test_server.py @@ -0,0 +1,272 @@ +def test_client_setname(judge_command): + judge_command( + "CLIENT SETNAME foobar", {"command": "CLIENT SETNAME", "value": "foobar"} + ) + + +def test_client_unblock(judge_command): + judge_command( + "CLIENT UNBLOCK 33 TIMEOUT", + {"command": "CLIENT UNBLOCK", "clientid": "33", "error": "TIMEOUT"}, + ) + judge_command("CLIENT UNBLOCK 33", {"command": "CLIENT UNBLOCK", "clientid": "33"}) + + +def test_flushdb(judge_command): + judge_command("FLUSHDB async", {"command": "FLUSHDB", "async": "async"}) + judge_command("FLUSHDB", {"command": "FLUSHDB"}) + judge_command("FLUSHDB ASYNC", {"command": "FLUSHDB", "async": "ASYNC"}) + judge_command("FLUSHALL ASYNC", {"command": "FLUSHALL", "async": "ASYNC"}) + + +def test_client_list(judge_command): + judge_command("client list", {"command": "client list"}) + judge_command("client list TYPE REPLICA1", None) + judge_command( + "client list type master", + {"command": "client list", "type_const": "type", "conntype": "master"}, + ) + judge_command( + "client list TYPE REPLICA", + {"command": "client list", "type_const": "TYPE", "conntype": "REPLICA"}, + ) + + judge_command( + "client list TYPE REPLICA id 1 2 3", + { + "command": "client list", + "type_const": "TYPE", + "conntype": "REPLICA", + "clientids": "1 2 3", + }, + ) + judge_command( + "client list ID 1 2 3", + {"command": "client list", "clientids": "1 2 3"}, + ) + + +def test_configset(judge_command): + judge_command( + "config set foo bar", + {"command": "config set", "parameter": "foo", "value": "bar"}, + ) + judge_command( + "config set requirepass ''", + {"command": "config set", "parameter": "requirepass", "value": "''"}, + ) + + +def test_shutdown(judge_command): + judge_command("shutdown save", {"command": "shutdown", "shutdown": "save"}) + judge_command("shutdown NOSAVE", {"command": "shutdown", "shutdown": "NOSAVE"}) + + +def test_clientpause(judge_command): + judge_command("client pause 3000", {"command": "client pause", "timeout": "3000"}) + + +def test_client_reply(judge_command): + judge_command("client reply on", {"command": "client reply", "switch": "on"}) + + +def test_client_kill(judge_command): + judge_command( + "CLIENT KILL addr 127.0.0.1:12345 type pubsub", + { + "command": "CLIENT KILL", + "addr": "addr", + "ip_port": "127.0.0.1:12345", + "type_const": "type", + "conntype": "pubsub", + }, + ) + judge_command( + "CLIENT KILL 127.0.0.1:12345 ", + {"command": "CLIENT KILL", "ip_port": "127.0.0.1:12345"}, + ) + judge_command( + "CLIENT KILL ADDR 127.0.0.1:12345 ", + {"command": "CLIENT KILL", "ip_port": "127.0.0.1:12345", "addr": "ADDR"}, + ) + judge_command( + "CLIENT KILL LADDR 127.0.0.1:12345 ", + {"command": "CLIENT KILL", "ip_port": "127.0.0.1:12345", "laddr": "LADDR"}, + ) + judge_command( + "CLIENT KILL USER myuser", + {"command": "CLIENT KILL", "const_user": "USER", "username": "myuser"}, + ) + judge_command( + "CLIENT KILL id 123455 type pubsub skipme no", + { + "command": "CLIENT KILL", + "const_id": "id", + "clientid": "123455", + "type_const": "type", + "conntype": "pubsub", + "skipme": "skipme", + "yes": "no", + }, + ) + + +def test_client_kill_username(judge_command): + """since redis-server 6.0""" + judge_command( + "client kill USER default", + {"command": "client kill", "const_user": "USER", "username": "default"}, + ) + + +def test_client_kill_unordered_arguments(judge_command): + judge_command( + "CLIENT KILL type pubsub addr 127.0.0.1:12345", + { + "command": "CLIENT KILL", + "addr": "addr", + "ip_port": "127.0.0.1:12345", + "type_const": "type", + "conntype": "pubsub", + }, + ) + + +def test_psync(judge_command): + judge_command( + "PSYNC abc 123", {"command": "PSYNC", "replicationid": "abc", "offset": "123"} + ) + judge_command("PSYNC", None) + + +def test_latency_graph(judge_command): + judge_command( + "latency graph command", {"command": "latency graph", "graphevent": "command"} + ) + judge_command( + "latency graph fork", {"command": "latency graph", "graphevent": "fork"} + ) + judge_command("latency graph", None) + + +def test_latency_reset(judge_command): + judge_command( + "latency reset command fork aof-fsync-always", + {"command": "latency reset", "graphevent": "aof-fsync-always"}, + ) + judge_command( + "latency reset fork", {"command": "latency reset", "graphevent": "fork"} + ) + judge_command("latency reset", {"command": "latency reset"}) + + +def test_lolwut(judge_command): + judge_command("lolwut", {"command": "lolwut"}) + # only works before redis 6 + judge_command("lolwut 5", {"command": "lolwut", "any": "5"}) + judge_command("lolwut 5 1", {"command": "lolwut", "any": "5 1"}) + # redis 6 + judge_command( + "lolwut VERSION 5 5", + {"command": "lolwut", "version": "VERSION", "version_num": "5", "any": "5"}, + ) + + +def test_info(judge_command): + judge_command("info cpu", {"command": "info", "section": "cpu"}) + judge_command("info", {"command": "info"}) + judge_command("info all", {"command": "info", "section": "all"}) + judge_command("info CPU", {"command": "info", "section": "CPU"}) + + +def test_bgsave(judge_command): + judge_command("bgsave", {"command": "bgsave"}) + judge_command("bgsave schedule", {"command": "bgsave", "schedule": "schedule"}) + judge_command("BGSAVE SCHEDULE", {"command": "BGSAVE", "schedule": "SCHEDULE"}) + + +def test_acl_cat(judge_command): + judge_command("acl cat", {"command": "acl cat"}) + judge_command("acl CAT", {"command": "acl CAT"}) + judge_command( + "ACL CAT scripting", {"command": "ACL CAT", "categoryname": "scripting"} + ) + judge_command("ACL CAT WATCH", {"command": "ACL CAT", "categoryname": "WATCH"}) + + +def test_acl_deluser(judge_command): + judge_command( + "acl deluser laixintao", {"command": "acl deluser", "username": "laixintao"} + ) + judge_command( + "acl deluser laixintao antirez", + {"command": "acl deluser", "username": "antirez"}, + ) + + +def test_acl_log(judge_command): + judge_command("acl log 2", {"command": "acl log", "count": "2"}) + judge_command("acl log reset", {"command": "acl log", "reset_const": "reset"}) + judge_command("acl log ", {"command": "acl log"}) + + +def test_acl_setuser(judge_command): + judge_command("ACL SETUSER alice", {"command": "ACL SETUSER", "username": "alice"}) + judge_command( + "ACL SETUSER alice on >p1pp0 ~cached:* +get", + {"command": "ACL SETUSER", "username": "alice", "rule": "+get"}, + ) + judge_command( + "ACL SETUSER alan allkeys +@string +@set -SADD >alanpassword", + {"command": "ACL SETUSER", "username": "alan", "rule": ">alanpassword"}, + ) + + +def test_acl_getuser(judge_command): + judge_command("acl getuser alan", {"command": "acl getuser", "username": "alan"}) + judge_command("acl getuser", None) + + +def test_failover(judge_command): + judge_command( + "failover to 10.0.0.5 7379 abort timeout 101", + { + "command": "failover", + "to_const": "to", + "host": "10.0.0.5", + "port": "7379", + "abort_const": "abort", + "timeout_const": "timeout", + "millisecond": "101", + }, + ) + judge_command( + "failover abort timeout 101", + { + "command": "failover", + "abort_const": "abort", + "timeout_const": "timeout", + "millisecond": "101", + }, + ) + judge_command( + "failover timeout 101", + { + "command": "failover", + "timeout_const": "timeout", + "millisecond": "101", + }, + ) + judge_command( + "failover to 10.0.0.5 7379 force abort timeout 101", + { + "command": "failover", + "to_const": "to", + "force": "force", + "host": "10.0.0.5", + "port": "7379", + "abort_const": "abort", + "timeout_const": "timeout", + "millisecond": "101", + }, + ) diff --git a/tests/unittests/command_parse/test_set_parse.py b/tests/unittests/command_parse/test_set_parse.py new file mode 100644 index 0000000..d35a52b --- /dev/null +++ b/tests/unittests/command_parse/test_set_parse.py @@ -0,0 +1,40 @@ +def test_sadd(judge_command): + judge_command( + "SADD foo m1 m2 m3", {"command": "SADD", "key": "foo", "members": "m1 m2 m3"} + ) + judge_command("SADD foo m1", {"command": "SADD", "key": "foo", "members": "m1"}) + judge_command("SADD foo", None) + + +def test_sdiffstore(judge_command): + judge_command( + "SDIFFSTORE foo m1 m2 m3", + {"command": "SDIFFSTORE", "destination": "foo", "keys": "m1 m2 m3"}, + ) + judge_command( + "SDIFFSTORE foo m1", + {"command": "SDIFFSTORE", "destination": "foo", "keys": "m1"}, + ) + judge_command("SDIFFSTORE foo", None) + + +def test_is_member(judge_command): + judge_command("SISMEMBER foo m1 m2 m3", None) + judge_command( + "SISMEMBER foo m1", {"command": "SISMEMBER", "key": "foo", "member": "m1"} + ) + judge_command("SISMEMBER foo", None) + + +def test_smove(judge_command): + judge_command( + "SMOVE foo bar m2", + {"command": "SMOVE", "key": "foo", "newkey": "bar", "member": "m2"}, + ) + judge_command("SMOVE foo m1", None) + judge_command("SMOVE foo", None) + + +def test_spop(judge_command): + judge_command("SPOP set", {"command": "SPOP", "key": "set"}) + judge_command("SPOP set 3", {"command": "SPOP", "key": "set", "count": "3"}) diff --git a/tests/unittests/command_parse/test_sorted_set_parse.py b/tests/unittests/command_parse/test_sorted_set_parse.py new file mode 100644 index 0000000..a0af616 --- /dev/null +++ b/tests/unittests/command_parse/test_sorted_set_parse.py @@ -0,0 +1,172 @@ +import pytest + + +def test_zcount(judge_command): + judge_command( + "zcount foo -10 0", + {"command": "zcount", "key": "foo", "min": "-10", "max": "0"}, + ) + + +def test_bzpopmax(judge_command): + judge_command( + "bzpopmax set set2 set3 4", + {"command": "bzpopmax", "keys": "set set2 set3", "timeout": "4"}, + ) + judge_command( + "bzpopmin set 4", {"command": "bzpopmin", "keys": "set", "timeout": "4"} + ) + + +def test_zadd(judge_command): + judge_command( + "zadd t 100 qewqr 23 pp 11 oo", + { + "command": "zadd", + "key": "t", + "score": "11", # FIXME: only have last one + "member": "oo", + }, + ) + judge_command( + "zadd t incr 100 foo", + { + "command": "zadd", + "key": "t", + "incr": "incr", + "score": "100", # FIXME: only have last one + "member": "foo", + }, + ) + judge_command( + "zadd t NX CH incr 100 foo", + { + "command": "zadd", + "key": "t", + "condition": "NX", + "changed": "CH", + "incr": "incr", + "score": "100", # FIXME: only have last one + "member": "foo", + }, + ) + + +def test_zincrby(judge_command): + judge_command( + "zincrby t 10 foo", + {"command": "zincrby", "key": "t", "float": "10", "member": "foo"}, + ) + judge_command( + "zincrby t 2.3 foo", + {"command": "zincrby", "key": "t", "float": "2.3", "member": "foo"}, + ) + + +def test_zlexcount(judge_command): + judge_command( + "zlexcount a - +", + {"command": "zlexcount", "key": "a", "lexmin": "-", "lexmax": "+"}, + ) + judge_command( + "zlexcount a (aaaa [z", + {"command": "zlexcount", "key": "a", "lexmin": "(aaaa", "lexmax": "[z"}, + ) + judge_command( + "ZLEXCOUNT myset - [c", + {"command": "ZLEXCOUNT", "key": "myset", "lexmin": "-", "lexmax": "[c"}, + ) + judge_command( + "ZLEXCOUNT myset [aaa (g", + {"command": "ZLEXCOUNT", "key": "myset", "lexmin": "[aaa", "lexmax": "(g"}, + ) + + +def test_zrange(judge_command): + judge_command( + "zrange foo -1 10", + {"command": "zrange", "key": "foo", "start": "-1", "end": "10"}, + ) + judge_command( + "zrange foo 0 -1", + {"command": "zrange", "key": "foo", "start": "0", "end": "-1"}, + ) + judge_command( + "zrange foo 0 -1 withscores", + { + "command": "zrange", + "key": "foo", + "start": "0", + "end": "-1", + "withscores": "withscores", + }, + ) + + +@pytest.mark.xfail(reason="Not implemented yet") +def test_zinterstore(judge_command): + judge_command("ZINTERSTORE out 2 zset1 zset2 WEIGHTS 2 3", {}) + judge_command("ZINTERSTORE out 2 zset1 zset2 WEIGHTS -1 -2", {}) + judge_command("ZINTERSTORE out 2 zset1 zset2 WEIGHTS 0.2 0.3", {}) + + +def test_zrangebylex(judge_command): + judge_command( + "ZRANGEBYLEX myzset [aaa (g", + {"command": "ZRANGEBYLEX", "key": "myzset", "lexmin": "[aaa", "lexmax": "(g"}, + ) + judge_command( + "ZRANGEBYLEX myzset - (c", + {"command": "ZRANGEBYLEX", "key": "myzset", "lexmin": "-", "lexmax": "(c"}, + ) + judge_command( + "ZRANGEBYLEX myzset - (c limit 10 100", + { + "command": "ZRANGEBYLEX", + "key": "myzset", + "lexmin": "-", + "lexmax": "(c", + "limit": "limit", + "offset": "10", + "count": "100", + }, + ) + judge_command( + "ZRANGEBYLEX myzset - (c limit 10 -1", + { + "command": "ZRANGEBYLEX", + "key": "myzset", + "lexmin": "-", + "lexmax": "(c", + "limit": "limit", + "offset": "10", + "count": "-1", + }, + ) + + +def test_zrangebyscore(judge_command): + judge_command( + "ZRANGEBYSCORE myzset -inf +inf", + {"command": "ZRANGEBYSCORE", "key": "myzset", "min": "-inf", "max": "+inf"}, + ) + judge_command( + "ZRANGEBYSCORE myzset 1 2", + {"command": "ZRANGEBYSCORE", "key": "myzset", "min": "1", "max": "2"}, + ) + judge_command( + "ZRANGEBYSCORE myzset (1 (2", + {"command": "ZRANGEBYSCORE", "key": "myzset", "min": "(1", "max": "(2"}, + ) + judge_command( + "ZRANGEBYSCORE myzset -inf +inf LIMIT 10 100", + { + "command": "ZRANGEBYSCORE", + "key": "myzset", + "min": "-inf", + "max": "+inf", + "limit": "LIMIT", + "offset": "10", + "count": "100", + }, + ) diff --git a/tests/unittests/command_parse/test_stream.py b/tests/unittests/command_parse/test_stream.py new file mode 100644 index 0000000..82f8670 --- /dev/null +++ b/tests/unittests/command_parse/test_stream.py @@ -0,0 +1,459 @@ +def test_xrange(judge_command): + judge_command( + "XRANGE somestream - +", + {"command": "XRANGE", "key": "somestream", "stream_id": ["-", "+"]}, + ) + judge_command( + "XRANGE somestream 1526985054069 1526985055069", + { + "command": "XRANGE", + "key": "somestream", + "stream_id": ["1526985054069", "1526985055069"], + }, + ) + judge_command( + "XRANGE somestream 1526985054069 1526985055069-10", + { + "command": "XRANGE", + "key": "somestream", + "stream_id": ["1526985054069", "1526985055069-10"], + }, + ) + judge_command( + "XRANGE somestream 1526985054069 1526985055069-10 count 10", + { + "command": "XRANGE", + "key": "somestream", + "stream_id": ["1526985054069", "1526985055069-10"], + "count_const": "count", + "count": "10", + }, + ) + + +def test_xgroup_create(judge_command): + judge_command( + "XGROUP CREATE mykey mygroup 123", + { + "command": "XGROUP", + "stream_create": "CREATE", + "key": "mykey", + "group": "mygroup", + "stream_id": "123", + }, + ) + judge_command( + "XGROUP CREATE mykey mygroup $", + { + "command": "XGROUP", + "stream_create": "CREATE", + "key": "mykey", + "group": "mygroup", + "stream_id": "$", + }, + ) + # short of a parameter + judge_command("XGROUP CREATE mykey mygroup", None) + judge_command("XGROUP CREATE mykey", None) + + +def test_xgroup_setid(judge_command): + judge_command( + "XGROUP SETID mykey mygroup 123", + { + "command": "XGROUP", + "stream_setid": "SETID", + "key": "mykey", + "group": "mygroup", + "stream_id": "123", + }, + ) + judge_command( + "XGROUP SETID mykey mygroup $", + { + "command": "XGROUP", + "stream_setid": "SETID", + "key": "mykey", + "group": "mygroup", + "stream_id": "$", + }, + ) + # two subcommand together shouldn't match + judge_command("XGROUP CREATE mykey mygroup 123 SETID mykey mygroup $", None) + + +def test_xgroup_destroy(judge_command): + judge_command( + "XGROUP destroy mykey mygroup", + { + "command": "XGROUP", + "stream_destroy": "destroy", + "key": "mykey", + "group": "mygroup", + }, + ) + judge_command("XGROUP destroy mykey", None) + judge_command("XGROUP DESTROY mykey mygroup $", None) + + +def test_xgroup_delconsumer(judge_command): + judge_command( + "XGROUP delconsumer mykey mygroup myconsumer", + { + "command": "XGROUP", + "stream_delconsumer": "delconsumer", + "key": "mykey", + "group": "mygroup", + "consumer": "myconsumer", + }, + ) + judge_command( + "XGROUP delconsumer mykey mygroup $", + { + "command": "XGROUP", + "stream_delconsumer": "delconsumer", + "key": "mykey", + "group": "mygroup", + "consumer": "$", + }, + ) + judge_command("XGROUP delconsumer mykey mygroup", None) + + +def test_xgroup_stream(judge_command): + judge_command( + "XACK mystream group1 123123", + { + "command": "XACK", + "key": "mystream", + "group": "group1", + "stream_id": "123123", + }, + ) + judge_command( + "XACK mystream group1 123123 111", + {"command": "XACK", "key": "mystream", "group": "group1", "stream_id": "111"}, + ) + + +def test_xinfo(judge_command): + judge_command( + "XINFO consumers mystream mygroup", + { + "command": "XINFO", + "stream_consumers": "consumers", + "key": "mystream", + "group": "mygroup", + }, + ) + judge_command( + "XINFO GROUPS mystream", + {"command": "XINFO", "stream_groups": "GROUPS", "key": "mystream"}, + ) + judge_command( + "XINFO STREAM mystream", + {"command": "XINFO", "stream": "STREAM", "key": "mystream"}, + ) + judge_command("XINFO HELP", {"command": "XINFO", "help": "HELP"}) + judge_command("XINFO consumers mystream mygroup GROUPS mystream", None) + judge_command("XINFO groups mystream mygroup", None) + + +def test_xinfo_with_full(judge_command): + judge_command( + "XINFO STREAM mystream FULL", + { + "command": "XINFO", + "stream": "STREAM", + "key": "mystream", + "full_const": "FULL", + }, + ) + judge_command( + "XINFO STREAM mystream FULL count 10", + { + "command": "XINFO", + "stream": "STREAM", + "key": "mystream", + "full_const": "FULL", + "count_const": "count", + "count": "10", + }, + ) + + +def test_xpending(judge_command): + judge_command( + "XPENDING mystream group55", + {"command": "XPENDING", "key": "mystream", "group": "group55"}, + ) + judge_command( + "XPENDING mystream group55 myconsumer", + { + "command": "XPENDING", + "key": "mystream", + "group": "group55", + "consumer": "myconsumer", + }, + ) + judge_command( + "XPENDING mystream group55 - + 10", + { + "command": "XPENDING", + "key": "mystream", + "group": "group55", + "stream_id": ["-", "+"], + "count": "10", + }, + ) + judge_command( + "XPENDING mystream group55 - + 10 myconsumer", + { + "command": "XPENDING", + "key": "mystream", + "group": "group55", + "stream_id": ["-", "+"], + "count": "10", + "consumer": "myconsumer", + }, + ) + judge_command("XPENDING mystream group55 - + ", None) + + +def test_xadd(judge_command): + judge_command( + "xadd mystream MAXLEN ~ 1000 * key value", + { + "command": "xadd", + "key": "mystream", + "maxlen": "MAXLEN", + "approximately": "~", + "count": "1000", + "sfield": "key", + "svalue": "value", + "stream_id": "*", + }, + ) + # test for MAXLEN option + judge_command( + "xadd mystream MAXLEN 1000 * key value", + { + "command": "xadd", + "key": "mystream", + "maxlen": "MAXLEN", + "count": "1000", + "sfield": "key", + "svalue": "value", + "stream_id": "*", + }, + ) + judge_command( + "xadd mystream * key value", + { + "command": "xadd", + "key": "mystream", + "sfield": "key", + "svalue": "value", + "stream_id": "*", + }, + ) + # spcify stream id + judge_command( + "xadd mystream 123-123 key value", + { + "command": "xadd", + "key": "mystream", + "sfield": "key", + "svalue": "value", + "stream_id": "123-123", + }, + ) + judge_command( + "xadd mystream 123-123 key value foo bar hello world", + { + "command": "xadd", + "key": "mystream", + "sfield": "hello", + "svalue": "world", + "stream_id": "123-123", + }, + ) + + +def test_xtrim(judge_command): + judge_command( + " XTRIM mystream MAXLEN 2", + {"command": "XTRIM", "key": "mystream", "maxlen": "MAXLEN", "count": "2"}, + ) + judge_command( + " XTRIM mystream MAXLEN ~ 2", + { + "command": "XTRIM", + "key": "mystream", + "maxlen": "MAXLEN", + "count": "2", + "approximately": "~", + }, + ) + judge_command(" XTRIM mystream", None) + + +def test_xdel(judge_command): + judge_command( + "XDEL mystream 1581165000000 1549611229000 1581060831000", + {"command": "XDEL", "key": "mystream", "stream_id": "1581060831000"}, + ) + judge_command( + "XDEL mystream 1581165000000", + {"command": "XDEL", "key": "mystream", "stream_id": "1581165000000"}, + ) + + +def test_xclaim(judge_command): + judge_command( + "XCLAIM mystream mygroup Alice 3600000 1526569498055-0", + { + "command": "XCLAIM", + "key": "mystream", + "group": "mygroup", + "consumer": "Alice", + "millisecond": "3600000", + "stream_id": "1526569498055-0", + }, + ) + judge_command( + "XCLAIM mystream mygroup Alice 3600000 1526569498055-0 123 456 789", + { + "command": "XCLAIM", + "key": "mystream", + "group": "mygroup", + "consumer": "Alice", + "millisecond": "3600000", + "stream_id": "789", + }, + ) + judge_command( + "XCLAIM mystream mygroup Alice 3600000 1526569498055-0 IDLE 300", + { + "command": "XCLAIM", + "key": "mystream", + "group": "mygroup", + "consumer": "Alice", + "millisecond": ["3600000", "300"], + "stream_id": "1526569498055-0", + "idle": "IDLE", + }, + ) + judge_command( + "XCLAIM mystream mygroup Alice 3600000 1526569498055-0 retrycount 7", + { + "command": "XCLAIM", + "key": "mystream", + "group": "mygroup", + "consumer": "Alice", + "millisecond": "3600000", + "stream_id": "1526569498055-0", + "retrycount": "retrycount", + "count": "7", + }, + ) + judge_command( + "XCLAIM mystream mygroup Alice 3600000 1526569498055-0 TIME 123456789", + { + "command": "XCLAIM", + "key": "mystream", + "group": "mygroup", + "consumer": "Alice", + "millisecond": "3600000", + "stream_id": "1526569498055-0", + "time": "TIME", + "timestamp": "123456789", + }, + ) + judge_command( + "XCLAIM mystream mygroup Alice 3600000 1526569498055-0 FORCE", + { + "command": "XCLAIM", + "key": "mystream", + "group": "mygroup", + "consumer": "Alice", + "millisecond": "3600000", + "stream_id": "1526569498055-0", + "force": "FORCE", + }, + ) + judge_command( + "XCLAIM mystream mygroup Alice 3600000 1526569498055-0 JUSTID", + { + "command": "XCLAIM", + "key": "mystream", + "group": "mygroup", + "consumer": "Alice", + "millisecond": "3600000", + "stream_id": "1526569498055-0", + "justid": "JUSTID", + }, + ) + + +def test_xread(judge_command): + judge_command( + "XREAD COUNT 2 STREAMS mystream writers 0-0 0-0", + { + "command": "XREAD", + "count_const": "COUNT", + "count": "2", + "streams": "STREAMS", + # FIXME current grammar can't support multiple tokens + # so the ids will be recognized to keys. + "keys": "mystream writers 0-0", + "stream_id": "0-0", + }, + ) + judge_command( + "XREAD COUNT 2 BLOCK 1000 STREAMS mystream writers 0-0 0-0", + { + "command": "XREAD", + "count_const": "COUNT", + "count": "2", + "streams": "STREAMS", + "keys": "mystream writers 0-0", + "block": "BLOCK", + "millisecond": "1000", + "stream_id": "0-0", + }, + ) + + +def test_xreadgroup(judge_command): + judge_command( + "XREADGROUP GROUP mygroup1 Bob COUNT 1 BLOCK 100 NOACK STREAMS key1 1 key2 2", + { + "command": "XREADGROUP", + "stream_group": "GROUP", + "group": "mygroup1", + "consumer": "Bob", + "count_const": "COUNT", + "count": "1", + "block": "BLOCK", + "millisecond": "100", + "noack": "NOACK", + "streams": "STREAMS", + "keys": "key1 1 key2", + "stream_id": "2", + }, + ) + judge_command( + "XREADGROUP GROUP mygroup1 Bob STREAMS key1 1 key2 2", + { + "command": "XREADGROUP", + "stream_group": "GROUP", + "group": "mygroup1", + "consumer": "Bob", + "streams": "STREAMS", + "keys": "key1 1 key2", + "stream_id": "2", + }, + ) + + judge_command("XREADGROUP GROUP group consumer", None) diff --git a/tests/unittests/command_parse/test_string_parse.py b/tests/unittests/command_parse/test_string_parse.py new file mode 100644 index 0000000..df56b25 --- /dev/null +++ b/tests/unittests/command_parse/test_string_parse.py @@ -0,0 +1,345 @@ +def test_set(judge_command): + judge_command("SET abc bar", {"command": "SET", "key": "abc", "value": "bar"}) + judge_command( + "SET abc bar EX 10", + { + "command": "SET", + "key": "abc", + "value": "bar", + "expiration": "EX", + "millisecond": "10", + }, + ) + judge_command( + "SET abc bar px 10000", + { + "command": "SET", + "key": "abc", + "value": "bar", + "expiration": "px", + "millisecond": "10000", + }, + ) + judge_command( + "SET abc bar px 10000 nx", + { + "command": "SET", + "key": "abc", + "value": "bar", + "expiration": "px", + "millisecond": "10000", + "condition": "nx", + }, + ) + judge_command( + "SET abc bar px 10000 XX", + { + "command": "SET", + "key": "abc", + "value": "bar", + "expiration": "px", + "millisecond": "10000", + "condition": "XX", + }, + ) + judge_command( + "SET abc bar XX px 10000", + { + "command": "SET", + "key": "abc", + "value": "bar", + "expiration": "px", + "millisecond": "10000", + "condition": "XX", + }, + ) + judge_command( + "SET abc bar XX", + {"command": "SET", "key": "abc", "value": "bar", "condition": "XX"}, + ) + # keepttl + judge_command( + "SET abc bar XX keepttl", + { + "command": "SET", + "key": "abc", + "value": "bar", + "condition": "XX", + "keepttl": "keepttl", + }, + ) + judge_command( + "SET abc bar keepttl XX", + { + "command": "SET", + "key": "abc", + "value": "bar", + "condition": "XX", + "keepttl": "keepttl", + }, + ) + judge_command( + "SET abc bar XX px 10000 KEEPTTL", + { + "command": "SET", + "key": "abc", + "value": "bar", + "expiration": "px", + "millisecond": "10000", + "condition": "XX", + "keepttl": "KEEPTTL", + }, + ) + + +def test_append(judge_command): + judge_command("append foo bar", {"command": "append", "key": "foo", "value": "bar"}) + judge_command( + "APPEND foo 'bar'", {"command": "APPEND", "key": "foo", "value": "'bar'"} + ) + judge_command("APPEND foo", None) + + +def test_bitcount(judge_command): + judge_command("bitcount foo", {"command": "bitcount", "key": "foo"}) + judge_command( + "bitcount foo 1 5", + {"command": "bitcount", "key": "foo", "start": "1", "end": "5"}, + ) + judge_command( + "bitcount foo 1 -5", + {"command": "bitcount", "key": "foo", "start": "1", "end": "-5"}, + ) + judge_command( + "bitcount foo -2 -1", + {"command": "bitcount", "key": "foo", "start": "-2", "end": "-1"}, + ) + judge_command("bitcount foo -2", None) + + +def test_getrange(judge_command): + judge_command("getrange foo", None) + judge_command( + "getrange foo 1 5", + {"command": "getrange", "key": "foo", "start": "1", "end": "5"}, + ) + judge_command( + "getrange foo 1 -5", + {"command": "getrange", "key": "foo", "start": "1", "end": "-5"}, + ) + judge_command( + "getrange foo -2 -1", + {"command": "getrange", "key": "foo", "start": "-2", "end": "-1"}, + ) + judge_command("getrange foo -2", None) + + +def test_get_set(judge_command): + judge_command("GETSET abc bar", {"command": "GETSET", "key": "abc", "value": "bar"}) + + +def test_incr(judge_command): + judge_command("INCR foo", {"command": "INCR", "key": "foo"}) + judge_command("INCR", None) + judge_command("INCR foo 1", None) + + +def test_incr_by(judge_command): + judge_command("INCRBY foo", None) + judge_command("INCRBY", None) + judge_command("INCRBY foo 1", {"command": "INCRBY", "key": "foo", "delta": "1"}) + judge_command("INCRBY foo 200", {"command": "INCRBY", "key": "foo", "delta": "200"}) + judge_command("INCRBY foo -21", {"command": "INCRBY", "key": "foo", "delta": "-21"}) + + +def test_decr(judge_command): + judge_command("DECR foo", {"command": "DECR", "key": "foo"}) + judge_command("DECR", None) + judge_command("DECR foo 1", None) + + +def test_decr_by(judge_command): + judge_command("DECRBY foo", None) + judge_command("DECRBY", None) + judge_command("DECRBY foo 1", {"command": "DECRBY", "key": "foo", "delta": "1"}) + judge_command("DECRBY foo 200", {"command": "DECRBY", "key": "foo", "delta": "200"}) + judge_command("DECRBY foo -21", {"command": "DECRBY", "key": "foo", "delta": "-21"}) + + +def test_command_set_range(judge_command): + judge_command( + "SETRANGE foo 10 bar", + {"command": "SETRANGE", "key": "foo", "offset": "10", "value": "bar"}, + ) + judge_command("SETRANGE foo bar", None) + judge_command( + "SETRANGE Redis 10 'hello world'", + { + "command": "SETRANGE", + "key": "Redis", + "offset": "10", + "value": "'hello world'", + }, + ) + + +def test_command_set_ex(judge_command): + judge_command( + "SETEX key 10 value", + {"command": "SETEX", "key": "key", "second": "10", "value": "value"}, + ) + judge_command("SETEX foo 10", None) + judge_command( + "setex Redis 10 'hello world'", + {"command": "setex", "key": "Redis", "second": "10", "value": "'hello world'"}, + ) + + +def test_command_setbit(judge_command): + judge_command( + "SETBIT key 10 0", + {"command": "SETBIT", "key": "key", "offset": "10", "bit": "0"}, + ) + judge_command( + "SETBIT foo 10 1", + {"command": "SETBIT", "key": "foo", "offset": "10", "bit": "1"}, + ) + judge_command("SETBIT foo 10 10", None) + judge_command("SETBIT foo 10 abc", None) + judge_command("SETBIT foo 10", None) + judge_command("SETBIT foo", None) + + +def test_command_getbit(judge_command): + judge_command("GETBIT key 10", {"command": "GETBIT", "key": "key", "offset": "10"}) + judge_command("GETBIT foo 0", {"command": "GETBIT", "key": "foo", "offset": "0"}) + judge_command("GETBIT foo -1", None) + judge_command("SETBIT foo abc", None) + judge_command("SETBIT foo", None) + + +def test_command_incrbyfloat(judge_command): + judge_command("INCRBYFLOAT key", None) + judge_command( + "INCRBYFLOAT key 1.1", {"command": "INCRBYFLOAT", "key": "key", "float": "1.1"} + ) + judge_command( + "INCRBYFLOAT key .1", {"command": "INCRBYFLOAT", "key": "key", "float": ".1"} + ) + judge_command( + "INCRBYFLOAT key 1.", {"command": "INCRBYFLOAT", "key": "key", "float": "1."} + ) + judge_command( + "INCRBYFLOAT key 5.0e3", + {"command": "INCRBYFLOAT", "key": "key", "float": "5.0e3"}, + ) + judge_command( + "INCRBYFLOAT key -5.0e3", + {"command": "INCRBYFLOAT", "key": "key", "float": "-5.0e3"}, + ) + + +def test_command_mget(judge_command): + judge_command("mget foo bar", {"command": "mget", "keys": "foo bar"}) + + +def test_mset(judge_command): + judge_command("mset foo bar", {"command": "mset", "key": "foo", "value": "bar"}) + judge_command( + "mset foo bar hello world", + {"command": "mset", "key": "hello", "value": "world"}, + ) + + +def test_psetex(judge_command): + judge_command( + "psetex foo 1000 bar", + {"command": "psetex", "key": "foo", "value": "bar", "millisecond": "1000"}, + ) + judge_command("psetex foo bar", None) + + +def test_bitop(judge_command): + judge_command( + "BITOP AND dest key1 key2", + {"command": "BITOP", "operation": "AND", "key": "dest", "keys": "key1 key2"}, + ) + judge_command( + "BITOP AND dest key1", + {"command": "BITOP", "operation": "AND", "key": "dest", "keys": "key1"}, + ) + judge_command("BITOP AND dest", None) + + +def test_bitpos(judge_command): + judge_command( + "BITPOS mykey 1 3 5", + {"command": "BITPOS", "key": "mykey", "bit": "1", "start": "3", "end": "5"}, + ) + judge_command("BITPOS mykey 1", {"command": "BITPOS", "key": "mykey", "bit": "1"}) + judge_command( + "BITPOS mykey 1 3", + {"command": "BITPOS", "key": "mykey", "bit": "1", "start": "3"}, + ) + + +def test_bitfield(judge_command): + judge_command( + "BITFIELD mykey INCRBY i5 100 1 GET u4 0", + { + "command": "BITFIELD", + "key": "mykey", + "incrby": "INCRBY", + "inttype": ["i5", "u4"], + "offset": ["100", "0"], + "value": "1", + "get": "GET", + }, + ) + judge_command( + "BITFIELD mystring SET i8 #0 100", + { + "command": "BITFIELD", + "key": "mystring", + "set": "SET", + "inttype": "i8", + "offset": "#0", + "value": "100", + }, + ) + judge_command( + "BITFIELD mykey incrby u2 100 1 OVERFLOW SAT incrby u2 102 1", + { + "command": "BITFIELD", + "key": "mykey", + "incrby": "incrby", + "inttype": "u2", + "offset": "102", + "value": "1", + "overflow": "OVERFLOW", + "overflow_option": "SAT", + }, + ) + + +def test_stralgo(judge_command): + judge_command( + "STRALGO LCS STRINGS ohmytext mynewtext", + { + "command": "STRALGO", + "str_algo": "LCS", + "strings_const": "STRINGS", + "values": "ohmytext mynewtext", + }, + ) + + # Due to redis' command design, this can't be fix in any ways. + judge_command( + "STRALGO LCS STRINGS ohmytext mynewtext LEN", + { + "command": "STRALGO", + "str_algo": "LCS", + "strings_const": "STRINGS", + "values": "ohmytext mynewtext LEN", + }, + ) diff --git a/tests/unittests/test_client.py b/tests/unittests/test_client.py new file mode 100644 index 0000000..45f0054 --- /dev/null +++ b/tests/unittests/test_client.py @@ -0,0 +1,602 @@ +import os +import re +import pytest +import redis +from unittest.mock import MagicMock, patch +from textwrap import dedent + +from prompt_toolkit.formatted_text import FormattedText + +from iredis.client import Client +from iredis.config import config, load_config_files +from iredis.completers import IRedisCompleter +from iredis.entry import Rainbow, prompt_message +from iredis.exceptions import NotSupport +from iredis.commands import command2syntax +from ..helpers import formatted_text_rematch + + +@pytest.fixture +def completer(): + return IRedisCompleter() + + +zset_type = "ziplist" +if os.environ["REDIS_VERSION"] == "7": + zset_type = "listpack" + + +@pytest.mark.parametrize( + "_input, command_name, expect_args", + [ + ("keys *", "keys", ["*"]), + ("DEL abc foo bar", "DEL", ["abc", "foo", "bar"]), + ("cluster info", "cluster info", []), + ("CLUSTER failover FORCE", "CLUSTER failover", ["FORCE"]), + ], +) +def test_send_command(_input, command_name, expect_args): + client = Client("127.0.0.1", "6379", None) + client.execute = MagicMock() + next(client.send_command(_input, None)) + args, _ = client.execute.call_args + assert args == (command_name, *expect_args) + + +def test_client_not_support_hello_command(iredis_client): + with pytest.raises(NotSupport): + iredis_client.pre_hook("hello 3", "hello", "3", None) + + +def test_patch_completer(): + client = Client("127.0.0.1", "6379", None) + completer = IRedisCompleter() + client.pre_hook( + "MGET foo bar hello world", "MGET", "foo bar hello world", completer + ) + assert completer.key_completer.words == ["world", "hello", "bar", "foo"] + assert completer.key_completer.words == ["world", "hello", "bar", "foo"] + + client.pre_hook("GET bar", "GET", "bar", completer) + assert completer.key_completer.words == ["bar", "world", "hello", "foo"] + + +def test_get_server_verison_after_client(config): + Client("127.0.0.1", "6379", None) + assert re.match(r"\d+\..*", config.version) + + config.version = "Unknown" + config.no_info = True + Client("127.0.0.1", "6379", None) + assert config.version == "Unknown" + + +def test_do_help(config): + client = Client("127.0.0.1", "6379", None) + config.version = "5.0.0" + resp = client.do_help("SET") + assert resp[10] == ("", "1.0.0 (Available on your redis-server: 5.0.0)") + config.version = "2.0.0" + resp = client.do_help("cluster", "addslots") + assert resp[10] == ("", "3.0.0 (Not available on your redis-server: 2.0.0)") + + +def test_rainbow_iterator(): + "test color infinite iterator" + original_color = Rainbow.color + Rainbow.color = list(range(0, 3)) + assert list(zip(range(10), Rainbow())) == [ + (0, 0), + (1, 1), + (2, 2), + (3, 1), + (4, 0), + (5, 1), + (6, 2), + (7, 1), + (8, 0), + (9, 1), + ] + Rainbow.color = original_color + + +def test_prompt_message(iredis_client, config): + config.rainbow = False + assert prompt_message(iredis_client) == "127.0.0.1:6379[15]> " + + config.rainbow = True + assert prompt_message(iredis_client)[:3] == [ + ("#cc2244", "1"), + ("#bb4444", "2"), + ("#996644", "7"), + ] + + +def test_on_connection_error_retry(iredis_client, config): + config.retry_times = 1 + mock_connection = MagicMock() + mock_connection.read_response.side_effect = [ + redis.exceptions.ConnectionError( + "Error 61 connecting to 127.0.0.1:7788. Connection refused." + ), + "hello", + ] + original_connection = iredis_client.connection + iredis_client.connection = mock_connection + value = iredis_client.execute("None", "GET", ["foo"]) + assert value == "hello" # be rendered + + mock_connection.disconnect.assert_called_once() + mock_connection.connect.assert_called_once() + + iredis_client.connection = original_connection + + +def test_on_connection_error_retry_without_retrytimes(iredis_client, config): + config.retry_times = 0 + mock_connection = MagicMock() + mock_connection.read_response.side_effect = [ + redis.exceptions.ConnectionError( + "Error 61 connecting to 127.0.0.1:7788. Connection refused." + ), + "hello", + ] + iredis_client.connection = mock_connection + with pytest.raises(redis.exceptions.ConnectionError): + iredis_client.execute("None", "GET", ["foo"]) + + mock_connection.disconnect.assert_not_called() + mock_connection.connect.assert_not_called() + + +def test_socket_keepalive(config): + config.socket_keepalive = True + from iredis.client import Client + + newclient = Client("127.0.0.1", "6379", 0) + assert newclient.connection.socket_keepalive + + # keepalive off + config.socket_keepalive = False + + newclient = Client("127.0.0.1", "6379", 0) + assert not newclient.connection.socket_keepalive + + +def test_not_retry_on_authentication_error(iredis_client, config): + config.retry_times = 2 + mock_connection = MagicMock() + mock_connection.read_response.side_effect = [ + redis.exceptions.AuthenticationError("Authentication required."), + "hello", + ] + iredis_client.connection = mock_connection + with pytest.raises(redis.exceptions.ConnectionError): + iredis_client.execute("None", "GET", ["foo"]) + + +@pytest.mark.skipif( + "int(os.environ['REDIS_VERSION']) != 6", + reason=""" +in redis7, it will not work if you: +1. connect redis without password +2. set a password +3. auth + +the auth will fail""", +) +def test_auto_select_db_and_auth_for_reconnect_only_6(iredis_client, config): + config.retry_times = 2 + config.raw = True + next(iredis_client.send_command("select 2")) + assert iredis_client.connection.db == 2 + + resp = next(iredis_client.send_command("auth 123")) + + assert ( + b"ERROR AUTH <password> called without any " + b"password configured for the default user. " + b"Are you sure your configuration is correct?" in resp + ) + assert iredis_client.connection.password is None + + next(iredis_client.send_command("config set requirepass 'abc'")) + next(iredis_client.send_command("auth abc")) + assert iredis_client.connection.password == "abc" + assert ( + iredis_client.execute("ACL SETUSER", "default", "on", "nopass", "~*", "+@all") + == b"OK" + ) + + +@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) > 5") +def test_auto_select_db_and_auth_for_reconnect_only_5(iredis_client, config): + config.retry_times = 2 + config.raw = True + next(iredis_client.send_command("select 2")) + assert iredis_client.connection.db == 2 + + resp = next(iredis_client.send_command("auth 123")) + + assert b"Client sent AUTH, but no password is set" in resp + assert iredis_client.connection.password is None + + next(iredis_client.send_command("config set requirepass 'abc'")) + next(iredis_client.send_command("auth abc")) + assert iredis_client.connection.password == "abc" + next(iredis_client.send_command("config set requirepass ''")) + + +def test_split_shell_command(iredis_client, completer): + assert iredis_client.split_command_and_pipeline(" get json | rg . ", completer) == ( + " get json ", + "rg . ", + ) + + assert iredis_client.split_command_and_pipeline( + """ get "json | \\" hello" | rg . """, completer + ) == (""" get "json | \\" hello" """, "rg . ") + + +def test_running_with_pipeline(clean_redis, iredis_client, capfd, completer): + config.shell = True + clean_redis.set("foo", "hello \n world") + with pytest.raises(StopIteration): + next(iredis_client.send_command("get foo | grep w", completer)) + out, err = capfd.readouterr() + assert out == " world\n" + + +def test_running_with_multiple_pipeline(clean_redis, iredis_client, capfd, completer): + config.shell = True + clean_redis.set("foo", "hello world\nhello iredis") + with pytest.raises(StopIteration): + next( + iredis_client.send_command("get foo | grep hello | grep iredis", completer) + ) + out, err = capfd.readouterr() + assert out == "hello iredis\n" + + +def test_can_not_connect_on_startup(capfd): + with pytest.raises(SystemExit): + Client("localhost", "16111", 15) + out, err = capfd.readouterr() + assert "connecting to localhost:16111." in err + + +def test_peek_key_not_exist(iredis_client, clean_redis, config): + config.raw = False + peek_result = list(iredis_client.do_peek("non-exist-key")) + assert peek_result == ["non-exist-key doesn't exist."] + + +def test_iredis_with_username(): + with patch("redis.connection.Connection.connect"): + c = Client("127.0.0.1", "6379", username="abc", password="abc1") + assert c.connection.username == "abc" + assert c.connection.password == "abc1" + + +def test_peek_string(iredis_client, clean_redis): + clean_redis.set("foo", "bar") + peek_result = list(iredis_client.do_peek("foo")) + + assert peek_result[0][0] == ("class:dockey", "key: ") + assert re.match(r"string \(embstr\) mem: \d+ bytes, ttl: -1", peek_result[0][1][1]) + assert peek_result[0][2:] == [ + ("", "\n"), + ("class:dockey", "strlen: "), + ("", "3"), + ("", "\n"), + ("class:dockey", "value: "), + ("", '"bar"'), + ] + + +def test_peek_list_fetch_all(iredis_client, clean_redis): + clean_redis.lpush("mylist", *[f"hello-{index}" for index in range(5)]) + peek_result = list(iredis_client.do_peek("mylist")) + + formatted_text_rematch( + peek_result[0], + FormattedText( + [ + ("class:dockey", "key: "), + ("", r"list \(quicklist\) mem: \d+ bytes, ttl: -1"), + ("", "\n"), + ("class:dockey", "llen: "), + ("", "5"), + ("", "\n"), + ("class:dockey", "elements: "), + ("", "\n"), + ("", r"1\)"), + ("", " "), + ("class:string", '"hello-4"'), + ("", "\n"), + ("", r"2\)"), + ("", " "), + ("class:string", '"hello-3"'), + ("", "\n"), + ("", r"3\)"), + ("", " "), + ("class:string", '"hello-2"'), + ("", "\n"), + ("", r"4\)"), + ("", " "), + ("class:string", '"hello-1"'), + ("", "\n"), + ("", r"5\)"), + ("", " "), + ("class:string", '"hello-0"'), + ] + ), + ) + + +def test_peek_list_fetch_part(iredis_client, clean_redis): + clean_redis.lpush("mylist", *[f"hello-{index}" for index in range(40)]) + peek_result = list(iredis_client.do_peek("mylist")) + assert len(peek_result[0]) == 91 + + +def test_peek_set_fetch_all(iredis_client, clean_redis): + clean_redis.sadd("myset", *[f"hello-{index}" for index in range(5)]) + peek_result = list(iredis_client.do_peek("myset")) + assert len(peek_result[0]) == 27 + + +def test_peek_set_fetch_part(iredis_client, clean_redis): + clean_redis.sadd("myset", *[f"hello-{index}" for index in range(40)]) + peek_result = list(iredis_client.do_peek("myset")) + + assert peek_result[0][0] == ("class:dockey", "key: ") + assert peek_result[0][1][1].startswith("set (hashtable) mem: 2") + + +def test_peek_zset_fetch_all(iredis_client, clean_redis): + clean_redis.zadd( + "myzset", dict(zip([f"hello-{index}" for index in range(3)], range(3))) + ) + peek_result = list(iredis_client.do_peek("myzset")) + + formatted_text_rematch( + peek_result[0][0:9], + FormattedText( + [ + ("class:dockey", "key: "), + ("", rf"zset \({zset_type}\) mem: \d+ bytes, ttl: -1"), + ("", "\n"), + ("class:dockey", "zcount: "), + ("", "3"), + ("", "\n"), + ("class:dockey", "members: "), + ("", "\n"), + ("", r"1\)"), + ] + ), + ) + + +def test_peek_zset_fetch_part(iredis_client, clean_redis): + clean_redis.zadd( + "myzset", dict(zip([f"hello-{index}" for index in range(40)], range(40))) + ) + peek_result = list(iredis_client.do_peek("myzset")) + formatted_text_rematch( + peek_result[0][0:8], + FormattedText( + [ + ("class:dockey", "key: "), + ("", rf"zset \({zset_type}\) mem: \d+ bytes, ttl: -1"), + ("", "\n"), + ("class:dockey", "zcount: "), + ("", "40"), + ("", "\n"), + ("class:dockey", r"members \(first 40\): "), + ("", "\n"), + ] + ), + ) + + +def test_peek_hash_fetch_all(iredis_client, clean_redis): + for key, value in zip( + [f"hello-{index}" for index in range(3)], [f"hi-{index}" for index in range(3)] + ): + clean_redis.hset("myhash", key, value) + peek_result = list(iredis_client.do_peek("myhash")) + assert len(peek_result[0]) == 28 + + +def test_peek_hash_fetch_part(iredis_client, clean_redis): + for key, value in zip( + [f"hello-{index}" for index in range(100)], + [f"hi-{index}" for index in range(100)], + ): + clean_redis.hset("myhash", key, value) + peek_result = list(iredis_client.do_peek("myhash")) + assert len(peek_result[0]) == 707 + + +def test_peek_stream(iredis_client, clean_redis): + clean_redis.xadd("mystream", {"foo": "bar", "hello": "world"}) + peek_result = list(iredis_client.do_peek("mystream")) + + assert peek_result[0][0] == ("class:dockey", "key: ") + assert re.match( + r"stream \((stream|unknown)\) mem: 6\d\d bytes, ttl: -1", peek_result[0][1][1] + ) + assert peek_result[0][2:18] == FormattedText( + [ + ("", "\n"), + ("class:dockey", "XINFO: "), + ("", "\n"), + ("", " 1)"), + ("", " "), + ("class:string", '"length"'), + ("", "\n"), + ("", " 2)"), + ("", " "), + ("class:string", '"1"'), + ("", "\n"), + ("", " 3)"), + ("", " "), + ("class:string", '"radix-tree-keys"'), + ("", "\n"), + ("", " 4)"), + ] + ) + + +def test_mem_not_called_before_redis_4(config, iredis_client, clean_redis): + config.version = "3.2.9" + + def wrapper(func): + def execute(command_name, *args): + print(command_name) + if command_name.upper() == "MEMORY USAGE": + raise Exception("MEMORY USAGE not supported!") + return func(command_name, *args) + + return execute + + iredis_client.execute = wrapper(iredis_client.execute) + clean_redis.set("foo", "bar") + result = list(iredis_client.do_peek("foo")) + assert result[0][1] == ("", "string (embstr), ttl: -1") + + +def test_mem_not_called_when_cant_get_server_version( + config, iredis_client, clean_redis +): + config.version = None + + def wrapper(func): + def execute(command_name, *args): + print(command_name) + if command_name.upper() == "MEMORY USAGE": + raise Exception("MEMORY USAGE not supported!") + return func(command_name, *args) + + return execute + + iredis_client.execute = wrapper(iredis_client.execute) + clean_redis.set("foo", "bar") + result = list(iredis_client.do_peek("foo")) + assert result[0][1] == ("", "string (embstr), ttl: -1") + + +def test_reissue_command_on_redis_cluster(iredis_client, clean_redis): + mock_response = iredis_client.connection = MagicMock() + mock_response.read_response.side_effect = redis.exceptions.ResponseError( + "MOVED 12182 127.0.0.1:7002" + ) + iredis_client.reissue_with_redirect = MagicMock() + iredis_client.execute("set", "foo", "bar") + assert iredis_client.reissue_with_redirect.call_args == ( + ( + "MOVED 12182 127.0.0.1:7002", + "set", + "foo", + "bar", + ), + ) + + +def test_reissue_command_on_redis_cluster_with_password_in_dsn( + iredis_client, clean_redis +): + config_content = dedent( + """ + [main] + log_location = /tmp/iredis1.log + no_info=True + [alias_dsn] + cluster-7003=redis://foo:bar@127.0.0.1:7003 + """ + ) + with open("/tmp/iredisrc", "w+") as etc_config: + etc_config.write(config_content) + + config_obj = load_config_files("/tmp/iredisrc") + config.alias_dsn = config_obj["alias_dsn"] + + mock_execute_by_connection = iredis_client.execute_by_connection = MagicMock() + with patch("redis.connection.Connection.connect"): + iredis_client.reissue_with_redirect( + "MOVED 12182 127.0.0.1:7003", "set", "foo", "bar" + ) + + call_args = mock_execute_by_connection.call_args[0] + print(call_args) + assert list(call_args[1:]) == ["set", "foo", "bar"] + assert call_args[0].password == "bar" + + +def test_version_parse_for_auth(iredis_client): + """ + fix: https://github.com/laixintao/iredis/issues/418 + """ + iredis_client.auth_compat("6.1.0") + assert command2syntax["AUTH"] == "command_usernamex_password" + iredis_client.auth_compat("5.0") + assert command2syntax["AUTH"] == "command_password" + iredis_client.auth_compat("5.0.14.1") + assert command2syntax["AUTH"] == "command_password" + + +@pytest.mark.parametrize( + "info, version", + [ + ( + "# Server\r\nredis_version:df--128-NOTFOUND\r\n" + "redis_mode:standalone\r\narch_bits:64", + "df--128-NOTFOUND", + ), + ( + "# Server\r\nredis_version:6.2.5\r\n" + "redis_git_sha1:00000000\r\n" + "redis_git_dirty:0\r\n" + "redis_build_id:915e5480613bc9b6\r\n" + "redis_mode:standalone ", + "6.2.5", + ), + ( + "# Server\r\nredis_version:5.0.14.1\r\n" + "redis_git_sha1:00000000\r\nredis_git_dirty:0\r\n" + "redis_build_id:915e5480613bc9b6\r\n" + "redis_mode:standalone ", + "5.0.14.1", + ), + ], +) +def test_version_path(info, version): + with patch("iredis.client.config") as mock_config: + mock_config.no_info = True + mock_config.pager = "less" + mock_config.version = "5.0.0" + with patch("iredis.client.Client.execute") as mock_execute: + mock_execute.return_value = info + client = Client("127.0.0.1", "6379", None) + client.get_server_info() + assert mock_config.version == version + + +def test_prompt(): + c = Client() + assert str(c) == "127.0.0.1:6379> " + + c = Client(prompt="{host} {port} {db}") + assert str(c) == "127.0.0.1 6379 0" + + c = Client(prompt="{host} {port} {db} {username}") + assert str(c) == "127.0.0.1 6379 0 None" + + c = Client(prompt="{host} {port} {db} {username}", username="foo1") + assert str(c) == "127.0.0.1 6379 0 foo1" + + c = Client(prompt="{client_id} aabc") + assert re.match(r"^\d+ aabc$", str(c)) + c = Client(prompt="{client_addr} >") + assert re.match(r"^127.0.0.1:\d+ >$", str(c)) diff --git a/tests/unittests/test_completers.py b/tests/unittests/test_completers.py new file mode 100644 index 0000000..5441b0e --- /dev/null +++ b/tests/unittests/test_completers.py @@ -0,0 +1,439 @@ +from unittest.mock import MagicMock, patch + +import pendulum +from prompt_toolkit.formatted_text import FormattedText +from prompt_toolkit.completion import Completion + +from iredis.completers import MostRecentlyUsedFirstWordCompleter +from iredis.completers import IRedisCompleter, TimestampCompleter, IntegerTypeCompleter + + +def test_LUF_completer_touch(): + c = MostRecentlyUsedFirstWordCompleter(3, ["one", "two"]) + c.touch("hello") + assert c.words == ["hello", "one", "two"] + + c.touch("foo") + assert c.words == ["foo", "hello", "one"] + + c.touch("hello") + assert c.words == ["hello", "foo", "one"] + + +def test_LUF_completer_touch_words(): + c = MostRecentlyUsedFirstWordCompleter(3, []) + c.touch_words(["hello", "world", "foo", "bar"]) + assert c.words == ["bar", "foo", "world"] + + c.touch_words(["one", "two"]) + assert c.words == ["two", "one", "bar"] + + +def test_newbie_mode_complete_without_meta_dict(): + fake_document = MagicMock() + fake_document.text_before_cursor = fake_document.text = "GEOR" + completer = IRedisCompleter(hint=False) + completions = list(completer.get_completions(fake_document, None)) + assert [word.text for word in completions] == ["GEORADIUS", "GEORADIUSBYMEMBER"] + assert [word.display_meta for word in completions] == [ + FormattedText([("", "")]), + FormattedText([("", "")]), + ] + + +def test_newbie_mode_complete_with_meta_dict(): + fake_document = MagicMock() + fake_document.text_before_cursor = fake_document.text = "GEOR" + completer = IRedisCompleter(hint=True) + completions = list(completer.get_completions(fake_document, None)) + + assert sorted([completion.display_meta for completion in completions]) == [ + FormattedText( + [ + ( + "", + "Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member", # noqa + ) + ] + ), + FormattedText( + [ + ( + "", + "Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point", # noqa + ) + ] + ), + ] + + +def test_newbie_mode_complete_with_meta_dict_command_is_lowercase(): + fake_document = MagicMock() + fake_document.text_before_cursor = fake_document.text = "geor" + completer = IRedisCompleter(hint=True) + completions = list(completer.get_completions(fake_document, None)) + + assert sorted([completion.display_meta for completion in completions]) == [ + FormattedText( + [ + ( + "", + "Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member", # noqa + ) + ] + ), + FormattedText( + [ + ( + "", + "Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point", # noqa + ) + ] + ), + ] + + +def test_iredis_completer_update_for_response(): + c = IRedisCompleter() + c.update_completer_for_response( + "HGETALL", + (), + [ + b"Behave", + b"misbehave", + b"Interpret", + b"misinterpret", + b"Lead", + b"mislead", + b"Trust", + b"mistrust", + ], + ) + assert c.field_completer.words == ["Trust", "Lead", "Interpret", "Behave"] + + +def test_categoryname_completer_update_for_response(): + c = IRedisCompleter() + c.update_completer_for_response( + "ACL CAT", + (), + [b"scripting", b"watch"], + ) + assert sorted(c.catetoryname_completer.words) == ["scripting", "watch"] + c.update_completer_for_response( + "ACL CAT", + ("scripting"), + [b"foo", b"bar"], + ) + assert sorted(c.catetoryname_completer.words) == ["scripting", "watch"] + + +def test_completer_when_there_are_spaces_in_command(): + c = IRedisCompleter() + c.update_completer_for_response( + "ACL cat", + (), + [b"scripting", b"watch"], + ) + assert sorted(c.catetoryname_completer.words) == ["scripting", "watch"] + + c.update_completer_for_response( + "acl \t cat", + (), + [b"hello", b"world"], + ) + assert sorted(c.catetoryname_completer.words) == [ + "hello", + "scripting", + "watch", + "world", + ] + + +def test_iredis_completer_no_exception_for_none_response(): + c = IRedisCompleter() + c.update_completer_for_response("XPENDING", None, None) + c.update_completer_for_response("KEYS", None, None) + + +def test_group_completer(): + fake_document = MagicMock() + previous_commands = ["xgroup create abc world 123", "xgroup setid abc hello 123"] + fake_document.text = fake_document.text_before_cursor = "XGROUP DESTROY key " + completer = IRedisCompleter() + for command in previous_commands: + completer.update_completer_for_input(command) + completions = list(completer.get_completions(fake_document, None)) + assert completions == [ + Completion( + text="hello", + start_position=0, + display=FormattedText([("", "hello")]), + display_meta=FormattedText([("", "")]), + ), + Completion( + text="world", + start_position=0, + display=FormattedText([("", "world")]), + display_meta=FormattedText([("", "")]), + ), + ] + + +@patch("iredis.completers.pendulum.now") +def test_timestamp_completer_humanize_time_completion(fake_now): + fake_now.return_value = pendulum.from_timestamp(1578487013) + c = TimestampCompleter(is_milliseconds=True, future_time=False) + + fake_document = MagicMock() + fake_document.text = fake_document.text_before_cursor = "30" + completions = list(c.get_completions(fake_document, None)) + + assert completions == [ + Completion( + text="1575895013000", + start_position=-2, + display=FormattedText([("", "1575895013000")]), + display_meta="30 days ago (2019-12-09 12:36:53)", + ), + Completion( + text="1578379013000", + start_position=-2, + display=FormattedText([("", "1578379013000")]), + display_meta="30 hours ago (2020-01-07 06:36:53)", + ), + Completion( + text="1578485213000", + start_position=-2, + display=FormattedText([("", "1578485213000")]), + display_meta="30 minutes ago (2020-01-08 12:06:53)", + ), + Completion( + text="1578486983000", + start_position=-2, + display=FormattedText([("", "1578486983000")]), + display_meta="30 seconds ago (2020-01-08 12:36:23)", + ), + ] + + # No plural + fake_document.text = fake_document.text_before_cursor = "1" + completions = list(c.get_completions(fake_document, None)) + + assert completions == [ + Completion( + text="1546951013000", + start_position=-1, + display=FormattedText([("", "1546951013000")]), + display_meta="1 year ago (2019-01-08 12:36:53)", + ), + Completion( + text="1575808613000", + start_position=-1, + display=FormattedText([("", "1575808613000")]), + display_meta="1 month ago (2019-12-08 12:36:53)", + ), + Completion( + text="1578400613000", + start_position=-1, + display=FormattedText([("", "1578400613000")]), + display_meta="1 day ago (2020-01-07 12:36:53)", + ), + Completion( + text="1578483413000", + start_position=-1, + display=FormattedText([("", "1578483413000")]), + display_meta="1 hour ago (2020-01-08 11:36:53)", + ), + Completion( + text="1578486953000", + start_position=-1, + display=FormattedText([("", "1578486953000")]), + display_meta="1 minute ago (2020-01-08 12:35:53)", + ), + Completion( + text="1578487012000", + start_position=-1, + display=FormattedText([("", "1578487012000")]), + display_meta="1 second ago (2020-01-08 12:36:52)", + ), + ] + + +@patch("iredis.completers.pendulum.now") +def test_timestamp_completer_humanize_time_completion_seconds(fake_now): + fake_now.return_value = pendulum.from_timestamp(1578487013) + c = TimestampCompleter(is_milliseconds=False, future_time=False) + + fake_document = MagicMock() + fake_document.text = fake_document.text_before_cursor = "30" + completions = list(c.get_completions(fake_document, None)) + + assert completions == [ + Completion( + text="1575895013", + start_position=-2, + display=FormattedText([("", "1575895013")]), + display_meta="30 days ago (2019-12-09 12:36:53)", + ), + Completion( + text="1578379013", + start_position=-2, + display=FormattedText([("", "1578379013")]), + display_meta="30 hours ago (2020-01-07 06:36:53)", + ), + Completion( + text="1578485213", + start_position=-2, + display=FormattedText([("", "1578485213")]), + display_meta="30 minutes ago (2020-01-08 12:06:53)", + ), + Completion( + text="1578486983", + start_position=-2, + display=FormattedText([("", "1578486983")]), + display_meta="30 seconds ago (2020-01-08 12:36:23)", + ), + ] + + +@patch("iredis.completers.pendulum.now") +def test_timestamp_completer_humanize_time_completion_seconds_future_time(fake_now): + fake_now.return_value = pendulum.from_timestamp(1578487013) + c = TimestampCompleter(is_milliseconds=False, future_time=True) + + fake_document = MagicMock() + fake_document.text = fake_document.text_before_cursor = "30" + completions = list(c.get_completions(fake_document, None)) + + print(completions) + for c in completions: + print(c.text) + print(c.display) + print(c.display_meta) + assert completions == [ + Completion( + text="1578487043", + start_position=-2, + display=FormattedText([("", "1578487043")]), + display_meta="30 seconds later (2020-01-08 12:37:23)", + ), + Completion( + text="1578488813", + start_position=-2, + display=FormattedText([("", "1578488813")]), + display_meta="30 minutes later (2020-01-08 13:06:53)", + ), + Completion( + text="1578595013", + start_position=-2, + display=FormattedText([("", "1578595013")]), + display_meta="30 hours later (2020-01-09 18:36:53)", + ), + Completion( + text="1581079013", + start_position=-2, + display=FormattedText([("", "1581079013")]), + display_meta="30 days later (2020-02-07 12:36:53)", + ), + ] + + +def test_timestamp_completer_datetime_format_time_completion(): + c = TimestampCompleter(is_milliseconds=True, future_time=False) + fake_document = MagicMock() + fake_document.text = fake_document.text_before_cursor = "2020-02-07" + completions = list(c.get_completions(fake_document, None)) + + assert completions == [ + Completion( + text="1581033600000", + start_position=-10, + display=FormattedText([("", "1581033600000")]), + display_meta="2020-02-07T00:00:00+00:00", + ) + ] + + +def test_integer_type_completer(): + c = IntegerTypeCompleter() + fake_document = MagicMock() + fake_document.text = fake_document.get_word_before_cursor.return_value = "i" + completions = list(c.get_completions(fake_document, None)) + assert len(completions) == 64 + + fake_document.text = fake_document.get_word_before_cursor.return_value = "u" + completions = list(c.get_completions(fake_document, None)) + assert len(completions) == 63 + + c.touch("u4") + assert list(c.get_completions(fake_document, None))[0].text == "u4" + + +def test_completion_casing(): + c = IRedisCompleter(completion_casing="auto") + fake_document = MagicMock() + fake_document.text = fake_document.text_before_cursor = "ge" + assert [ + completion.text for completion in c.get_completions(fake_document, None) + ] == [ + "get", + "getex", + "getset", + "getdel", + "getbit", + "geopos", + "geoadd", + "geohash", + "geodist", + "getrange", + "geosearch", + "georadius", + "geosearchstore", + "georadiusbymember", + ] + + c = IRedisCompleter(completion_casing="auto") + fake_document.text = fake_document.text_before_cursor = "GET" + assert [ + completion.text for completion in c.get_completions(fake_document, None) + ] == ["GET", "GETEX", "GETSET", "GETDEL", "GETBIT", "GETRANGE"] + + c = IRedisCompleter(completion_casing="upper") + fake_document.text = fake_document.text_before_cursor = "get" + assert [ + completion.text for completion in c.get_completions(fake_document, None) + ] == ["GET", "GETEX", "GETSET", "GETDEL", "GETBIT", "GETRANGE"] + + c = IRedisCompleter(completion_casing="lower") + fake_document.text = fake_document.text_before_cursor = "GET" + assert [ + completion.text for completion in c.get_completions(fake_document, None) + ] == ["get", "getex", "getset", "getdel", "getbit", "getrange"] + + +def test_username_completer(): + completer = IRedisCompleter() + completer.update_completer_for_input("acl deluser laixintao") + completer.update_completer_for_input("acl deluser antirez") + + fake_document = MagicMock() + fake_document.text_before_cursor = fake_document.text = "acl deluser " + completions = list(completer.get_completions(fake_document, None)) + assert sorted([completion.text for completion in completions]) == [ + "antirez", + "laixintao", + ] + + +def test_username_touch_for_response(): + c = IRedisCompleter() + c.update_completer_for_response( + "acl users", + (), + [b"hello", b"world"], + ) + assert sorted(c.username_completer.words) == [ + "hello", + "world", + ] diff --git a/tests/unittests/test_entry.py b/tests/unittests/test_entry.py new file mode 100644 index 0000000..912aabf --- /dev/null +++ b/tests/unittests/test_entry.py @@ -0,0 +1,295 @@ +import pytest +import tempfile +from unittest.mock import patch +from prompt_toolkit.formatted_text import FormattedText + +from iredis.entry import ( + gather_args, + parse_url, + SkipAuthFileHistory, + write_result, + is_too_tall, +) + +from iredis.utils import DSN + + +@pytest.mark.parametrize( + "is_tty,raw_arg_is_raw,final_config_is_raw", + [ + (True, None, False), + (True, True, True), + (True, False, False), + (False, None, True), + (False, True, True), + (False, False, True), # not tty + ], +) +def test_command_entry_tty(is_tty, raw_arg_is_raw, final_config_is_raw, config): + # is tty + raw -> raw + with patch("sys.stdout.isatty") as patch_tty: + + patch_tty.return_value = is_tty + if raw_arg_is_raw is None: + call = ["iredis"] + elif raw_arg_is_raw is True: + call = ["iredis", "--raw"] + elif raw_arg_is_raw is False: + call = ["iredis", "--no-raw"] + else: + raise Exception() + gather_args.main(call, standalone_mode=False) + assert config.raw == final_config_is_raw + + +def test_disable_pager(): + from iredis.config import config + + gather_args.main(["iredis", "--decode", "utf-8"], standalone_mode=False) + assert config.enable_pager + + gather_args.main(["iredis", "--no-pager"], standalone_mode=False) + assert not config.enable_pager + + +def test_command_with_decode_utf_8(): + from iredis.config import config + + gather_args.main(["iredis", "--decode", "utf-8"], standalone_mode=False) + assert config.decode == "utf-8" + + gather_args.main(["iredis"], standalone_mode=False) + assert config.decode == "" + + +def test_command_with_shell_pipeline(): + from iredis.config import config + + gather_args.main(["iredis", "--no-shell"], standalone_mode=False) + assert config.shell is False + + gather_args.main(["iredis"], standalone_mode=False) + assert config.shell is True + + +def test_command_shell_options_higher_priority(): + from iredis.config import config + from textwrap import dedent + + config_content = dedent( + """ + [main] + shell = False + """ + ) + with open("/tmp/iredisrc", "w+") as etc_config: + etc_config.write(config_content) + + gather_args.main(["iredis", "--iredisrc", "/tmp/iredisrc"], standalone_mode=False) + assert config.shell is False + + gather_args.main( + ["iredis", "--shell", "--iredisrc", "/tmp/iredisrc"], standalone_mode=False + ) + assert config.shell is True + + +@pytest.mark.parametrize( + "url,dsn", + [ + ( + "redis://localhost:6379/3", + DSN( + scheme="redis", + host="localhost", + port=6379, + path=None, + db=3, + username=None, + password=None, + verify_ssl=None, + ), + ), + ( + "redis://localhost:6379", + DSN( + scheme="redis", + host="localhost", + port=6379, + path=None, + db=0, + username=None, + password=None, + verify_ssl=None, + ), + ), + ( + "rediss://localhost:6379", + DSN( + scheme="rediss", + host="localhost", + port=6379, + path=None, + db=0, + username=None, + password=None, + verify_ssl=None, + ), + ), + ( + "rediss://localhost:6379/1?ssl_cert_reqs=optional", + DSN( + scheme="rediss", + host="localhost", + port=6379, + path=None, + db=1, + username=None, + password=None, + verify_ssl="optional", + ), + ), + ( + "redis://username:password@localhost:6379", + DSN( + scheme="redis", + host="localhost", + port=6379, + path=None, + db=0, + username="username", + password="password", + verify_ssl=None, + ), + ), + ( + "redis://:password@localhost:6379", + DSN( + scheme="redis", + host="localhost", + port=6379, + path=None, + db=0, + username=None, + password="password", + verify_ssl=None, + ), + ), + ( + "redis://username@localhost:12345", + DSN( + scheme="redis", + host="localhost", + port=12345, + path=None, + db=0, + username="username", + password=None, + verify_ssl=None, + ), + ), + ( + # query string won't work for redis:// + "redis://username@localhost:6379?db=2", + DSN( + scheme="redis", + host="localhost", + port=6379, + path=None, + db=0, + username="username", + password=None, + verify_ssl=None, + ), + ), + ( + "unix://username:password2@/tmp/to/socket.sock?db=0", + DSN( + scheme="unix", + host=None, + port=None, + path="/tmp/to/socket.sock", + db=0, + username="username", + password="password2", + verify_ssl=None, + ), + ), + ( + "unix://:password3@/path/to/socket.sock", + DSN( + scheme="unix", + host=None, + port=None, + path="/path/to/socket.sock", + db=0, + username=None, + password="password3", + verify_ssl=None, + ), + ), + ( + "unix:///tmp/socket.sock", + DSN( + scheme="unix", + host=None, + port=None, + path="/tmp/socket.sock", + db=0, + username=None, + password=None, + verify_ssl=None, + ), + ), + ], +) +def test_parse_url(url, dsn): + assert parse_url(url) == dsn + + +@pytest.mark.parametrize( + "command,record", + [ + ("set foo bar", True), + ("set auth bar", True), + ("auth 123", False), + ("AUTH hello", False), + ("AUTH hello world", False), + ], +) +def test_history(command, record): + f = tempfile.TemporaryFile("w+") + history = SkipAuthFileHistory(f.name) + assert history._loaded_strings == [] + history.append_string(command) + assert (command in history._loaded_strings) is record + + +def test_write_result_for_str(capsys): + write_result("hello") + captured = capsys.readouterr() + assert captured.out == "hello\n" + + +def test_write_result_for_bytes(capsys): + write_result(b"hello") + captured = capsys.readouterr() + assert captured.out == "hello\n" + + +def test_write_result_for_formatted_text(): + ft = FormattedText([("class:keyword", "set"), ("class:string", "hello world")]) + # just this test not raise means ok + write_result(ft) + + +def test_is_too_tall_for_formatted_text(): + ft = FormattedText([("class:key", f"key-{index}\n") for index in range(21)]) + assert is_too_tall(ft, 20) + assert not is_too_tall(ft, 22) + + +def test_is_too_tall_for_bytes(): + byte_text = b"".join([b"key\n" for index in range(21)]) + assert is_too_tall(byte_text, 20) + assert not is_too_tall(byte_text, 23) diff --git a/tests/unittests/test_markdown_doc_render.py b/tests/unittests/test_markdown_doc_render.py new file mode 100644 index 0000000..0538299 --- /dev/null +++ b/tests/unittests/test_markdown_doc_render.py @@ -0,0 +1,28 @@ +""" +This test ensures that all of redis-doc's markdown can be rendered. +Why do we need this? +see: +https://github.com/antirez/redis-doc/commit/02b3d1a345093c1794fd86273e9d516fffd3b819 +""" + +import pytest +from importlib_resources import read_text + +from iredis.commands import commands_summary +from iredis.data import commands as commands_data +from iredis.markdown import render + + +doc_files = [] +for command, info in commands_summary.items(): + command_docs_name = "-".join(command.split()).lower() + if info["group"] == "iredis": + continue + doc_files.append(f"{command_docs_name}.md") + + +@pytest.mark.parametrize("filename", doc_files) +def test_markdown_render(filename): + print(filename) + doc = read_text(commands_data, filename) + render(doc) diff --git a/tests/unittests/test_render_functions.py b/tests/unittests/test_render_functions.py new file mode 100644 index 0000000..30b328e --- /dev/null +++ b/tests/unittests/test_render_functions.py @@ -0,0 +1,492 @@ +import os +import time +from prompt_toolkit.formatted_text import FormattedText +from iredis import renders +from iredis.config import config +from iredis.completers import IRedisCompleter + + +def strip_formatted_text(formatted_text): + return "".join(text[1] for text in formatted_text) + + +def test_render_simple_string_raw_using_raw_render(): + assert renders.OutputRender.render_raw(b"OK") == b"OK" + assert renders.OutputRender.render_raw(b"BUMPED 1") == b"BUMPED 1" + assert renders.OutputRender.render_raw(b"STILL 1") == b"STILL 1" + + +def test_render_simple_string(): + assert renders.OutputRender.render_simple_string(b"OK") == FormattedText( + [("class:success", "OK")] + ) + assert renders.OutputRender.render_simple_string(b"BUMPED 1") == FormattedText( + [("class:success", "BUMPED 1")] + ) + assert renders.OutputRender.render_simple_string(b"STILL 1") == FormattedText( + [("class:success", "STILL 1")] + ) + + +def test_render_list_index(): + raw = ["hello", "world", "foo"] + out = renders._render_list([item.encode() for item in raw], raw) + out = strip_formatted_text(out) + assert isinstance(out, str) + assert "3)" in out + assert "1)" in out + assert "4)" not in out + + +def test_render_list_index_const_width(): + raw = ["hello"] * 100 + out = renders._render_list([item.encode() for item in raw], raw) + out = strip_formatted_text(out) + assert isinstance(out, str) + assert " 1)" in out + assert "\n100)" in out + + raw = ["hello"] * 1000 + out = renders._render_list([item.encode() for item in raw], raw) + out = strip_formatted_text(out) + assert " 1)" in out + assert "\n 999)" in out + assert "\n1000)" in out + + raw = ["hello"] * 10 + out = renders._render_list([item.encode() for item in raw], raw) + out = strip_formatted_text(out) + assert " 1)" in out + assert "\n 9)" in out + assert "\n10)" in out + + +def test_render_list_using_raw_render(): + raw = ["hello", "world", "foo"] + out = renders.OutputRender.render_raw([item.encode() for item in raw]) + assert b"hello\nworld\nfoo" == out + + +def test_render_list_with_nil_init(): + raw = [b"hello", None, b"world"] + out = renders.OutputRender.render_list(raw) + out = strip_formatted_text(out) + assert out == '1) "hello"\n2) (nil)\n3) "world"' + + +def test_render_list_with_nil_init_while_config_raw(): + raw = [b"hello", None, b"world"] + out = renders.OutputRender.render_raw(raw) + assert out == b"hello\n\nworld" + + +def test_render_list_with_empty_list_raw(): + raw = [] + out = renders.OutputRender.render_raw(raw) + assert out == b"" + + +def test_render_list_with_empty_list(): + raw = [] + out = renders.OutputRender.render_list(raw) + out = strip_formatted_text(out) + assert out == "(empty list or set)" + + +def test_ensure_str_bytes(): + assert renders.ensure_str(b"hello world") == r"hello world" + assert renders.ensure_str(b"hello'world") == r"hello'world" + assert renders.ensure_str("你好".encode()) == r"\xe4\xbd\xa0\xe5\xa5\xbd" + + +def test_double_quotes(): + assert renders.double_quotes('hello"world') == r'"hello\"world"' + assert renders.double_quotes('"hello\\world"') == '"\\"hello\\world\\""' + + assert renders.double_quotes("'") == '"\'"' + assert renders.double_quotes("\\") == '"\\"' + assert renders.double_quotes('"') == '"\\""' + + +def test_render_int(): + config.raw = False + assert renders.OutputRender.render_int(12) == FormattedText( + [("class:type", "(integer) "), ("", "12")] + ) + + +def test_render_int_raw(): + assert renders.OutputRender.render_raw(12) == b"12" + + +def test_render_list_or_string(): + assert renders.OutputRender.render_list_or_string("") == '""' + assert renders.OutputRender.render_list_or_string("foo") == '"foo"' + assert renders.OutputRender.render_list_or_string( + [b"foo", b"bar"] + ) == FormattedText( + [ + ("", "1)"), + ("", " "), + ("class:string", '"foo"'), + ("", "\n"), + ("", "2)"), + ("", " "), + ("class:string", '"bar"'), + ] + ) + + +def test_render_list_or_string_nil_and_empty_list(): + assert renders.OutputRender.render_list_or_string(None) == FormattedText( + [("class:type", "(nil)")] + ) + assert renders.OutputRender.render_list_or_string([]) == FormattedText( + [("class:type", "(empty list or set)")] + ) + + +def test_render_raw_nil_and_empty_list(): + assert renders.OutputRender.render_raw(None) == b"" + assert renders.OutputRender.render_raw([]) == b"" + + +def test_list_or_string(): + config.raw = False + assert renders.OutputRender.render_string_or_int(b"10.1") == '"10.1"' + assert renders.OutputRender.render_string_or_int(3) == FormattedText( + [("class:type", "(integer) "), ("", "3")] + ) + + +def test_command_keys(): + completer = IRedisCompleter() + completer.key_completer.words = [] + config.raw = False + rendered = renders.OutputRender.command_keys([b"cat", b"dog", b"banana"]) + completer.update_completer_for_response("KEYS", None, [b"cat", b"dog", b"banana"]) + + assert rendered == FormattedText( + [ + ("", "1)"), + ("", " "), + ("class:key", '"cat"'), + ("", "\n"), + ("", "2)"), + ("", " "), + ("class:key", '"dog"'), + ("", "\n"), + ("", "3)"), + ("", " "), + ("class:key", '"banana"'), + ] + ) + assert completer.key_completer.words == ["banana", "dog", "cat"] + + +def test_command_scan(): + completer = IRedisCompleter() + completer.key_completer.words = [] + config.raw = False + rendered = renders.OutputRender.command_scan( + [b"44", [b"a", b"key:__rand_int__", b"dest", b" a"]] + ) + completer.update_completer_for_response( + "SCAN", ("0",), [b"44", [b"a", b"key:__rand_int__", b"dest", b" a"]] + ) + + assert rendered == FormattedText( + [ + ("class:type", "(cursor) "), + ("class:integer", "44"), + ("", "\n"), + ("", "1)"), + ("", " "), + ("class:key", '"a"'), + ("", "\n"), + ("", "2)"), + ("", " "), + ("class:key", '"key:__rand_int__"'), + ("", "\n"), + ("", "3)"), + ("", " "), + ("class:key", '"dest"'), + ("", "\n"), + ("", "4)"), + ("", " "), + ("class:key", '" a"'), + ] + ) + assert completer.key_completer.words == [" a", "dest", "key:__rand_int__", "a"] + + +def test_command_sscan(): + completer = IRedisCompleter() + completer.member_completer.words = [] + rendered = renders.OutputRender.command_sscan( + [b"44", [b"a", b"member:__rand_int__", b"dest", b" a"]] + ) + completer.update_completer_for_response( + "SSCAN", (0), [b"44", [b"a", b"member:__rand_int__", b"dest", b" a"]] + ) + + assert rendered == FormattedText( + [ + ("class:type", "(cursor) "), + ("class:integer", "44"), + ("", "\n"), + ("", "1)"), + ("", " "), + ("class:member", '"a"'), + ("", "\n"), + ("", "2)"), + ("", " "), + ("class:member", '"member:__rand_int__"'), + ("", "\n"), + ("", "3)"), + ("", " "), + ("class:member", '"dest"'), + ("", "\n"), + ("", "4)"), + ("", " "), + ("class:member", '" a"'), + ] + ) + assert completer.member_completer.words == [ + " a", + "dest", + "member:__rand_int__", + "a", + ] + + +def test_command_sscan_config_raw(): + completer = IRedisCompleter() + completer.member_completer.words = [] + rendered = renders.OutputRender.render_raw( + [b"44", [b"a", b"member:__rand_int__", b"dest", b" a"]] + ) + completer.update_completer_for_response( + "SSCAN", (0), [b"44", [b"a", b"member:__rand_int__", b"dest", b" a"]] + ) + + assert rendered == b"44\na\nmember:__rand_int__\ndest\n a" + assert completer.member_completer.words == [ + " a", + "dest", + "member:__rand_int__", + "a", + ] + + +def test_render_members(): + completer = IRedisCompleter() + completer.member_completer.words = [] + config.withscores = True + resp = [b"duck", b"667", b"camel", b"708"] + rendered = renders.OutputRender.render_members(resp) + completer.update_completer_for_response("ZRANGE", ("foo", "0", "-1"), resp) + + assert rendered == FormattedText( + [ + ("", "1)"), + ("", " "), + ("class:integer", "667 "), + ("class:member", '"duck"'), + ("", "\n"), + ("", "2)"), + ("", " "), + ("class:integer", "708 "), + ("class:member", '"camel"'), + ] + ) + assert completer.member_completer.words == ["camel", "duck"] + + +def test_render_members_config_raw(): + completer = IRedisCompleter() + completer.member_completer.words = [] + config.withscores = True + resp = [b"duck", b"667", b"camel", b"708"] + rendered = renders.OutputRender.render_raw(resp) + completer.update_completer_for_response("ZRANGE", (), resp) + + assert rendered == b"duck\n667\ncamel\n708" + assert completer.member_completer.words == ["camel", "duck"] + + +def test_render_unixtime_config_raw(): + # fake the timezone and reload + os.environ["TZ"] = "Asia/Shanghai" + time.tzset() + rendered = renders.OutputRender.render_unixtime(1570469891) + + assert rendered == FormattedText( + [ + ("class:type", "(integer) "), + ("", "1570469891"), + ("", "\n"), + ("class:type", "(local time)"), + ("", " "), + ("", "2019-10-08 01:38:11"), + ] + ) + + +def test_render_unixtime(): + rendered = renders.OutputRender.render_raw(1570469891) + + assert rendered == b"1570469891" + + +def test_bulk_string_reply(): + assert renders.OutputRender.render_bulk_string(b"'\"") == '''"'\\""''' + + +def test_bulk_string_reply_raw(): + assert renders.OutputRender.render_raw(b"hello") == b"hello" + + +def test_render_bulk_string_decoded(): + EXPECTED_RENDER = """# Server\nredis_version:5.0.5\nredis_git_sha1:00000000\nredis_git_dirty:0\nredis_build_id:31cd6e21ec924b46""" # noqa + _input = b"# Server\r\nredis_version:5.0.5\r\nredis_git_sha1:00000000\r\nredis_git_dirty:0\r\nredis_build_id:31cd6e21ec924b46" # noqa + assert renders.OutputRender.render_bulk_string_decode(_input) == EXPECTED_RENDER + + +def test_render_bulk_string_decoded_with_decoded_utf8(): + EXPECTED_RENDER = """# Server\nredis_version:5.0.5\nredis_git_sha1:00000000\nredis_git_dirty:0\nredis_build_id:31cd6e21ec924b46""" # noqa + _input = "# Server\r\nredis_version:5.0.5\r\nredis_git_sha1:00000000\r\nredis_git_dirty:0\r\nredis_build_id:31cd6e21ec924b46" # noqa + assert renders.OutputRender.render_bulk_string_decode(_input) == EXPECTED_RENDER + + +def test_render_time(): + value = [b"1571305643", b"765481"] + assert renders.OutputRender.render_time(value) == FormattedText( + [ + ("class:type", "(unix timestamp) "), + ("", "1571305643"), + ("", "\n"), + ("class:type", "(millisecond) "), + ("", "765481"), + ("", "\n"), + ("class:type", "(convert to local timezone) "), + ("", "2019-10-17 17:47:23.765481"), + ] + ) + + assert renders.OutputRender.render_raw(value) == b"1571305643\n765481" + + +def test_render_nested_pairs(): + text = [ + b"peak.allocated", + 10160336, + b"lua.caches", + 0, + b"db.0", + [b"overhead.hashtable.main", 648, b"overhead.hashtable.expires", 32], + b"db.1", + [b"overhead.hashtable.main", 112, b"overhead.hashtable.expires", 32], + b"fragmentation", + b"0.062980629503726959", + b"fragmentation.bytes", + -9445680, + ] + + assert renders.OutputRender.render_raw(text) == ( + b"peak.allocated\n10160336\nlua.caches\n0\ndb.0\noverhead.hashtable.main\n64" + b"8\noverhead.hashtable.expires\n32\ndb.1\noverhead.hashtable.main\n112\nove" + b"rhead.hashtable.expires\n32\nfragmentation\n0.062980629503726959\nfragmentat" + b"ion.bytes\n-9445680" + ) + + assert renders.OutputRender.render_nested_pair(text) == FormattedText( + [ + ("class:string", "peak.allocated: "), + ("class:value", "10160336"), + ("", "\n"), + ("class:string", "lua.caches: "), + ("class:value", "0"), + ("", "\n"), + ("class:string", "db.0: "), + ("", "\n"), + ("class:string", " overhead.hashtable.main: "), + ("class:value", "648"), + ("", "\n"), + ("class:string", " overhead.hashtable.expires: "), + ("class:value", "32"), + ("", "\n"), + ("class:string", "db.1: "), + ("", "\n"), + ("class:string", " overhead.hashtable.main: "), + ("class:value", "112"), + ("", "\n"), + ("class:string", " overhead.hashtable.expires: "), + ("class:value", "32"), + ("", "\n"), + ("class:string", "fragmentation: "), + ("class:value", "0.062980629503726959"), + ("", "\n"), + ("class:string", "fragmentation.bytes: "), + ("class:value", "-9445680"), + ] + ) + + +def test_render_nested_list(): + text = [[b"get", 2, [b"readonly", b"fast"], 1, 1, 1]] + assert renders.OutputRender.render_list(text) == FormattedText( + [ + ("", "1)"), + ("", " "), + ("", "1)"), + ("", " "), + ("class:string", '"get"'), + ("", "\n"), + ("", " "), + ("", "2)"), + ("", " "), + ("class:string", '"2"'), + ("", "\n"), + ("", " "), + ("", "3)"), + ("", " "), + ("", "1)"), + ("", " "), + ("class:string", '"readonly"'), + ("", "\n"), + ("", " "), + ("", "2)"), + ("", " "), + ("class:string", '"fast"'), + ("", "\n"), + ("", " "), + ("", "4)"), + ("", " "), + ("class:string", '"1"'), + ("", "\n"), + ("", " "), + ("", "5)"), + ("", " "), + ("class:string", '"1"'), + ("", "\n"), + ("", " "), + ("", "6)"), + ("", " "), + ("class:string", '"1"'), + ] + ) + + +def test_render_bytes(config): + assert renders.OutputRender.render_bytes(b"bytes\n") == b"bytes" + + +def test_render_bytes_raw(config): + assert renders.OutputRender.render_raw(b"bytes\n") == b"bytes\n" + + +def test_render_help(config): + assert renders.OutputRender.render_help([b"foo", b"bar"]) == FormattedText( + [("class:string", "foo\nbar")] + ) diff --git a/tests/unittests/test_utils.py b/tests/unittests/test_utils.py new file mode 100644 index 0000000..98ea8db --- /dev/null +++ b/tests/unittests/test_utils.py @@ -0,0 +1,122 @@ +import re +import time +import pytest +from unittest.mock import patch + +from iredis.utils import timer, strip_quote_args +from iredis.commands import split_command_args, split_unknown_args +from iredis.utils import command_syntax +from iredis.style import STYLE +from iredis.exceptions import InvalidArguments, AmbiguousCommand +from iredis.commands import commands_summary +from prompt_toolkit import print_formatted_text + + +def test_timer(): + with patch("iredis.utils.logger") as mock_logger: + timer("foo") + time.sleep(0.1) + timer("bar") + mock_logger.debug.assert_called() + args, kwargs = mock_logger.debug.call_args + matched = re.match(r"\[timer (\d)\] (0\.\d+) -> bar", args[0]) + + assert matched.group(1) == str(3) + assert 0.1 <= float(matched.group(2)) <= 0.2 + + # --- test again --- + timer("foo") + time.sleep(0.2) + timer("bar") + mock_logger.debug.assert_called() + args, kwargs = mock_logger.debug.call_args + matched = re.match(r"\[timer (\d)\] (0\.\d+) -> bar", args[0]) + + assert matched.group(1) == str(5) + assert 0.2 <= float(matched.group(2)) <= 0.3 + + +@pytest.mark.parametrize( + "test_input,expected", + [ + ("hello world", ["hello", "world"]), + ("'hello world'", ["hello world"]), + ('''hello"world"''', ["helloworld"]), + (r'''hello\"world"''', [r"hello\world"]), + (r'"\\"', [r"\\"]), + (r"\\", [r"\\"]), + (r"\abcd ef", [r"\abcd", "ef"]), + # quotes in quotes + (r""" 'hello"world' """, ['hello"world']), + (r""" "hello'world" """, ["hello'world"]), + (r""" 'hello\'world'""", ["hello'world"]), + (r""" "hello\"world" """, ['hello"world']), + (r"''", [""]), # set foo "" is a legal command + (r'""', [""]), # set foo "" is a legal command + (r"\\", ["\\\\"]), # backslash are legal + ("\\hello\\", ["\\hello\\"]), # backslash are legal + ], +) +def test_stripe_quote_escape_in_quote(test_input, expected): + assert list(strip_quote_args(test_input)) == expected + + +@pytest.mark.parametrize( + "command,expected,args", + [ + ("GET a", "GET", ["a"]), + ("cluster info", "cluster info", []), + ("getbit foo 17", "getbit", ["foo", "17"]), + ("command ", "command", []), + (" command count ", "command count", []), + (" command count ", "command count", []), # command with multi space + (" command count ' hello world'", "command count", [" hello world"]), + ("set foo 'hello world'", "set", ["foo", "hello world"]), + ], +) +def test_split_commands(command, expected, args): + parsed_command, parsed_args = split_command_args(command) + assert expected == parsed_command + assert args == parsed_args + + +def test_split_commands_fail_on_unknown_command(): + with pytest.raises(InvalidArguments): + split_command_args("FOO BAR") + + +@pytest.mark.parametrize( + "command", + ["command in", "command in", "Command in", "COMMAND in"], +) +def test_split_commands_fail_on_partially_input(command): + with pytest.raises(AmbiguousCommand): + split_command_args(command) + + +def test_split_commands_fail_on_unfinished_command(): + with pytest.raises(InvalidArguments): + split_command_args("setn") + + +def test_render_bottom_with_command_json(): + for command, info in commands_summary.items(): + print_formatted_text(command_syntax(command, info), style=STYLE) + + +@pytest.mark.parametrize( + "raw,command,args", + [ + ("abc 123", "abc", ["123"]), + ("abc", "abc", []), + ("abc foo bar", "abc", ["foo", "bar"]), + ("abc 'foo bar'", "abc", ["foo bar"]), + ('abc "foo bar"', "abc", ["foo bar"]), + ('abc "foo bar" 3 hello', "abc", ["foo bar", "3", "hello"]), + ('abc "foo \nbar"', "abc", ["foo \nbar"]), + ], +) +def test_split_unknown_commands(raw, command, args): + parsed_command, parsed_args = split_unknown_args(raw) + assert command == parsed_command + assert args == parsed_args |