├── .bumpversion.cfg ├── .dockerignore ├── .flake8 ├── .github ├── FUNDING.yml └── workflows │ ├── release.yaml │ ├── test-binary-build.yaml │ └── test.yaml ├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── Dockerfile ├── LICENSE ├── README.md ├── docs ├── assets │ ├── color.css │ ├── demo.cast │ ├── demo.svg │ ├── logo.png │ └── render.md ├── cloudshell │ └── run-in-docker.txt └── update-redis-doc.md ├── iredis ├── __init__.py ├── bottom.py ├── client.py ├── commands.py ├── completers.py ├── config.py ├── data │ ├── __init__.py │ ├── command_syntax.csv │ ├── commands.json │ ├── commands │ │ ├── __init__.py │ │ ├── _index.md │ │ ├── acl-cat.md │ │ ├── acl-deluser.md │ │ ├── acl-dryrun.md │ │ ├── acl-genpass.md │ │ ├── acl-getuser.md │ │ ├── acl-help.md │ │ ├── acl-list.md │ │ ├── acl-load.md │ │ ├── acl-log.md │ │ ├── acl-save.md │ │ ├── acl-setuser.md │ │ ├── acl-users.md │ │ ├── acl-whoami.md │ │ ├── acl.md │ │ ├── append.md │ │ ├── asking.md │ │ ├── auth.md │ │ ├── bgrewriteaof.md │ │ ├── bgsave.md │ │ ├── bitcount.md │ │ ├── bitfield.md │ │ ├── bitfield_ro.md │ │ ├── bitop.md │ │ ├── bitpos.md │ │ ├── blmove.md │ │ ├── blmpop.md │ │ ├── blpop.md │ │ ├── brpop.md │ │ ├── brpoplpush.md │ │ ├── bzmpop.md │ │ ├── bzpopmax.md │ │ ├── bzpopmin.md │ │ ├── client-caching.md │ │ ├── client-getname.md │ │ ├── client-getredir.md │ │ ├── client-help.md │ │ ├── client-id.md │ │ ├── client-info.md │ │ ├── client-kill.md │ │ ├── client-list.md │ │ ├── client-no-evict.md │ │ ├── client-pause.md │ │ ├── client-reply.md │ │ ├── client-setname.md │ │ ├── client-tracking.md │ │ ├── client-trackinginfo.md │ │ ├── client-unblock.md │ │ ├── client-unpause.md │ │ ├── client.md │ │ ├── cluster-addslots.md │ │ ├── cluster-addslotsrange.md │ │ ├── cluster-bumpepoch.md │ │ ├── cluster-count-failure-reports.md │ │ ├── cluster-countkeysinslot.md │ │ ├── cluster-delslots.md │ │ ├── cluster-delslotsrange.md │ │ ├── cluster-failover.md │ │ ├── cluster-flushslots.md │ │ ├── cluster-forget.md │ │ ├── cluster-getkeysinslot.md │ │ ├── cluster-help.md │ │ ├── cluster-info.md │ │ ├── cluster-keyslot.md │ │ ├── cluster-links.md │ │ ├── cluster-meet.md │ │ ├── cluster-myid.md │ │ ├── cluster-nodes.md │ │ ├── cluster-replicas.md │ │ ├── cluster-replicate.md │ │ ├── cluster-reset.md │ │ ├── cluster-saveconfig.md │ │ ├── cluster-set-config-epoch.md │ │ ├── cluster-setslot.md │ │ ├── cluster-shards.md │ │ ├── cluster-slaves.md │ │ ├── cluster-slots.md │ │ ├── cluster.md │ │ ├── command-count.md │ │ ├── command-docs.md │ │ ├── command-getkeys.md │ │ ├── command-getkeysandflags.md │ │ ├── command-help.md │ │ ├── command-info.md │ │ ├── command-list.md │ │ ├── command.md │ │ ├── config-get.md │ │ ├── config-help.md │ │ ├── config-resetstat.md │ │ ├── config-rewrite.md │ │ ├── config-set.md │ │ ├── config.md │ │ ├── copy.md │ │ ├── dbsize.md │ │ ├── debug-object.md │ │ ├── debug-segfault.md │ │ ├── debug.md │ │ ├── decr.md │ │ ├── decrby.md │ │ ├── del.md │ │ ├── discard.md │ │ ├── dump.md │ │ ├── echo.md │ │ ├── eval.md │ │ ├── eval_ro.md │ │ ├── evalsha.md │ │ ├── evalsha_ro.md │ │ ├── exec.md │ │ ├── exists.md │ │ ├── expire.md │ │ ├── expireat.md │ │ ├── expiretime.md │ │ ├── failover.md │ │ ├── fcall.md │ │ ├── fcall_ro.md │ │ ├── flushall.md │ │ ├── flushdb.md │ │ ├── function-delete.md │ │ ├── function-dump.md │ │ ├── function-flush.md │ │ ├── function-help.md │ │ ├── function-kill.md │ │ ├── function-list.md │ │ ├── function-load.md │ │ ├── function-restore.md │ │ ├── function-stats.md │ │ ├── function.md │ │ ├── geoadd.md │ │ ├── geodecode.md │ │ ├── geodist.md │ │ ├── geoencode.md │ │ ├── geohash.md │ │ ├── geopos.md │ │ ├── georadius.md │ │ ├── georadius_ro.md │ │ ├── georadiusbymember.md │ │ ├── georadiusbymember_ro.md │ │ ├── geosearch.md │ │ ├── geosearchstore.md │ │ ├── get.md │ │ ├── getbit.md │ │ ├── getdel.md │ │ ├── getex.md │ │ ├── getrange.md │ │ ├── getset.md │ │ ├── hdel.md │ │ ├── hello.md │ │ ├── hexists.md │ │ ├── hget.md │ │ ├── hgetall.md │ │ ├── hincrby.md │ │ ├── hincrbyfloat.md │ │ ├── hkeys.md │ │ ├── hlen.md │ │ ├── hmget.md │ │ ├── hmset.md │ │ ├── hrandfield.md │ │ ├── hscan.md │ │ ├── hset.md │ │ ├── hsetnx.md │ │ ├── hstrlen.md │ │ ├── hvals.md │ │ ├── incr.md │ │ ├── incrby.md │ │ ├── incrbyfloat.md │ │ ├── info.md │ │ ├── keys.md │ │ ├── lastsave.md │ │ ├── latency-doctor.md │ │ ├── latency-graph.md │ │ ├── latency-help.md │ │ ├── latency-histogram.md │ │ ├── latency-history.md │ │ ├── latency-latest.md │ │ ├── latency-reset.md │ │ ├── latency.md │ │ ├── lcs.md │ │ ├── lindex.md │ │ ├── linsert.md │ │ ├── llen.md │ │ ├── lmove.md │ │ ├── lmpop.md │ │ ├── lolwut.md │ │ ├── lpop.md │ │ ├── lpos.md │ │ ├── lpush.md │ │ ├── lpushx.md │ │ ├── lrange.md │ │ ├── lrem.md │ │ ├── lset.md │ │ ├── ltrim.md │ │ ├── memory-doctor.md │ │ ├── memory-help.md │ │ ├── memory-malloc-stats.md │ │ ├── memory-purge.md │ │ ├── memory-stats.md │ │ ├── memory-usage.md │ │ ├── memory.md │ │ ├── mget.md │ │ ├── migrate.md │ │ ├── module-help.md │ │ ├── module-list.md │ │ ├── module-load.md │ │ ├── module-loadex.md │ │ ├── module-unload.md │ │ ├── module.md │ │ ├── monitor.md │ │ ├── move.md │ │ ├── mset.md │ │ ├── msetnx.md │ │ ├── multi.md │ │ ├── object-encoding.md │ │ ├── object-freq.md │ │ ├── object-help.md │ │ ├── object-idletime.md │ │ ├── object-refcount.md │ │ ├── object.md │ │ ├── persist.md │ │ ├── pexpire.md │ │ ├── pexpireat.md │ │ ├── pexpiretime.md │ │ ├── pfadd.md │ │ ├── pfcount.md │ │ ├── pfdebug.md │ │ ├── pfmerge.md │ │ ├── pfselftest.md │ │ ├── ping.md │ │ ├── psetex.md │ │ ├── psubscribe.md │ │ ├── psync.md │ │ ├── pttl.md │ │ ├── publish.md │ │ ├── pubsub-channels.md │ │ ├── pubsub-help.md │ │ ├── pubsub-numpat.md │ │ ├── pubsub-numsub.md │ │ ├── pubsub-shardchannels.md │ │ ├── pubsub-shardnumsub.md │ │ ├── pubsub.md │ │ ├── punsubscribe.md │ │ ├── quit.md │ │ ├── randomkey.md │ │ ├── readonly.md │ │ ├── readwrite.md │ │ ├── rename.md │ │ ├── renamenx.md │ │ ├── replconf.md │ │ ├── replicaof.md │ │ ├── reset.md │ │ ├── restore-asking.md │ │ ├── restore.md │ │ ├── role.md │ │ ├── rpop.md │ │ ├── rpoplpush.md │ │ ├── rpush.md │ │ ├── rpushx.md │ │ ├── sadd.md │ │ ├── save.md │ │ ├── scan.md │ │ ├── scard.md │ │ ├── script-debug.md │ │ ├── script-exists.md │ │ ├── script-flush.md │ │ ├── script-help.md │ │ ├── script-kill.md │ │ ├── script-load.md │ │ ├── script.md │ │ ├── sdiff.md │ │ ├── sdiffstore.md │ │ ├── select.md │ │ ├── set.md │ │ ├── setbit.md │ │ ├── setex.md │ │ ├── setnx.md │ │ ├── setrange.md │ │ ├── shutdown.md │ │ ├── sinter.md │ │ ├── sintercard.md │ │ ├── sinterstore.md │ │ ├── sismember.md │ │ ├── slaveof.md │ │ ├── slowlog-get.md │ │ ├── slowlog-help.md │ │ ├── slowlog-len.md │ │ ├── slowlog-reset.md │ │ ├── slowlog.md │ │ ├── smembers.md │ │ ├── smismember.md │ │ ├── smove.md │ │ ├── sort.md │ │ ├── sort_ro.md │ │ ├── spop.md │ │ ├── spublish.md │ │ ├── srandmember.md │ │ ├── srem.md │ │ ├── sscan.md │ │ ├── ssubscribe.md │ │ ├── stralgo.md │ │ ├── strlen.md │ │ ├── subscribe.md │ │ ├── substr.md │ │ ├── sunion.md │ │ ├── sunionstore.md │ │ ├── sunsubscribe.md │ │ ├── swapdb.md │ │ ├── sync.md │ │ ├── time.md │ │ ├── touch.md │ │ ├── ttl.md │ │ ├── type.md │ │ ├── unlink.md │ │ ├── unsubscribe.md │ │ ├── unwatch.md │ │ ├── wait.md │ │ ├── watch.md │ │ ├── xack.md │ │ ├── xadd.md │ │ ├── xautoclaim.md │ │ ├── xclaim.md │ │ ├── xdel.md │ │ ├── xgroup-create.md │ │ ├── xgroup-createconsumer.md │ │ ├── xgroup-delconsumer.md │ │ ├── xgroup-destroy.md │ │ ├── xgroup-help.md │ │ ├── xgroup-setid.md │ │ ├── xgroup.md │ │ ├── xinfo-consumers.md │ │ ├── xinfo-groups.md │ │ ├── xinfo-help.md │ │ ├── xinfo-stream.md │ │ ├── xinfo.md │ │ ├── xlen.md │ │ ├── xpending.md │ │ ├── xrange.md │ │ ├── xread.md │ │ ├── xreadgroup.md │ │ ├── xrevrange.md │ │ ├── xsetid.md │ │ ├── xtrim.md │ │ ├── zadd.md │ │ ├── zcard.md │ │ ├── zcount.md │ │ ├── zdiff.md │ │ ├── zdiffstore.md │ │ ├── zincrby.md │ │ ├── zinter.md │ │ ├── zintercard.md │ │ ├── zinterstore.md │ │ ├── zlexcount.md │ │ ├── zmpop.md │ │ ├── zmscore.md │ │ ├── zpopmax.md │ │ ├── zpopmin.md │ │ ├── zrandmember.md │ │ ├── zrange.md │ │ ├── zrangebylex.md │ │ ├── zrangebyscore.md │ │ ├── zrangestore.md │ │ ├── zrank.md │ │ ├── zrem.md │ │ ├── zremrangebylex.md │ │ ├── zremrangebyrank.md │ │ ├── zremrangebyscore.md │ │ ├── zrevrange.md │ │ ├── zrevrangebylex.md │ │ ├── zrevrangebyscore.md │ │ ├── zrevrank.md │ │ ├── zscan.md │ │ ├── zscore.md │ │ ├── zunion.md │ │ └── zunionstore.md │ ├── dangerous_commands.csv │ └── iredisrc ├── entry.py ├── exceptions.py ├── key_bindings.py ├── lexer.py ├── markdown.py ├── processors.py ├── redis_grammar.py ├── renders.py ├── style.py ├── utils.py └── warning.py ├── poetry.lock ├── pyoxidizer.template.bzl ├── pyproject.toml ├── scripts ├── add_fooset_commands.txt ├── add_hash.txt ├── add_lists.txt ├── add_myzset_commands.txt ├── check_renders.sh ├── conf │ └── slave │ │ └── slave.conf ├── display_all_command_hints.py ├── download_redis_commands.py ├── multi_del.txt ├── redis.conf ├── set_999_keys_in_redis.py ├── tcp-proxy.sh └── update_command_from_redis_doc.sh └── tests ├── __init__.py ├── cli_tests ├── __init__.py ├── test_cli_pubsub.py ├── test_cli_start.py ├── test_command_input.py ├── test_command_restore.py ├── test_completer.py ├── test_config.py ├── test_dsn.py ├── test_history.py ├── test_on_error.py ├── test_pager.py ├── test_self_implemented_command.py ├── test_shell_pipeline.py ├── test_string_execute.py ├── test_transaction.py ├── test_warning.py └── wrappager.py ├── conftest.py ├── helpers.py └── unittests ├── __init__.py ├── command_parse ├── test_base_token.py ├── test_cluster.py ├── test_connection.py ├── test_generic_parse.py ├── test_geo.py ├── test_hash_parse.py ├── test_hll_parse.py ├── test_list_parse.py ├── test_pubsub.py ├── test_script.py ├── test_server.py ├── test_set_parse.py ├── test_sorted_set_parse.py ├── test_stream.py └── test_string_parse.py ├── test_client.py ├── test_completers.py ├── test_entry.py ├── test_markdown_doc_render.py ├── test_render_functions.py └── test_utils.py /.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 1.15.1 3 | commit = True 4 | tag = True 5 | 6 | [bumpversion:file:iredis/__init__.py] 7 | 8 | [bumpversion:file:pyproject.toml] 9 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | tests 2 | scripts 3 | CHANGELOG.md 4 | Dockerfile 5 | docs 6 | pyoxidizer.template.bzl 7 | redis-doc 8 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = D203,W503,W605,C901,E203 3 | exclude = .git,__pycache__,build,dist,venv 4 | max-complexity = 14 5 | max-line-length = 120 6 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | patreon: laixintao 2 | custom: ["https://www.kawabangga.com/sponsor", "http://paypal.me/laixintao"] 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "iredis/data/redis-doc"] 2 | path = iredis/data/redis-doc 3 | url = https://github.com/antirez/redis-doc.git 4 | [submodule "redis-doc"] 5 | path = redis-doc 6 | url = https://github.com/antirez/redis-doc.git 7 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM redis/redis-stack-server:latest 2 | 3 | COPY . /iredis 4 | 5 | RUN apt-get update --fix-missing 6 | RUN apt-get install -yqq python3 python3-pip python-is-python3 7 | RUN python3 -m pip install poetry 8 | WORKDIR /iredis 9 | RUN poetry config virtualenvs.create false 10 | RUN poetry build 11 | RUN pip install dist/iredis*.tar.gz 12 | WORKDIR / 13 | RUN rm -rf .cache /var/cache/apt 14 | RUN rm -rf /iredis 15 | 16 | CMD ["sh", "-c", "/opt/redis-stack/bin/redis-stack-server --daemonize yes && iredis"] 17 | -------------------------------------------------------------------------------- /docs/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laixintao/iredis/27be126e4ea798115547111752f83c8998d66707/docs/assets/logo.png -------------------------------------------------------------------------------- /docs/assets/render.md: -------------------------------------------------------------------------------- 1 | Render using [termtosvg](https://github.com/nbedos/termtosvg/blob/develop/man/termtosvg.md): 2 | 3 | ``` 4 | termtosvg render demo.cast demo1.svg -D 2 -m40 -M300 -t progress_bar 5 | ``` 6 | 7 | size: 66x20 8 | -------------------------------------------------------------------------------- /docs/cloudshell/run-in-docker.txt: -------------------------------------------------------------------------------- 1 | Try redis in docker(which contains a redis-server): 2 | 3 | docker build -t iredis . && docker run -it iredis 4 | -------------------------------------------------------------------------------- /docs/update-redis-doc.md: -------------------------------------------------------------------------------- 1 | # How to Catch Up with Latest Redis-doc 2 | 3 | 1. `git pull` in submodule. 4 | 2. Overwrite `iredis/data/commands.json`. 5 | 3. Diff with old `commands.json`, make the changes. 6 | 4. `mv redis-doc/commands/*.md iredis/data/commands` 7 | 5. `prettier --write --prose-wrap always iredis/data/commands/*.md` 8 | 9 | Done! 10 | -------------------------------------------------------------------------------- /iredis/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "1.15.1" 2 | -------------------------------------------------------------------------------- /iredis/bottom.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from .commands import commands_summary 3 | from .utils import command_syntax 4 | 5 | BUTTOM_TEXT = "Ctrl-D to exit;" 6 | logger = logging.getLogger(__name__) 7 | 8 | 9 | class BottomToolbar: 10 | CHAR = "⣾⣷⣯⣟⡿⢿⣻⣽" 11 | 12 | def __init__(self, command_holder): 13 | self.index = 0 14 | # BottomToolbar can only read this variable 15 | self.command_holder = command_holder 16 | 17 | def get_animation_char(self): 18 | animation = self.CHAR[self.index] 19 | 20 | self.index += 1 21 | if self.index == len(self.CHAR): 22 | self.index = 0 23 | return animation 24 | 25 | def render(self): 26 | text = BUTTOM_TEXT 27 | # add command help if valid 28 | if self.command_holder.command: 29 | try: 30 | command_info = commands_summary[self.command_holder.command] 31 | text = command_syntax(self.command_holder.command, command_info) 32 | except KeyError as e: 33 | logger.exception(e) 34 | 35 | return text 36 | -------------------------------------------------------------------------------- /iredis/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laixintao/iredis/27be126e4ea798115547111752f83c8998d66707/iredis/data/__init__.py -------------------------------------------------------------------------------- /iredis/data/commands/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laixintao/iredis/27be126e4ea798115547111752f83c8998d66707/iredis/data/commands/__init__.py -------------------------------------------------------------------------------- /iredis/data/commands/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Redis Commands" 3 | linkTitle: "Commands" 4 | --- 5 | -------------------------------------------------------------------------------- /iredis/data/commands/acl-deluser.md: -------------------------------------------------------------------------------- 1 | Delete all the specified ACL users and terminate all the connections that are 2 | authenticated with such users. Note: the special `default` user cannot be 3 | removed from the system, this is the default user that every new connection 4 | is authenticated with. The list of users may include usernames that do not 5 | exist, in such case no operation is performed for the non existing users. 6 | 7 | @return 8 | 9 | @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. 10 | 11 | @examples 12 | 13 | ``` 14 | > ACL DELUSER antirez 15 | 1 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/acl-dryrun.md: -------------------------------------------------------------------------------- 1 | Simulate the execution of a given command by a given user. 2 | 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. 3 | 4 | @return 5 | 6 | @simple-string-reply: `OK` on success. 7 | @bulk-string-reply: An error describing why the user can't execute the command. 8 | 9 | @examples 10 | 11 | ``` 12 | > ACL SETUSER VIRGINIA +SET ~* 13 | "OK" 14 | > ACL DRYRUN VIRGINIA SET foo bar 15 | "OK" 16 | > ACL DRYRUN VIRGINIA GET foo bar 17 | "This user has no permissions to run the 'GET' command" 18 | ``` 19 | -------------------------------------------------------------------------------- /iredis/data/commands/acl-help.md: -------------------------------------------------------------------------------- 1 | The `ACL HELP` command returns a helpful text describing the different subcommands. 2 | 3 | @return 4 | 5 | @array-reply: a list of subcommands and their descriptions 6 | -------------------------------------------------------------------------------- /iredis/data/commands/acl-list.md: -------------------------------------------------------------------------------- 1 | The command shows the currently active ACL rules in the Redis server. Each 2 | line in the returned array defines a different user, and the format is the 3 | same used in the redis.conf file or the external ACL file, so you can 4 | cut and paste what is returned by the ACL LIST command directly inside a 5 | configuration file if you wish (but make sure to check `ACL SAVE`). 6 | 7 | @return 8 | 9 | An array of strings. 10 | 11 | @examples 12 | 13 | ``` 14 | > ACL LIST 15 | 1) "user antirez on #9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 ~objects:* &* +@all -@admin -@dangerous" 16 | 2) "user default on nopass ~* &* +@all" 17 | ``` 18 | -------------------------------------------------------------------------------- /iredis/data/commands/acl-load.md: -------------------------------------------------------------------------------- 1 | When Redis is configured to use an ACL file (with the `aclfile` configuration 2 | option), this command will reload the ACLs from the file, replacing all 3 | the current ACL rules with the ones defined in the file. The command makes 4 | sure to have an *all or nothing* behavior, that is: 5 | 6 | * If every line in the file is valid, all the ACLs are loaded. 7 | * 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. 8 | 9 | @return 10 | 11 | @simple-string-reply: `OK` on success. 12 | 13 | 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. 14 | 15 | @examples 16 | 17 | ``` 18 | > ACL LOAD 19 | +OK 20 | 21 | > ACL LOAD 22 | -ERR /tmp/foo:1: Unknown command or category name in ACL... 23 | ``` 24 | -------------------------------------------------------------------------------- /iredis/data/commands/acl-log.md: -------------------------------------------------------------------------------- 1 | The command shows a list of recent ACL security events: 2 | 3 | 1. Failures to authenticate their connections with `AUTH` or `HELLO`. 4 | 2. Commands denied because against the current ACL rules. 5 | 3. Commands denied because accessing keys not allowed in the current ACL rules. 6 | 7 | The optional argument specifies how many entries to show. By default 8 | up to ten failures are returned. The special `RESET` argument clears the log. 9 | Entries are displayed starting from the most recent. 10 | 11 | @return 12 | 13 | When called to show security events: 14 | 15 | @array-reply: a list of ACL security events. 16 | 17 | When called with `RESET`: 18 | 19 | @simple-string-reply: `OK` if the security log was cleared. 20 | 21 | @examples 22 | 23 | ``` 24 | > AUTH someuser wrongpassword 25 | (error) WRONGPASS invalid username-password pair 26 | > ACL LOG 1 27 | 1) 1) "count" 28 | 2) (integer) 1 29 | 3) "reason" 30 | 4) "auth" 31 | 5) "context" 32 | 6) "toplevel" 33 | 7) "object" 34 | 8) "AUTH" 35 | 9) "username" 36 | 10) "someuser" 37 | 11) "age-seconds" 38 | 12) "4.0960000000000001" 39 | 13) "client-info" 40 | 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" 41 | ``` 42 | -------------------------------------------------------------------------------- /iredis/data/commands/acl-save.md: -------------------------------------------------------------------------------- 1 | When Redis is configured to use an ACL file (with the `aclfile` configuration 2 | option), this command will save the currently defined ACLs from the server memory to the ACL file. 3 | 4 | @return 5 | 6 | @simple-string-reply: `OK` on success. 7 | 8 | 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. 9 | 10 | @examples 11 | 12 | ``` 13 | > ACL SAVE 14 | +OK 15 | 16 | > ACL SAVE 17 | -ERR There was an error trying to save the ACLs. Please check the server logs for more information 18 | ``` 19 | -------------------------------------------------------------------------------- /iredis/data/commands/acl-users.md: -------------------------------------------------------------------------------- 1 | The command shows a list of all the usernames of the currently configured 2 | users in the Redis ACL system. 3 | 4 | @return 5 | 6 | An array of strings. 7 | 8 | @examples 9 | 10 | ``` 11 | > ACL USERS 12 | 1) "anna" 13 | 2) "antirez" 14 | 3) "default" 15 | ``` 16 | -------------------------------------------------------------------------------- /iredis/data/commands/acl-whoami.md: -------------------------------------------------------------------------------- 1 | Return the username the current connection is authenticated with. 2 | New connections are authenticated with the "default" user. They 3 | can change user using `AUTH`. 4 | 5 | @return 6 | 7 | @bulk-string-reply: the username of the current connection. 8 | 9 | @examples 10 | 11 | ``` 12 | > ACL WHOAMI 13 | "default" 14 | ``` 15 | -------------------------------------------------------------------------------- /iredis/data/commands/acl.md: -------------------------------------------------------------------------------- 1 | This is a container command for [Access Control List](/docs/manual/security/acl/) commands. 2 | 3 | To see the list of available commands you can call `ACL HELP`. 4 | -------------------------------------------------------------------------------- /iredis/data/commands/asking.md: -------------------------------------------------------------------------------- 1 | When a cluster client receives an `-ASK` redirect, the `ASKING` command is sent to the target node followed by the command which was redirected. 2 | This is normally done automatically by cluster clients. 3 | 4 | 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. 5 | 6 | See [ASK redirection in the Redis Cluster Specification](/topics/cluster-spec#ask-redirection) for details. 7 | 8 | @return 9 | 10 | @simple-string-reply: `OK`. 11 | -------------------------------------------------------------------------------- /iredis/data/commands/bgsave.md: -------------------------------------------------------------------------------- 1 | Save the DB in background. 2 | 3 | Normally the OK code is immediately returned. 4 | Redis forks, the parent continues to serve the clients, the child saves the DB 5 | on disk then exits. 6 | 7 | An error is returned if there is already a background save running or if there 8 | is another non-background-save process running, specifically an in-progress AOF 9 | rewrite. 10 | 11 | If `BGSAVE SCHEDULE` is used, the command will immediately return `OK` when an 12 | AOF rewrite is in progress and schedule the background save to run at the next 13 | opportunity. 14 | 15 | A client may be able to check if the operation succeeded using the `LASTSAVE` 16 | command. 17 | 18 | Please refer to the [persistence documentation][tp] for detailed information. 19 | 20 | [tp]: /topics/persistence 21 | 22 | @return 23 | 24 | @simple-string-reply: `Background saving started` if `BGSAVE` started correctly or `Background saving scheduled` when used with the `SCHEDULE` subcommand. 25 | -------------------------------------------------------------------------------- /iredis/data/commands/bitfield_ro.md: -------------------------------------------------------------------------------- 1 | Read-only variant of the `BITFIELD` command. 2 | It is like the original `BITFIELD` but only accepts `!GET` subcommand and can safely be used in read-only replicas. 3 | 4 | Since the original `BITFIELD` has `!SET` and `!INCRBY` options it is technically flagged as a writing command in the Redis command table. 5 | 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). 6 | 7 | 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. 8 | 9 | See original `BITFIELD` for more details. 10 | 11 | @examples 12 | 13 | ``` 14 | BITFIELD_RO hello GET i8 16 15 | ``` 16 | 17 | @return 18 | 19 | @array-reply: An array with each entry being the corresponding result of the subcommand given at the same position. 20 | -------------------------------------------------------------------------------- /iredis/data/commands/blmove.md: -------------------------------------------------------------------------------- 1 | `BLMOVE` is the blocking variant of `LMOVE`. 2 | When `source` contains elements, this command behaves exactly like `LMOVE`. 3 | When used inside a `MULTI`/`EXEC` block, this command behaves exactly like `LMOVE`. 4 | When `source` is empty, Redis will block the connection until another client 5 | pushes to it or until `timeout` (a double value specifying the maximum number of seconds to block) is reached. 6 | A `timeout` of zero can be used to block indefinitely. 7 | 8 | This command comes in place of the now deprecated `BRPOPLPUSH`. Doing 9 | `BLMOVE RIGHT LEFT` is equivalent. 10 | 11 | See `LMOVE` for more information. 12 | 13 | @return 14 | 15 | @bulk-string-reply: the element being popped from `source` and pushed to `destination`. 16 | If `timeout` is reached, a @nil-reply is returned. 17 | 18 | ## Pattern: Reliable queue 19 | 20 | Please see the pattern description in the `LMOVE` documentation. 21 | 22 | ## Pattern: Circular list 23 | 24 | Please see the pattern description in the `LMOVE` documentation. 25 | -------------------------------------------------------------------------------- /iredis/data/commands/blmpop.md: -------------------------------------------------------------------------------- 1 | `BLMPOP` is the blocking variant of `LMPOP`. 2 | 3 | When any of the lists contains elements, this command behaves exactly like `LMPOP`. 4 | When used inside a `MULTI`/`EXEC` block, this command behaves exactly like `LMPOP`. 5 | 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. 6 | A `timeout` of zero can be used to block indefinitely. 7 | 8 | See `LMPOP` for more information. 9 | 10 | @return 11 | 12 | @array-reply: specifically: 13 | 14 | * A `nil` when no element could be popped, and timeout is reached. 15 | * 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. 16 | -------------------------------------------------------------------------------- /iredis/data/commands/brpop.md: -------------------------------------------------------------------------------- 1 | `BRPOP` is a blocking list pop primitive. 2 | It is the blocking version of `RPOP` because it blocks the connection when there 3 | are no elements to pop from any of the given lists. 4 | An element is popped from the tail of the first list that is non-empty, with the 5 | given keys being checked in the order that they are given. 6 | 7 | See the [BLPOP documentation][cb] for the exact semantics, since `BRPOP` is 8 | identical to `BLPOP` with the only difference being that it pops elements from 9 | the tail of a list instead of popping from the head. 10 | 11 | [cb]: /commands/blpop 12 | 13 | @return 14 | 15 | @array-reply: specifically: 16 | 17 | * A `nil` multi-bulk when no element could be popped and the timeout expired. 18 | * A two-element multi-bulk with the first element being the name of the key 19 | where an element was popped and the second element being the value of the 20 | popped element. 21 | 22 | @examples 23 | 24 | ``` 25 | redis> DEL list1 list2 26 | (integer) 0 27 | redis> RPUSH list1 a b c 28 | (integer) 3 29 | redis> BRPOP list1 list2 0 30 | 1) "list1" 31 | 2) "c" 32 | ``` 33 | -------------------------------------------------------------------------------- /iredis/data/commands/brpoplpush.md: -------------------------------------------------------------------------------- 1 | `BRPOPLPUSH` is the blocking variant of `RPOPLPUSH`. 2 | When `source` contains elements, this command behaves exactly like `RPOPLPUSH`. 3 | When used inside a `MULTI`/`EXEC` block, this command behaves exactly like `RPOPLPUSH`. 4 | When `source` is empty, Redis will block the connection until another client 5 | pushes to it or until `timeout` is reached. 6 | A `timeout` of zero can be used to block indefinitely. 7 | 8 | See `RPOPLPUSH` for more information. 9 | 10 | @return 11 | 12 | @bulk-string-reply: the element being popped from `source` and pushed to `destination`. 13 | If `timeout` is reached, a @nil-reply is returned. 14 | 15 | ## Pattern: Reliable queue 16 | 17 | Please see the pattern description in the `RPOPLPUSH` documentation. 18 | 19 | ## Pattern: Circular list 20 | 21 | Please see the pattern description in the `RPOPLPUSH` documentation. 22 | -------------------------------------------------------------------------------- /iredis/data/commands/bzmpop.md: -------------------------------------------------------------------------------- 1 | `BZMPOP` is the blocking variant of `ZMPOP`. 2 | 3 | When any of the sorted sets contains elements, this command behaves exactly like `ZMPOP`. 4 | When used inside a `MULTI`/`EXEC` block, this command behaves exactly like `ZMPOP`. 5 | 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. 6 | A `timeout` of zero can be used to block indefinitely. 7 | 8 | See `ZMPOP` for more information. 9 | 10 | @return 11 | 12 | @array-reply: specifically: 13 | 14 | * A `nil` when no element could be popped. 15 | * 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. 16 | 17 | -------------------------------------------------------------------------------- /iredis/data/commands/bzpopmin.md: -------------------------------------------------------------------------------- 1 | `BZPOPMIN` is the blocking variant of the sorted set `ZPOPMIN` primitive. 2 | 3 | It is the blocking version because it blocks the connection when there are no 4 | members to pop from any of the given sorted sets. 5 | A member with the lowest score is popped from first sorted set that is 6 | non-empty, with the given keys being checked in the order that they are given. 7 | 8 | The `timeout` argument is interpreted as a double value specifying the maximum 9 | number of seconds to block. A timeout of zero can be used to block indefinitely. 10 | 11 | See the [BLPOP documentation][cl] for the exact semantics, since `BZPOPMIN` is 12 | identical to `BLPOP` with the only difference being the data structure being 13 | popped from. 14 | 15 | [cl]: /commands/blpop 16 | 17 | @return 18 | 19 | @array-reply: specifically: 20 | 21 | * A `nil` multi-bulk when no element could be popped and the timeout expired. 22 | * A three-element multi-bulk with the first element being the name of the key 23 | where a member was popped, the second element is the popped member itself, 24 | and the third element is the score of the popped element. 25 | 26 | @examples 27 | 28 | ``` 29 | redis> DEL zset1 zset2 30 | (integer) 0 31 | redis> ZADD zset1 0 a 1 b 2 c 32 | (integer) 3 33 | redis> BZPOPMIN zset1 zset2 0 34 | 1) "zset1" 35 | 2) "a" 36 | 3) "0" 37 | ``` 38 | -------------------------------------------------------------------------------- /iredis/data/commands/client-caching.md: -------------------------------------------------------------------------------- 1 | This command controls the tracking of the keys in the next command executed 2 | by the connection, when tracking is enabled in `OPTIN` or `OPTOUT` mode. 3 | Please check the 4 | [client side caching documentation](/topics/client-side-caching) for 5 | background information. 6 | 7 | When tracking is enabled Redis, using the `CLIENT TRACKING` command, it is 8 | possible to specify the `OPTIN` or `OPTOUT` options, so that keys 9 | in read only commands are not automatically remembered by the server to 10 | be invalidated later. When we are in `OPTIN` mode, we can enable the 11 | tracking of the keys in the next command by calling `CLIENT CACHING yes` 12 | immediately before it. Similarly when we are in `OPTOUT` mode, and keys 13 | are normally tracked, we can avoid the keys in the next command to be 14 | tracked using `CLIENT CACHING no`. 15 | 16 | Basically the command sets a state in the connection, that is valid only 17 | for the next command execution, that will modify the behavior of client 18 | tracking. 19 | 20 | @return 21 | 22 | @simple-string-reply: `OK` or an error if the argument is not yes or no. 23 | -------------------------------------------------------------------------------- /iredis/data/commands/client-getname.md: -------------------------------------------------------------------------------- 1 | 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. 2 | 3 | @return 4 | 5 | @bulk-string-reply: The connection name, or a null bulk reply if no name is set. 6 | -------------------------------------------------------------------------------- /iredis/data/commands/client-getredir.md: -------------------------------------------------------------------------------- 1 | This command returns the client ID we are redirecting our 2 | [tracking](/topics/client-side-caching) notifications to. We set a client 3 | to redirect to when using `CLIENT TRACKING` to enable tracking. However in 4 | order to avoid forcing client libraries implementations to remember the 5 | ID notifications are redirected to, this command exists in order to improve 6 | introspection and allow clients to check later if redirection is active 7 | and towards which client ID. 8 | 9 | @return 10 | 11 | @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. 12 | -------------------------------------------------------------------------------- /iredis/data/commands/client-help.md: -------------------------------------------------------------------------------- 1 | The `CLIENT HELP` command returns a helpful text describing the different subcommands. 2 | 3 | @return 4 | 5 | @array-reply: a list of subcommands and their descriptions 6 | -------------------------------------------------------------------------------- /iredis/data/commands/client-id.md: -------------------------------------------------------------------------------- 1 | The command just returns the ID of the current connection. Every connection 2 | ID has certain guarantees: 3 | 4 | 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. 5 | 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. 6 | 7 | This command is especially useful together with `CLIENT UNBLOCK` which was 8 | introduced also in Redis 5 together with `CLIENT ID`. Check the `CLIENT UNBLOCK` command page for a pattern involving the two commands. 9 | 10 | @examples 11 | 12 | ```cli 13 | CLIENT ID 14 | ``` 15 | 16 | @return 17 | 18 | @integer-reply 19 | 20 | The id of the client. 21 | -------------------------------------------------------------------------------- /iredis/data/commands/client-info.md: -------------------------------------------------------------------------------- 1 | The command returns information and statistics about the current client connection in a mostly human readable format. 2 | 3 | The reply format is identical to that of `CLIENT LIST`, and the content consists only of information about the current client. 4 | 5 | @examples 6 | 7 | ```cli 8 | CLIENT INFO 9 | ``` 10 | 11 | @return 12 | 13 | @bulk-string-reply: a unique string, as described at the `CLIENT LIST` page, for the current client. 14 | -------------------------------------------------------------------------------- /iredis/data/commands/client-no-evict.md: -------------------------------------------------------------------------------- 1 | The `CLIENT NO-EVICT` command sets the [client eviction](/topics/clients#client-eviction) mode for the current connection. 2 | 3 | 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. 4 | 5 | When turned off, the current client will be re-included in the pool of potential clients to be evicted (and evicted if needed). 6 | 7 | See [client eviction](/topics/clients#client-eviction) for more details. 8 | 9 | @return 10 | 11 | @simple-string-reply: `OK`. 12 | -------------------------------------------------------------------------------- /iredis/data/commands/client-reply.md: -------------------------------------------------------------------------------- 1 | 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. 2 | 3 | The `CLIENT REPLY` command controls whether the server will reply the client's commands. The following modes are available: 4 | 5 | * `ON`. This is the default mode in which the server returns a reply to every command. 6 | * `OFF`. In this mode the server will not reply to client commands. 7 | * `SKIP`. This mode skips the reply of command immediately after it. 8 | 9 | @return 10 | 11 | When called with either `OFF` or `SKIP` subcommands, no reply is made. When called with `ON`: 12 | 13 | @simple-string-reply: `OK`. 14 | -------------------------------------------------------------------------------- /iredis/data/commands/client-setname.md: -------------------------------------------------------------------------------- 1 | The `CLIENT SETNAME` command assigns a name to the current connection. 2 | 3 | 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. 4 | 5 | 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. 6 | 7 | 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. 8 | 9 | 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. 10 | 11 | The connection name can be inspected using `CLIENT GETNAME`. 12 | 13 | Every new connection starts without an assigned name. 14 | 15 | Tip: setting names to connections is a good way to debug connection leaks due to bugs in the application using Redis. 16 | 17 | @return 18 | 19 | @simple-string-reply: `OK` if the connection name was successfully set. 20 | -------------------------------------------------------------------------------- /iredis/data/commands/client-trackinginfo.md: -------------------------------------------------------------------------------- 1 | The command returns information about the current client connection's use of the [server assisted client side caching](/topics/client-side-caching) feature. 2 | 3 | @return 4 | 5 | @array-reply: a list of tracking information sections and their respective values, specifically: 6 | 7 | * **flags**: A list of tracking flags used by the connection. The flags and their meanings are as follows: 8 | * `off`: The connection isn't using server assisted client side caching. 9 | * `on`: Server assisted client side caching is enabled for the connection. 10 | * `bcast`: The client uses broadcasting mode. 11 | * `optin`: The client does not cache keys by default. 12 | * `optout`: The client caches keys by default. 13 | * `caching-yes`: The next command will cache keys (exists only together with `optin`). 14 | * `caching-no`: The next command won't cache keys (exists only together with `optout`). 15 | * `noloop`: The client isn't notified about keys modified by itself. 16 | * `broken_redirect`: The client ID used for redirection isn't valid anymore. 17 | * **redirect**: The client ID used for notifications redirection, or -1 when none. 18 | * **prefixes**: A list of key prefixes for which notifications are sent to the client. 19 | -------------------------------------------------------------------------------- /iredis/data/commands/client-unpause.md: -------------------------------------------------------------------------------- 1 | `CLIENT UNPAUSE` is used to resume command processing for all clients that were paused by `CLIENT PAUSE`. 2 | 3 | @return 4 | 5 | @simple-string-reply: The command returns `OK` 6 | -------------------------------------------------------------------------------- /iredis/data/commands/client.md: -------------------------------------------------------------------------------- 1 | This is a container command for client connection commands. 2 | 3 | To see the list of available commands you can call `CLIENT HELP`. -------------------------------------------------------------------------------- /iredis/data/commands/cluster-addslotsrange.md: -------------------------------------------------------------------------------- 1 | The `CLUSTER ADDSLOTSRANGE` is similar to the `CLUSTER ADDSLOTS` command in that they both assign hash slots to nodes. 2 | 3 | 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. 4 | 5 | ## Example 6 | 7 | To assign slots 1 2 3 4 5 to the node, the `ADDSLOTS` command is: 8 | 9 | > CLUSTER ADDSLOTS 1 2 3 4 5 10 | OK 11 | 12 | The same operation can be completed with the following `ADDSLOTSRANGE` command: 13 | 14 | > CLUSTER ADDSLOTSRANGE 1 5 15 | OK 16 | 17 | 18 | ## Usage in Redis Cluster 19 | 20 | This command only works in cluster mode and is useful in the following Redis Cluster operations: 21 | 22 | 1. To create a new cluster ADDSLOTSRANGE is used in order to initially setup master nodes splitting the available hash slots among them. 23 | 2. In order to fix a broken cluster where certain slots are unassigned. 24 | 25 | @return 26 | 27 | @simple-string-reply: `OK` if the command was successful. Otherwise an error is returned. 28 | -------------------------------------------------------------------------------- /iredis/data/commands/cluster-bumpepoch.md: -------------------------------------------------------------------------------- 1 | Advances the cluster config epoch. 2 | 3 | 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. 4 | 5 | **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. 6 | 7 | @return 8 | 9 | @simple-string-reply: `BUMPED` if the epoch was incremented, or `STILL` if the node already has the greatest config epoch in the cluster. 10 | -------------------------------------------------------------------------------- /iredis/data/commands/cluster-countkeysinslot.md: -------------------------------------------------------------------------------- 1 | Returns the number of keys in the specified Redis Cluster hash slot. The 2 | command only queries the local data set, so contacting a node 3 | that is not serving the specified hash slot will always result in a count of 4 | zero being returned. 5 | 6 | ``` 7 | > CLUSTER COUNTKEYSINSLOT 7000 8 | (integer) 50341 9 | ``` 10 | 11 | @return 12 | 13 | @integer-reply: The number of keys in the specified hash slot, or an error if the hash slot is invalid. 14 | -------------------------------------------------------------------------------- /iredis/data/commands/cluster-flushslots.md: -------------------------------------------------------------------------------- 1 | Deletes all slots from a node. 2 | 3 | The `CLUSTER FLUSHSLOTS` deletes all information about slots from the connected node. It can only be called when the database is empty. 4 | 5 | @return 6 | 7 | @simple-string-reply: `OK` 8 | -------------------------------------------------------------------------------- /iredis/data/commands/cluster-getkeysinslot.md: -------------------------------------------------------------------------------- 1 | The command returns an array of keys names stored in the contacted node and 2 | hashing to the specified hash slot. The maximum number of keys to return 3 | is specified via the `count` argument, so that it is possible for the user 4 | of this API to batch-processing keys. 5 | 6 | The main usage of this command is during rehashing of cluster slots from one 7 | node to another. The way the rehashing is performed is exposed in the Redis 8 | Cluster specification, or in a more simple to digest form, as an appendix 9 | of the `CLUSTER SETSLOT` command documentation. 10 | 11 | ``` 12 | > CLUSTER GETKEYSINSLOT 7000 3 13 | 1) "key_39015" 14 | 2) "key_89793" 15 | 3) "key_92937" 16 | ``` 17 | 18 | @return 19 | 20 | @array-reply: From 0 to *count* key names in a Redis array reply. 21 | -------------------------------------------------------------------------------- /iredis/data/commands/cluster-help.md: -------------------------------------------------------------------------------- 1 | The `CLUSTER HELP` command returns a helpful text describing the different subcommands. 2 | 3 | @return 4 | 5 | @array-reply: a list of subcommands and their descriptions 6 | -------------------------------------------------------------------------------- /iredis/data/commands/cluster-keyslot.md: -------------------------------------------------------------------------------- 1 | Returns an integer identifying the hash slot the specified key hashes to. 2 | This command is mainly useful for debugging and testing, since it exposes 3 | via an API the underlying Redis implementation of the hashing algorithm. 4 | Example use cases for this command: 5 | 6 | 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. 7 | 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. 8 | 9 | ## Example 10 | 11 | ``` 12 | > CLUSTER KEYSLOT somekey 13 | (integer) 11058 14 | > CLUSTER KEYSLOT foo{hash_tag} 15 | (integer) 2515 16 | > CLUSTER KEYSLOT bar{hash_tag} 17 | (integer) 2515 18 | ``` 19 | 20 | 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. 21 | 22 | @return 23 | 24 | @integer-reply: The hash slot number. 25 | -------------------------------------------------------------------------------- /iredis/data/commands/cluster-myid.md: -------------------------------------------------------------------------------- 1 | Returns the node's id. 2 | 3 | The `CLUSTER MYID` command returns the unique, auto-generated identifier that is associated with the connected cluster node. 4 | 5 | @return 6 | 7 | @bulk-string-reply: The node id. -------------------------------------------------------------------------------- /iredis/data/commands/cluster-replicas.md: -------------------------------------------------------------------------------- 1 | The command provides a list of replica nodes replicating from the specified 2 | 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). 3 | 4 | The command will fail if the specified node is not known or if it is not 5 | a master according to the node table of the node receiving the command. 6 | 7 | Note that if a replica is added, moved, or removed from a given master node, 8 | and we ask `CLUSTER REPLICAS` to a node that has not yet received the 9 | configuration update, it may show stale information. However eventually 10 | (in a matter of seconds if there are no network partitions) all the nodes 11 | will agree about the set of nodes associated with a given master. 12 | 13 | @return 14 | 15 | The command returns data in the same format as `CLUSTER NODES`. 16 | -------------------------------------------------------------------------------- /iredis/data/commands/cluster-replicate.md: -------------------------------------------------------------------------------- 1 | The command reconfigures a node as a replica of the specified master. 2 | If the node receiving the command is an *empty master*, as a side effect 3 | of the command, the node role is changed from master to replica. 4 | 5 | Once a node is turned into the replica of another master node, there is no need 6 | to inform the other cluster nodes about the change: heartbeat packets exchanged 7 | between nodes will propagate the new configuration automatically. 8 | 9 | A replica will always accept the command, assuming that: 10 | 11 | 1. The specified node ID exists in its nodes table. 12 | 2. The specified node ID does not identify the instance we are sending the command to. 13 | 3. The specified node ID is a master. 14 | 15 | If the node receiving the command is not already a replica, but is a master, 16 | the command will only succeed, and the node will be converted into a replica, 17 | only if the following additional conditions are met: 18 | 19 | 1. The node is not serving any hash slots. 20 | 2. The node is empty, no keys are stored at all in the key space. 21 | 22 | If the command succeeds the new replica will immediately try to contact its master in order to replicate from it. 23 | 24 | @return 25 | 26 | @simple-string-reply: `OK` if the command was executed successfully, otherwise an error is returned. 27 | -------------------------------------------------------------------------------- /iredis/data/commands/cluster-saveconfig.md: -------------------------------------------------------------------------------- 1 | Forces a node to save the `nodes.conf` configuration on disk. Before to return 2 | the command calls `fsync(2)` in order to make sure the configuration is 3 | flushed on the computer disk. 4 | 5 | This command is mainly used in the event a `nodes.conf` node state file 6 | gets lost / deleted for some reason, and we want to generate it again from 7 | scratch. It can also be useful in case of mundane alterations of a node cluster 8 | configuration via the `CLUSTER` command in order to ensure the new configuration 9 | is persisted on disk, however all the commands should normally be able to 10 | auto schedule to persist the configuration on disk when it is important 11 | to do so for the correctness of the system in the event of a restart. 12 | 13 | @return 14 | 15 | @simple-string-reply: `OK` or an error if the operation fails. 16 | -------------------------------------------------------------------------------- /iredis/data/commands/cluster-set-config-epoch.md: -------------------------------------------------------------------------------- 1 | This command sets a specific *config epoch* in a fresh node. It only works when: 2 | 3 | 1. The nodes table of the node is empty. 4 | 2. The node current *config epoch* is zero. 5 | 6 | These prerequisites are needed since usually, manually altering the 7 | configuration epoch of a node is unsafe, we want to be sure that the node with 8 | the higher configuration epoch value (that is the last that failed over) wins 9 | over other nodes in claiming the hash slots ownership. 10 | 11 | However there is an exception to this rule, and it is when a new 12 | cluster is created from scratch. Redis Cluster *config epoch collision 13 | resolution* algorithm can deal with new nodes all configured with the 14 | same configuration at startup, but this process is slow and should be 15 | the exception, only to make sure that whatever happens, two more 16 | nodes eventually always move away from the state of having the same 17 | configuration epoch. 18 | 19 | So, using `CLUSTER SET-CONFIG-EPOCH`, when a new cluster is created, we can 20 | assign a different progressive configuration epoch to each node before 21 | joining the cluster together. 22 | 23 | @return 24 | 25 | @simple-string-reply: `OK` if the command was executed successfully, otherwise an error is returned. 26 | -------------------------------------------------------------------------------- /iredis/data/commands/cluster-slaves.md: -------------------------------------------------------------------------------- 1 | **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. 2 | 3 | The command provides a list of replica nodes replicating from the specified 4 | 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). 5 | 6 | The command will fail if the specified node is not known or if it is not 7 | a master according to the node table of the node receiving the command. 8 | 9 | Note that if a replica is added, moved, or removed from a given master node, 10 | and we ask `CLUSTER SLAVES` to a node that has not yet received the 11 | configuration update, it may show stale information. However eventually 12 | (in a matter of seconds if there are no network partitions) all the nodes 13 | will agree about the set of nodes associated with a given master. 14 | 15 | @return 16 | 17 | The command returns data in the same format as `CLUSTER NODES`. 18 | -------------------------------------------------------------------------------- /iredis/data/commands/cluster.md: -------------------------------------------------------------------------------- 1 | This is a container command for Redis Cluster commands. 2 | 3 | To see the list of available commands you can call `CLUSTER HELP`. 4 | -------------------------------------------------------------------------------- /iredis/data/commands/command-count.md: -------------------------------------------------------------------------------- 1 | Returns @integer-reply of number of total commands in this Redis server. 2 | 3 | @return 4 | 5 | @integer-reply: number of commands returned by `COMMAND` 6 | 7 | @examples 8 | 9 | ```cli 10 | COMMAND COUNT 11 | ``` 12 | -------------------------------------------------------------------------------- /iredis/data/commands/command-getkeys.md: -------------------------------------------------------------------------------- 1 | Returns @array-reply of keys from a full Redis command. 2 | 3 | `COMMAND GETKEYS` is a helper command to let you find the keys 4 | from a full Redis command. 5 | 6 | `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`), 7 | 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. 8 | You can use `COMMAND GETKEYS` or `COMMAND GETKEYSANDFLAGS` to discover key names directly from how Redis parses the commands. 9 | 10 | 11 | @return 12 | 13 | @array-reply: list of keys from your command. 14 | 15 | @examples 16 | 17 | ```cli 18 | COMMAND GETKEYS MSET a b c d e f 19 | COMMAND GETKEYS EVAL "not consulted" 3 key1 key2 key3 arg1 arg2 arg3 argN 20 | COMMAND GETKEYS SORT mylist ALPHA STORE outlist 21 | ``` 22 | -------------------------------------------------------------------------------- /iredis/data/commands/command-getkeysandflags.md: -------------------------------------------------------------------------------- 1 | Returns @array-reply of keys from a full Redis command and their usage flags. 2 | 3 | `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. 4 | 5 | `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`), 6 | 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. 7 | You can use `COMMAND GETKEYS` or `COMMAND GETKEYSANDFLAGS` to discover key names directly from how Redis parses the commands. 8 | 9 | Refer to [key specifications](/topics/key-specs#logical-operation-flags) for information about the meaning of the key flags. 10 | 11 | @return 12 | 13 | @array-reply: list of keys from your command. 14 | Each element of the array is an array containing key name in the first entry, and flags in the second. 15 | 16 | @examples 17 | 18 | ```cli 19 | COMMAND GETKEYS MSET a b c d e f 20 | COMMAND GETKEYS EVAL "not consulted" 3 key1 key2 key3 arg1 arg2 arg3 argN 21 | COMMAND GETKEYSANDFLAGS LMOVE mylist1 mylist2 left left 22 | ``` 23 | -------------------------------------------------------------------------------- /iredis/data/commands/command-help.md: -------------------------------------------------------------------------------- 1 | The `COMMAND HELP` command returns a helpful text describing the different subcommands. 2 | 3 | @return 4 | 5 | @array-reply: a list of subcommands and their descriptions 6 | -------------------------------------------------------------------------------- /iredis/data/commands/command-info.md: -------------------------------------------------------------------------------- 1 | Returns @array-reply of details about multiple Redis commands. 2 | 3 | Same result format as `COMMAND` except you can specify which commands 4 | get returned. 5 | 6 | If you request details about non-existing commands, their return 7 | position will be nil. 8 | 9 | 10 | @return 11 | 12 | @array-reply: nested list of command details. 13 | 14 | @examples 15 | 16 | ```cli 17 | COMMAND INFO get set eval 18 | COMMAND INFO foo evalsha config bar 19 | ``` 20 | -------------------------------------------------------------------------------- /iredis/data/commands/command-list.md: -------------------------------------------------------------------------------- 1 | Return an array of the server's command names. 2 | 3 | You can use the optional _FILTERBY_ modifier to apply one of the following filters: 4 | 5 | - **MODULE module-name**: get the commands that belong to the module specified by _module-name_. 6 | - **ACLCAT category**: get the commands in the [ACL category](/docs/manual/security/acl/#command-categories) specified by _category_. 7 | - **PATTERN pattern**: get the commands that match the given glob-like _pattern_. 8 | 9 | @return 10 | 11 | @array-reply: a list of command names. 12 | -------------------------------------------------------------------------------- /iredis/data/commands/config-help.md: -------------------------------------------------------------------------------- 1 | The `CONFIG HELP` command returns a helpful text describing the different subcommands. 2 | 3 | @return 4 | 5 | @array-reply: a list of subcommands and their descriptions 6 | -------------------------------------------------------------------------------- /iredis/data/commands/config-resetstat.md: -------------------------------------------------------------------------------- 1 | Resets the statistics reported by Redis using the `INFO` command. 2 | 3 | These are the counters that are reset: 4 | 5 | * Keyspace hits 6 | * Keyspace misses 7 | * Number of commands processed 8 | * Number of connections received 9 | * Number of expired keys 10 | * Number of rejected connections 11 | * Latest fork(2) time 12 | * The `aof_delayed_fsync` counter 13 | 14 | @return 15 | 16 | @simple-string-reply: always `OK`. 17 | -------------------------------------------------------------------------------- /iredis/data/commands/config.md: -------------------------------------------------------------------------------- 1 | This is a container command for runtime configuration commands. 2 | 3 | To see the list of available commands you can call `CONFIG HELP`. 4 | -------------------------------------------------------------------------------- /iredis/data/commands/copy.md: -------------------------------------------------------------------------------- 1 | This command copies the value stored at the `source` key to the `destination` 2 | key. 3 | 4 | By default, the `destination` key is created in the logical database used by the 5 | connection. The `DB` option allows specifying an alternative logical database 6 | index for the destination key. 7 | 8 | The command returns an error when the `destination` key already exists. The 9 | `REPLACE` option removes the `destination` key before copying the value to it. 10 | 11 | @return 12 | 13 | @integer-reply, specifically: 14 | 15 | * `1` if `source` was copied. 16 | * `0` if `source` was not copied. 17 | 18 | @examples 19 | 20 | ``` 21 | SET dolly "sheep" 22 | COPY dolly clone 23 | GET clone 24 | ``` -------------------------------------------------------------------------------- /iredis/data/commands/dbsize.md: -------------------------------------------------------------------------------- 1 | Return the number of keys in the currently-selected database. 2 | 3 | @return 4 | 5 | @integer-reply 6 | -------------------------------------------------------------------------------- /iredis/data/commands/debug-object.md: -------------------------------------------------------------------------------- 1 | `DEBUG OBJECT` is a debugging command that should not be used by clients. Check 2 | the `OBJECT` command instead. 3 | 4 | @return 5 | 6 | @simple-string-reply 7 | -------------------------------------------------------------------------------- /iredis/data/commands/debug-segfault.md: -------------------------------------------------------------------------------- 1 | `DEBUG SEGFAULT` performs an invalid memory access that crashes Redis. It is 2 | used to simulate bugs during the development. 3 | 4 | @return 5 | 6 | @simple-string-reply 7 | -------------------------------------------------------------------------------- /iredis/data/commands/debug.md: -------------------------------------------------------------------------------- 1 | The `DEBUG` command is an internal command. 2 | It is meant to be used for developing and testing Redis. -------------------------------------------------------------------------------- /iredis/data/commands/decr.md: -------------------------------------------------------------------------------- 1 | Decrements the number stored at `key` by one. 2 | If the key does not exist, it is set to `0` before performing the operation. 3 | An error is returned if the key contains a value of the wrong type or contains a 4 | string that can not be represented as integer. 5 | This operation is limited to **64 bit signed integers**. 6 | 7 | See `INCR` for extra information on increment/decrement operations. 8 | 9 | @return 10 | 11 | @integer-reply: the value of `key` after the decrement 12 | 13 | @examples 14 | 15 | ```cli 16 | SET mykey "10" 17 | DECR mykey 18 | SET mykey "234293482390480948029348230948" 19 | DECR mykey 20 | ``` 21 | -------------------------------------------------------------------------------- /iredis/data/commands/decrby.md: -------------------------------------------------------------------------------- 1 | Decrements the number stored at `key` by `decrement`. 2 | If the key does not exist, it is set to `0` before performing the operation. 3 | An error is returned if the key contains a value of the wrong type or contains a 4 | string that can not be represented as integer. 5 | This operation is limited to 64 bit signed integers. 6 | 7 | See `INCR` for extra information on increment/decrement operations. 8 | 9 | @return 10 | 11 | @integer-reply: the value of `key` after the decrement 12 | 13 | @examples 14 | 15 | ```cli 16 | SET mykey "10" 17 | DECRBY mykey 3 18 | ``` 19 | -------------------------------------------------------------------------------- /iredis/data/commands/del.md: -------------------------------------------------------------------------------- 1 | Removes the specified keys. 2 | A key is ignored if it does not exist. 3 | 4 | @return 5 | 6 | @integer-reply: The number of keys that were removed. 7 | 8 | @examples 9 | 10 | ```cli 11 | SET key1 "Hello" 12 | SET key2 "World" 13 | DEL key1 key2 key3 14 | ``` 15 | -------------------------------------------------------------------------------- /iredis/data/commands/discard.md: -------------------------------------------------------------------------------- 1 | Flushes all previously queued commands in a [transaction][tt] and restores the 2 | connection state to normal. 3 | 4 | [tt]: /topics/transactions 5 | 6 | If `WATCH` was used, `DISCARD` unwatches all keys watched by the connection. 7 | 8 | @return 9 | 10 | @simple-string-reply: always `OK`. 11 | -------------------------------------------------------------------------------- /iredis/data/commands/dump.md: -------------------------------------------------------------------------------- 1 | Serialize the value stored at key in a Redis-specific format and return it to 2 | the user. 3 | The returned value can be synthesized back into a Redis key using the `RESTORE` 4 | command. 5 | 6 | The serialization format is opaque and non-standard, however it has a few 7 | semantic characteristics: 8 | 9 | * It contains a 64-bit checksum that is used to make sure errors will be 10 | detected. 11 | The `RESTORE` command makes sure to check the checksum before synthesizing a 12 | key using the serialized value. 13 | * Values are encoded in the same format used by RDB. 14 | * An RDB version is encoded inside the serialized value, so that different Redis 15 | versions with incompatible RDB formats will refuse to process the serialized 16 | value. 17 | 18 | The serialized value does NOT contain expire information. 19 | In order to capture the time to live of the current value the `PTTL` command 20 | should be used. 21 | 22 | If `key` does not exist a nil bulk reply is returned. 23 | 24 | @return 25 | 26 | @bulk-string-reply: the serialized value. 27 | 28 | @examples 29 | 30 | ```cli 31 | SET mykey 10 32 | DUMP mykey 33 | ``` 34 | -------------------------------------------------------------------------------- /iredis/data/commands/echo.md: -------------------------------------------------------------------------------- 1 | Returns `message`. 2 | 3 | @return 4 | 5 | @bulk-string-reply 6 | 7 | @examples 8 | 9 | ```cli 10 | ECHO "Hello World!" 11 | ``` 12 | -------------------------------------------------------------------------------- /iredis/data/commands/eval.md: -------------------------------------------------------------------------------- 1 | Invoke the execution of a server-side Lua script. 2 | 3 | The first argument is the script's source code. 4 | Scripts are written in [Lua](https://lua.org) and executed by the embedded [Lua 5.1](/topics/lua-api) interpreter in Redis. 5 | 6 | The second argument is the number of input key name arguments, followed by all the keys accessed by the script. 7 | These names of input keys are available to the script as the [_KEYS_ global runtime variable](/topics/lua-api#the-keys-global-variable) 8 | Any additional input arguments **should not** represent names of keys. 9 | 10 | **Important:** 11 | 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. 12 | The script **should only** access keys whose names are given as input arguments. 13 | Scripts **should never** access keys with programmatically-generated names or based on the contents of data structures stored in the database. 14 | 15 | Please refer to the [Redis Programmability](/topics/programmability) and [Introduction to Eval Scripts](/topics/eval-intro) for more information about Lua scripts. 16 | 17 | @examples 18 | 19 | The following example will run a script that returns the first argument that it gets. 20 | 21 | ``` 22 | > EVAL "return ARGV[1]" 0 hello 23 | "hello" 24 | ``` 25 | -------------------------------------------------------------------------------- /iredis/data/commands/eval_ro.md: -------------------------------------------------------------------------------- 1 | This is a read-only variant of the `EVAL` command that cannot execute commands that modify data. 2 | 3 | For more information about when to use this command vs `EVAL`, please refer to [Read-only scripts](/docs/manual/programmability/#read-only_scripts). 4 | 5 | For more information about `EVAL` scripts please refer to [Introduction to Eval Scripts](/topics/eval-intro). 6 | 7 | @examples 8 | 9 | ``` 10 | > SET mykey "Hello" 11 | OK 12 | 13 | > EVAL_RO "return redis.call('GET', KEYS[1])" 1 mykey 14 | "Hello" 15 | 16 | > EVAL_RO "return redis.call('DEL', KEYS[1])" 1 mykey 17 | (error) ERR Error running script (call to b0d697da25b13e49157b2c214a4033546aba2104): @user_script:1: @user_script: 1: Write commands are not allowed from read-only scripts. 18 | ``` 19 | -------------------------------------------------------------------------------- /iredis/data/commands/evalsha.md: -------------------------------------------------------------------------------- 1 | Evaluate a script from the server's cache by its SHA1 digest. 2 | 3 | The server caches scripts by using the `SCRIPT LOAD` command. 4 | The command is otherwise identical to `EVAL`. 5 | 6 | Please refer to the [Redis Programmability](/topics/programmability) and [Introduction to Eval Scripts](/topics/eval-intro) for more information about Lua scripts. 7 | -------------------------------------------------------------------------------- /iredis/data/commands/evalsha_ro.md: -------------------------------------------------------------------------------- 1 | This is a read-only variant of the `EVALSHA` command that cannot execute commands that modify data. 2 | 3 | For more information about when to use this command vs `EVALSHA`, please refer to [Read-only scripts](/docs/manual/programmability/#read-only_scripts). 4 | 5 | For more information about `EVALSHA` scripts please refer to [Introduction to Eval Scripts](/topics/eval-intro). 6 | -------------------------------------------------------------------------------- /iredis/data/commands/exec.md: -------------------------------------------------------------------------------- 1 | Executes all previously queued commands in a [transaction][tt] and restores the 2 | connection state to normal. 3 | 4 | [tt]: /topics/transactions 5 | 6 | When using `WATCH`, `EXEC` will execute commands only if the watched keys were 7 | not modified, allowing for a [check-and-set mechanism][ttc]. 8 | 9 | [ttc]: /topics/transactions#cas 10 | 11 | @return 12 | 13 | @array-reply: each element being the reply to each of the commands in the 14 | atomic transaction. 15 | 16 | When using `WATCH`, `EXEC` can return a @nil-reply if the execution was aborted. 17 | -------------------------------------------------------------------------------- /iredis/data/commands/exists.md: -------------------------------------------------------------------------------- 1 | Returns if `key` exists. 2 | 3 | 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. 4 | 5 | @return 6 | 7 | @integer-reply, specifically the number of keys that exist from those specified as arguments. 8 | 9 | @examples 10 | 11 | ```cli 12 | SET key1 "Hello" 13 | EXISTS key1 14 | EXISTS nosuchkey 15 | SET key2 "World" 16 | EXISTS key1 key2 nosuchkey 17 | ``` 18 | -------------------------------------------------------------------------------- /iredis/data/commands/expiretime.md: -------------------------------------------------------------------------------- 1 | Returns the absolute Unix timestamp (since January 1, 1970) in seconds at which the given key will expire. 2 | 3 | See also the `PEXPIRETIME` command which returns the same information with milliseconds resolution. 4 | 5 | @return 6 | 7 | @integer-reply: Expiration Unix timestamp in seconds, or a negative value in order to signal an error (see the description below). 8 | 9 | * The command returns `-1` if the key exists but has no associated expiration time. 10 | * The command returns `-2` if the key does not exist. 11 | 12 | @examples 13 | 14 | ```cli 15 | SET mykey "Hello" 16 | EXPIREAT mykey 33177117420 17 | EXPIRETIME mykey 18 | ``` 19 | -------------------------------------------------------------------------------- /iredis/data/commands/fcall_ro.md: -------------------------------------------------------------------------------- 1 | This is a read-only variant of the `FCALL` command that cannot execute commands that modify data. 2 | 3 | For more information about when to use this command vs `FCALL`, please refer to [Read-only scripts](/docs/manual/programmability/#read-only_scripts). 4 | 5 | For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). 6 | -------------------------------------------------------------------------------- /iredis/data/commands/flushall.md: -------------------------------------------------------------------------------- 1 | Delete all the keys of all the existing databases, not just the currently selected one. 2 | This command never fails. 3 | 4 | By default, `FLUSHALL` will synchronously flush all the databases. 5 | Starting with Redis 6.2, setting the **lazyfree-lazy-user-flush** configuration directive to "yes" changes the default flush mode to asynchronous. 6 | 7 | It is possible to use one of the following modifiers to dictate the flushing mode explicitly: 8 | 9 | * `ASYNC`: flushes the databases asynchronously 10 | * `!SYNC`: flushes the databases synchronously 11 | 12 | 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. 13 | 14 | @return 15 | 16 | @simple-string-reply 17 | 18 | ## Behavior change history 19 | 20 | * `>= 6.2.0`: Default flush behavior now configurable by the **lazyfree-lazy-user-flush** configuration directive. -------------------------------------------------------------------------------- /iredis/data/commands/flushdb.md: -------------------------------------------------------------------------------- 1 | Delete all the keys of the currently selected DB. 2 | This command never fails. 3 | 4 | By default, `FLUSHDB` will synchronously flush all keys from the database. 5 | Starting with Redis 6.2, setting the **lazyfree-lazy-user-flush** configuration directive to "yes" changes the default flush mode to asynchronous. 6 | 7 | It is possible to use one of the following modifiers to dictate the flushing mode explicitly: 8 | 9 | * `ASYNC`: flushes the database asynchronously 10 | * `!SYNC`: flushes the database synchronously 11 | 12 | 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. 13 | 14 | @return 15 | 16 | @simple-string-reply 17 | 18 | ## Behavior change history 19 | 20 | * `>= 6.2.0`: Default flush behavior now configurable by the **lazyfree-lazy-user-flush** configuration directive. -------------------------------------------------------------------------------- /iredis/data/commands/function-delete.md: -------------------------------------------------------------------------------- 1 | Delete a library and all its functions. 2 | 3 | This command deletes the library called _library-name_ and all functions in it. 4 | If the library doesn't exist, the server returns an error. 5 | 6 | For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). 7 | 8 | @return 9 | 10 | @simple-string-reply 11 | 12 | @examples 13 | 14 | ``` 15 | redis> FUNCTION LOAD Lua mylib "redis.register_function('myfunc', function(keys, args) return 'hello' end)" 16 | OK 17 | redis> FCALL myfunc 0 18 | "hello" 19 | redis> FUNCTION DELETE mylib 20 | OK 21 | redis> FCALL myfunc 0 22 | (error) ERR Function not found 23 | ``` 24 | -------------------------------------------------------------------------------- /iredis/data/commands/function-dump.md: -------------------------------------------------------------------------------- 1 | Return the serialized payload of loaded libraries. 2 | You can restore the serialized payload later with the `FUNCTION RESTORE` command. 3 | 4 | For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). 5 | 6 | @return 7 | 8 | @bulk-string-reply: the serialized payload 9 | 10 | @examples 11 | 12 | The following example shows how to dump loaded libraries using `FUNCTION DUMP` and then it calls `FUNCTION FLUSH` deletes all the libraries. 13 | Then, it restores the original libraries from the serialized payload with `FUNCTION RESTORE`. 14 | 15 | ``` 16 | redis> FUNCTION DUMP 17 | "\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" 18 | redis> FUNCTION FLUSH 19 | OK 20 | 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" 21 | OK 22 | redis> FUNCTION LIST 23 | 1) 1) "library_name" 24 | 2) "mylib" 25 | 3) "engine" 26 | 4) "LUA" 27 | 5) "description" 28 | 6) (nil) 29 | 7) "functions" 30 | 8) 1) 1) "name" 31 | 2) "myfunc" 32 | 3) "description" 33 | 4) (nil) 34 | ``` 35 | -------------------------------------------------------------------------------- /iredis/data/commands/function-flush.md: -------------------------------------------------------------------------------- 1 | Deletes all the libraries. 2 | 3 | Unless called with the optional mode argument, the `lazyfree-lazy-user-flush` configuration directive sets the effective behavior. Valid modes are: 4 | 5 | * `ASYNC`: Asynchronously flush the libraries. 6 | * `!SYNC`: Synchronously flush the libraries. 7 | 8 | For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). 9 | 10 | @return 11 | 12 | @simple-string-reply 13 | -------------------------------------------------------------------------------- /iredis/data/commands/function-help.md: -------------------------------------------------------------------------------- 1 | The `FUNCTION HELP` command returns a helpful text describing the different subcommands. 2 | 3 | @return 4 | 5 | @array-reply: a list of subcommands and their descriptions 6 | -------------------------------------------------------------------------------- /iredis/data/commands/function-kill.md: -------------------------------------------------------------------------------- 1 | Kill a function that is currently executing. 2 | 3 | 4 | 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). 5 | 6 | For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). 7 | 8 | @return 9 | 10 | @simple-string-reply 11 | -------------------------------------------------------------------------------- /iredis/data/commands/function-list.md: -------------------------------------------------------------------------------- 1 | Return information about the functions and libraries. 2 | 3 | You can use the optional `LIBRARYNAME` argument to specify a pattern for matching library names. 4 | The optional `WITHCODE` modifier will cause the server to include the libraries source implementation in the reply. 5 | 6 | The following information is provided for each of the libraries in the response: 7 | 8 | * **library_name:** the name of the library. 9 | * **engine:** the engine of the library. 10 | * **functions:** the list of functions in the library. 11 | Each function has the following fields: 12 | * **name:** the name of the function. 13 | * **description:** the function's description. 14 | * **flags:** an array of [function flags](/docs/manual/programmability/functions-intro/#function-flags). 15 | * **library_code:** the library's source code (when given the `WITHCODE` modifier). 16 | 17 | For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). 18 | 19 | @return 20 | 21 | @array-reply 22 | -------------------------------------------------------------------------------- /iredis/data/commands/function-restore.md: -------------------------------------------------------------------------------- 1 | Restore libraries from the serialized payload. 2 | 3 | You can use the optional _policy_ argument to provide a policy for handling existing libraries. 4 | The following policies are allowed: 5 | 6 | * **APPEND:** appends the restored libraries to the existing libraries and aborts on collision. 7 | This is the default policy. 8 | * **FLUSH:** deletes all existing libraries before restoring the payload. 9 | * **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. 10 | 11 | For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). 12 | 13 | @return 14 | 15 | @simple-string-reply 16 | -------------------------------------------------------------------------------- /iredis/data/commands/function-stats.md: -------------------------------------------------------------------------------- 1 | Return information about the function that's currently running and information about the available execution engines. 2 | 3 | The reply is map with two keys: 4 | 5 | 1. `running_script`: information about the running script. 6 | If there's no in-flight function, the server replies with a _nil_. 7 | Otherwise, this is a map with the following keys: 8 | * **name:** the name of the function. 9 | * **command:** the command and arguments used for invoking the function. 10 | * **duration_ms:** the function's runtime duration in milliseconds. 11 | 2. `engines`: this is a map of maps. Each entry in the map represent a single engine. 12 | Engine map contains statistics about the engine like number of functions and number of libraries. 13 | 14 | 15 | You can use this command to inspect the invocation of a long-running function and decide whether kill it with the `FUNCTION KILL` command. 16 | 17 | For more information please refer to [Introduction to Redis Functions](/topics/functions-intro). 18 | 19 | @return 20 | 21 | @array-reply -------------------------------------------------------------------------------- /iredis/data/commands/function.md: -------------------------------------------------------------------------------- 1 | This is a container command for function commands. 2 | 3 | To see the list of available commands you can call `FUNCTION HELP`. -------------------------------------------------------------------------------- /iredis/data/commands/geodecode.md: -------------------------------------------------------------------------------- 1 | Geospatial Redis commands encode positions of objects in a single 52 bit 2 | integer, using a technique called geohash. Those 52 bit integers are: 3 | 4 | 1. Returned by `GEOAENCODE` as return value. 5 | 2. Used by `GEOADD` as sorted set scores of members. 6 | 7 | The `GEODECODE` command is able to translate the 52 bit integers back into a 8 | position expressed as longitude and latitude. The command also returns the 9 | corners of the box that the 52 bit integer identifies on the earth surface, 10 | since each 52 integer actually represent not a single point, but a small area. 11 | 12 | This command usefulness is limited to the rare situations where you want to 13 | fetch raw data from the sorted set, for example with `ZRANGE`, and later need to 14 | decode the scores into positions. The other obvious use is debugging. 15 | 16 | @return 17 | 18 | @array-reply, specifically: 19 | 20 | The command returns an array of three elements. Each element of the main array 21 | is an array of two elements, specifying a longitude and a latitude. So the 22 | returned value is in the following form: 23 | 24 | - center-longitude, center-latitude 25 | - min-longitude, min-latitude 26 | - max-longitude, max-latitude 27 | 28 | @examples 29 | 30 | ```cli 31 | GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" 32 | ZSCORE Sicily "Palermo" 33 | GEODECODE 3479099956230698 34 | ``` 35 | -------------------------------------------------------------------------------- /iredis/data/commands/geodist.md: -------------------------------------------------------------------------------- 1 | Return the distance between two members in the geospatial index represented by the sorted set. 2 | 3 | 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. 4 | 5 | If one or both the members are missing, the command returns NULL. 6 | 7 | The unit must be one of the following, and defaults to meters: 8 | 9 | * **m** for meters. 10 | * **km** for kilometers. 11 | * **mi** for miles. 12 | * **ft** for feet. 13 | 14 | The distance is computed assuming that the Earth is a perfect sphere, so errors up to 0.5% are possible in edge cases. 15 | 16 | @return 17 | 18 | @bulk-string-reply, specifically: 19 | 20 | The command returns the distance as a double (represented as a string) 21 | in the specified unit, or NULL if one or both the elements are missing. 22 | 23 | @examples 24 | 25 | ```cli 26 | GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" 27 | GEODIST Sicily Palermo Catania 28 | GEODIST Sicily Palermo Catania km 29 | GEODIST Sicily Palermo Catania mi 30 | GEODIST Sicily Foo Bar 31 | ``` 32 | -------------------------------------------------------------------------------- /iredis/data/commands/geopos.md: -------------------------------------------------------------------------------- 1 | Return the positions (longitude,latitude) of all the specified members of the geospatial index represented by the sorted set at *key*. 2 | 3 | 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. 4 | 5 | The command can accept a variable number of arguments so it always returns an array of positions even when a single element is specified. 6 | 7 | @return 8 | 9 | @array-reply, specifically: 10 | 11 | The command returns an array where each element is a two elements array 12 | representing longitude and latitude (x,y) of each member name passed as 13 | argument to the command. 14 | 15 | Non existing elements are reported as NULL elements of the array. 16 | 17 | @examples 18 | 19 | ```cli 20 | GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" 21 | GEOPOS Sicily Palermo Catania NonExisting 22 | ``` 23 | -------------------------------------------------------------------------------- /iredis/data/commands/georadius_ro.md: -------------------------------------------------------------------------------- 1 | Read-only variant of the `GEORADIUS` command. 2 | 3 | This command is identical to the `GEORADIUS` command, except that it doesn't support the optional `STORE` and `STOREDIST` parameters. 4 | 5 | @return 6 | 7 | @array-reply: An array with each entry being the corresponding result of the subcommand given at the same position. 8 | -------------------------------------------------------------------------------- /iredis/data/commands/georadiusbymember.md: -------------------------------------------------------------------------------- 1 | This command is exactly like `GEORADIUS` with the sole difference that instead 2 | 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. 3 | 4 | The position of the specified member is used as the center of the query. 5 | 6 | Please check the example below and the `GEORADIUS` documentation for more information about the command and its options. 7 | 8 | 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. 9 | 10 | @examples 11 | 12 | ```cli 13 | GEOADD Sicily 13.583333 37.316667 "Agrigento" 14 | GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" 15 | GEORADIUSBYMEMBER Sicily Agrigento 100 km 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/georadiusbymember_ro.md: -------------------------------------------------------------------------------- 1 | Read-only variant of the `GEORADIUSBYMEMBER` command. 2 | 3 | This command is identical to the `GEORADIUSBYMEMBER` command, except that it doesn't support the optional `STORE` and `STOREDIST` parameters. 4 | -------------------------------------------------------------------------------- /iredis/data/commands/geosearchstore.md: -------------------------------------------------------------------------------- 1 | This command is like `GEOSEARCH`, but stores the result in destination key. 2 | 3 | This command comes in place of the now deprecated `GEORADIUS` and `GEORADIUSBYMEMBER`. 4 | 5 | By default, it stores the results in the `destination` sorted set with their geospatial information. 6 | 7 | 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. 8 | 9 | @return 10 | 11 | @integer-reply: the number of elements in the resulting set. 12 | 13 | @examples 14 | 15 | ```cli 16 | GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" 17 | GEOADD Sicily 12.758489 38.788135 "edge1" 17.241510 38.788135 "edge2" 18 | GEOSEARCHSTORE key1 Sicily FROMLONLAT 15 37 BYBOX 400 400 km ASC COUNT 3 19 | GEOSEARCH key1 FROMLONLAT 15 37 BYBOX 400 400 km ASC WITHCOORD WITHDIST WITHHASH 20 | GEOSEARCHSTORE key2 Sicily FROMLONLAT 15 37 BYBOX 400 400 km ASC COUNT 3 STOREDIST 21 | ZRANGE key2 0 -1 WITHSCORES 22 | ``` -------------------------------------------------------------------------------- /iredis/data/commands/get.md: -------------------------------------------------------------------------------- 1 | Get the value of `key`. 2 | If the key does not exist the special value `nil` is returned. 3 | An error is returned if the value stored at `key` is not a string, because `GET` 4 | only handles string values. 5 | 6 | @return 7 | 8 | @bulk-string-reply: the value of `key`, or `nil` when `key` does not exist. 9 | 10 | @examples 11 | 12 | ```cli 13 | GET nonexisting 14 | SET mykey "Hello" 15 | GET mykey 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/getbit.md: -------------------------------------------------------------------------------- 1 | Returns the bit value at _offset_ in the string value stored at _key_. 2 | 3 | When _offset_ is beyond the string length, the string is assumed to be a 4 | contiguous space with 0 bits. 5 | When _key_ does not exist it is assumed to be an empty string, so _offset_ is 6 | always out of range and the value is also assumed to be a contiguous space with 7 | 0 bits. 8 | 9 | @return 10 | 11 | @integer-reply: the bit value stored at _offset_. 12 | 13 | @examples 14 | 15 | ```cli 16 | SETBIT mykey 7 1 17 | GETBIT mykey 0 18 | GETBIT mykey 7 19 | GETBIT mykey 100 20 | ``` 21 | -------------------------------------------------------------------------------- /iredis/data/commands/getdel.md: -------------------------------------------------------------------------------- 1 | Get the value of `key` and delete the key. 2 | 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). 3 | 4 | @return 5 | 6 | @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. 7 | 8 | @examples 9 | 10 | ```cli 11 | SET mykey "Hello" 12 | GETDEL mykey 13 | GET mykey 14 | ``` 15 | -------------------------------------------------------------------------------- /iredis/data/commands/getex.md: -------------------------------------------------------------------------------- 1 | Get the value of `key` and optionally set its expiration. 2 | `GETEX` is similar to `GET`, but is a write command with additional options. 3 | 4 | ## Options 5 | 6 | The `GETEX` command supports a set of options that modify its behavior: 7 | 8 | * `EX` *seconds* -- Set the specified expire time, in seconds. 9 | * `PX` *milliseconds* -- Set the specified expire time, in milliseconds. 10 | * `EXAT` *timestamp-seconds* -- Set the specified Unix time at which the key will expire, in seconds. 11 | * `PXAT` *timestamp-milliseconds* -- Set the specified Unix time at which the key will expire, in milliseconds. 12 | * `PERSIST` -- Remove the time to live associated with the key. 13 | 14 | @return 15 | 16 | @bulk-string-reply: the value of `key`, or `nil` when `key` does not exist. 17 | 18 | @examples 19 | 20 | ```cli 21 | SET mykey "Hello" 22 | GETEX mykey 23 | TTL mykey 24 | GETEX mykey EX 60 25 | TTL mykey 26 | ``` 27 | -------------------------------------------------------------------------------- /iredis/data/commands/getrange.md: -------------------------------------------------------------------------------- 1 | Returns the substring of the string value stored at `key`, determined by the 2 | offsets `start` and `end` (both are inclusive). 3 | Negative offsets can be used in order to provide an offset starting from the end 4 | of the string. 5 | So -1 means the last character, -2 the penultimate and so forth. 6 | 7 | The function handles out of range requests by limiting the resulting range to 8 | the actual length of the string. 9 | 10 | @return 11 | 12 | @bulk-string-reply 13 | 14 | @examples 15 | 16 | ```cli 17 | SET mykey "This is a string" 18 | GETRANGE mykey 0 3 19 | GETRANGE mykey -3 -1 20 | GETRANGE mykey 0 -1 21 | GETRANGE mykey 10 100 22 | ``` 23 | -------------------------------------------------------------------------------- /iredis/data/commands/getset.md: -------------------------------------------------------------------------------- 1 | Atomically sets `key` to `value` and returns the old value stored at `key`. 2 | Returns an error when `key` exists but does not hold a string value. Any 3 | previous time to live associated with the key is discarded on successful 4 | `SET` operation. 5 | 6 | ## Design pattern 7 | 8 | `GETSET` can be used together with `INCR` for counting with atomic reset. 9 | For example: a process may call `INCR` against the key `mycounter` every time 10 | some event occurs, but from time to time we need to get the value of the counter 11 | and reset it to zero atomically. 12 | This can be done using `GETSET mycounter "0"`: 13 | 14 | ```cli 15 | INCR mycounter 16 | GETSET mycounter "0" 17 | GET mycounter 18 | ``` 19 | 20 | @return 21 | 22 | @bulk-string-reply: the old value stored at `key`, or `nil` when `key` did not exist. 23 | 24 | @examples 25 | 26 | ```cli 27 | SET mykey "Hello" 28 | GETSET mykey "World" 29 | GET mykey 30 | ``` 31 | -------------------------------------------------------------------------------- /iredis/data/commands/hdel.md: -------------------------------------------------------------------------------- 1 | Removes the specified fields from the hash stored at `key`. 2 | Specified fields that do not exist within this hash are ignored. 3 | If `key` does not exist, it is treated as an empty hash and this command returns 4 | `0`. 5 | 6 | @return 7 | 8 | @integer-reply: the number of fields that were removed from the hash, not 9 | including specified but non existing fields. 10 | 11 | @examples 12 | 13 | ```cli 14 | HSET myhash field1 "foo" 15 | HDEL myhash field1 16 | HDEL myhash field2 17 | ``` 18 | -------------------------------------------------------------------------------- /iredis/data/commands/hexists.md: -------------------------------------------------------------------------------- 1 | Returns if `field` is an existing field in the hash stored at `key`. 2 | 3 | @return 4 | 5 | @integer-reply, specifically: 6 | 7 | * `1` if the hash contains `field`. 8 | * `0` if the hash does not contain `field`, or `key` does not exist. 9 | 10 | @examples 11 | 12 | ```cli 13 | HSET myhash field1 "foo" 14 | HEXISTS myhash field1 15 | HEXISTS myhash field2 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/hget.md: -------------------------------------------------------------------------------- 1 | Returns the value associated with `field` in the hash stored at `key`. 2 | 3 | @return 4 | 5 | @bulk-string-reply: the value associated with `field`, or `nil` when `field` is not 6 | present in the hash or `key` does not exist. 7 | 8 | @examples 9 | 10 | ```cli 11 | HSET myhash field1 "foo" 12 | HGET myhash field1 13 | HGET myhash field2 14 | ``` 15 | -------------------------------------------------------------------------------- /iredis/data/commands/hgetall.md: -------------------------------------------------------------------------------- 1 | Returns all fields and values of the hash stored at `key`. 2 | In the returned value, every field name is followed by its value, so the length 3 | of the reply is twice the size of the hash. 4 | 5 | @return 6 | 7 | @array-reply: list of fields and their values stored in the hash, or an 8 | empty list when `key` does not exist. 9 | 10 | @examples 11 | 12 | ```cli 13 | HSET myhash field1 "Hello" 14 | HSET myhash field2 "World" 15 | HGETALL myhash 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/hincrby.md: -------------------------------------------------------------------------------- 1 | Increments the number stored at `field` in the hash stored at `key` by 2 | `increment`. 3 | If `key` does not exist, a new key holding a hash is created. 4 | If `field` does not exist the value is set to `0` before the operation is 5 | performed. 6 | 7 | The range of values supported by `HINCRBY` is limited to 64 bit signed integers. 8 | 9 | @return 10 | 11 | @integer-reply: the value at `field` after the increment operation. 12 | 13 | @examples 14 | 15 | Since the `increment` argument is signed, both increment and decrement 16 | operations can be performed: 17 | 18 | ```cli 19 | HSET myhash field 5 20 | HINCRBY myhash field 1 21 | HINCRBY myhash field -1 22 | HINCRBY myhash field -10 23 | ``` 24 | -------------------------------------------------------------------------------- /iredis/data/commands/hincrbyfloat.md: -------------------------------------------------------------------------------- 1 | Increment the specified `field` of a hash stored at `key`, and representing a 2 | floating point number, by the specified `increment`. If the increment value 3 | is negative, the result is to have the hash field value **decremented** instead of incremented. 4 | If the field does not exist, it is set to `0` before performing the operation. 5 | An error is returned if one of the following conditions occur: 6 | 7 | * The field contains a value of the wrong type (not a string). 8 | * The current field content or the specified increment are not parsable as a 9 | double precision floating point number. 10 | 11 | The exact behavior of this command is identical to the one of the `INCRBYFLOAT` 12 | command, please refer to the documentation of `INCRBYFLOAT` for further 13 | information. 14 | 15 | @return 16 | 17 | @bulk-string-reply: the value of `field` after the increment. 18 | 19 | @examples 20 | 21 | ```cli 22 | HSET mykey field 10.50 23 | HINCRBYFLOAT mykey field 0.1 24 | HINCRBYFLOAT mykey field -5 25 | HSET mykey field 5.0e3 26 | HINCRBYFLOAT mykey field 2.0e2 27 | ``` 28 | 29 | ## Implementation details 30 | 31 | The command is always propagated in the replication link and the Append Only 32 | File as a `HSET` operation, so that differences in the underlying floating point 33 | math implementation will not be sources of inconsistency. 34 | -------------------------------------------------------------------------------- /iredis/data/commands/hkeys.md: -------------------------------------------------------------------------------- 1 | Returns all field names in the hash stored at `key`. 2 | 3 | @return 4 | 5 | @array-reply: list of fields in the hash, or an empty list when `key` does 6 | not exist. 7 | 8 | @examples 9 | 10 | ```cli 11 | HSET myhash field1 "Hello" 12 | HSET myhash field2 "World" 13 | HKEYS myhash 14 | ``` 15 | -------------------------------------------------------------------------------- /iredis/data/commands/hlen.md: -------------------------------------------------------------------------------- 1 | Returns the number of fields contained in the hash stored at `key`. 2 | 3 | @return 4 | 5 | @integer-reply: number of fields in the hash, or `0` when `key` does not exist. 6 | 7 | @examples 8 | 9 | ```cli 10 | HSET myhash field1 "Hello" 11 | HSET myhash field2 "World" 12 | HLEN myhash 13 | ``` 14 | -------------------------------------------------------------------------------- /iredis/data/commands/hmget.md: -------------------------------------------------------------------------------- 1 | Returns the values associated with the specified `fields` in the hash stored at 2 | `key`. 3 | 4 | For every `field` that does not exist in the hash, a `nil` value is returned. 5 | Because non-existing keys are treated as empty hashes, running `HMGET` against 6 | a non-existing `key` will return a list of `nil` values. 7 | 8 | @return 9 | 10 | @array-reply: list of values associated with the given fields, in the same 11 | order as they are requested. 12 | 13 | ```cli 14 | HSET myhash field1 "Hello" 15 | HSET myhash field2 "World" 16 | HMGET myhash field1 field2 nofield 17 | ``` 18 | -------------------------------------------------------------------------------- /iredis/data/commands/hmset.md: -------------------------------------------------------------------------------- 1 | Sets the specified fields to their respective values in the hash stored at 2 | `key`. 3 | This command overwrites any specified fields already existing in the hash. 4 | If `key` does not exist, a new key holding a hash is created. 5 | 6 | @return 7 | 8 | @simple-string-reply 9 | 10 | @examples 11 | 12 | ```cli 13 | HMSET myhash field1 "Hello" field2 "World" 14 | HGET myhash field1 15 | HGET myhash field2 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/hscan.md: -------------------------------------------------------------------------------- 1 | See `SCAN` for `HSCAN` documentation. 2 | -------------------------------------------------------------------------------- /iredis/data/commands/hset.md: -------------------------------------------------------------------------------- 1 | Sets `field` in the hash stored at `key` to `value`. 2 | If `key` does not exist, a new key holding a hash is created. 3 | If `field` already exists in the hash, it is overwritten. 4 | 5 | @return 6 | 7 | @integer-reply: The number of fields that were added. 8 | 9 | @examples 10 | 11 | ```cli 12 | HSET myhash field1 "Hello" 13 | HGET myhash field1 14 | ``` 15 | -------------------------------------------------------------------------------- /iredis/data/commands/hsetnx.md: -------------------------------------------------------------------------------- 1 | Sets `field` in the hash stored at `key` to `value`, only if `field` does not 2 | yet exist. 3 | If `key` does not exist, a new key holding a hash is created. 4 | If `field` already exists, this operation has no effect. 5 | 6 | @return 7 | 8 | @integer-reply, specifically: 9 | 10 | * `1` if `field` is a new field in the hash and `value` was set. 11 | * `0` if `field` already exists in the hash and no operation was performed. 12 | 13 | @examples 14 | 15 | ```cli 16 | HSETNX myhash field "Hello" 17 | HSETNX myhash field "World" 18 | HGET myhash field 19 | ``` 20 | -------------------------------------------------------------------------------- /iredis/data/commands/hstrlen.md: -------------------------------------------------------------------------------- 1 | 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. 2 | 3 | @return 4 | 5 | @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. 6 | 7 | @examples 8 | 9 | ```cli 10 | HMSET myhash f1 HelloWorld f2 99 f3 -256 11 | HSTRLEN myhash f1 12 | HSTRLEN myhash f2 13 | HSTRLEN myhash f3 14 | ``` 15 | -------------------------------------------------------------------------------- /iredis/data/commands/hvals.md: -------------------------------------------------------------------------------- 1 | Returns all values in the hash stored at `key`. 2 | 3 | @return 4 | 5 | @array-reply: list of values in the hash, or an empty list when `key` does 6 | not exist. 7 | 8 | @examples 9 | 10 | ```cli 11 | HSET myhash field1 "Hello" 12 | HSET myhash field2 "World" 13 | HVALS myhash 14 | ``` 15 | -------------------------------------------------------------------------------- /iredis/data/commands/incrby.md: -------------------------------------------------------------------------------- 1 | Increments the number stored at `key` by `increment`. 2 | If the key does not exist, it is set to `0` before performing the operation. 3 | An error is returned if the key contains a value of the wrong type or contains a 4 | string that can not be represented as integer. 5 | This operation is limited to 64 bit signed integers. 6 | 7 | See `INCR` for extra information on increment/decrement operations. 8 | 9 | @return 10 | 11 | @integer-reply: the value of `key` after the increment 12 | 13 | @examples 14 | 15 | ```cli 16 | SET mykey "10" 17 | INCRBY mykey 5 18 | ``` 19 | -------------------------------------------------------------------------------- /iredis/data/commands/keys.md: -------------------------------------------------------------------------------- 1 | Returns all keys matching `pattern`. 2 | 3 | While the time complexity for this operation is O(N), the constant times are 4 | fairly low. 5 | For example, Redis running on an entry level laptop can scan a 1 million key 6 | database in 40 milliseconds. 7 | 8 | **Warning**: consider `KEYS` as a command that should only be used in production 9 | environments with extreme care. 10 | It may ruin performance when it is executed against large databases. 11 | This command is intended for debugging and special operations, such as changing 12 | your keyspace layout. 13 | Don't use `KEYS` in your regular application code. 14 | If you're looking for a way to find keys in a subset of your keyspace, consider 15 | using `SCAN` or [sets][tdts]. 16 | 17 | [tdts]: /topics/data-types#sets 18 | 19 | Supported glob-style patterns: 20 | 21 | * `h?llo` matches `hello`, `hallo` and `hxllo` 22 | * `h*llo` matches `hllo` and `heeeello` 23 | * `h[ae]llo` matches `hello` and `hallo,` but not `hillo` 24 | * `h[^e]llo` matches `hallo`, `hbllo`, ... but not `hello` 25 | * `h[a-b]llo` matches `hallo` and `hbllo` 26 | 27 | Use `\` to escape special characters if you want to match them verbatim. 28 | 29 | @return 30 | 31 | @array-reply: list of keys matching `pattern`. 32 | 33 | @examples 34 | 35 | ```cli 36 | MSET firstname Jack lastname Stuntman age 35 37 | KEYS *name* 38 | KEYS a?? 39 | KEYS * 40 | ``` 41 | -------------------------------------------------------------------------------- /iredis/data/commands/lastsave.md: -------------------------------------------------------------------------------- 1 | Return the UNIX TIME of the last DB save executed with success. 2 | A client may check if a `BGSAVE` command succeeded reading the `LASTSAVE` value, 3 | then issuing a `BGSAVE` command and checking at regular intervals every N 4 | seconds if `LASTSAVE` changed. 5 | 6 | @return 7 | 8 | @integer-reply: an UNIX time stamp. 9 | -------------------------------------------------------------------------------- /iredis/data/commands/latency-help.md: -------------------------------------------------------------------------------- 1 | The `LATENCY HELP` command returns a helpful text describing the different 2 | subcommands. 3 | 4 | For more information refer to the [Latency Monitoring Framework page][lm]. 5 | 6 | [lm]: /topics/latency-monitor 7 | 8 | @return 9 | 10 | @array-reply: a list of subcommands and their descriptions 11 | -------------------------------------------------------------------------------- /iredis/data/commands/latency-history.md: -------------------------------------------------------------------------------- 1 | The `LATENCY HISTORY` command returns the raw data of the `event`'s latency spikes time series. 2 | 3 | This is useful to an application that wants to fetch raw data in order to perform monitoring, display graphs, and so forth. 4 | 5 | The command will return up to 160 timestamp-latency pairs for the `event`. 6 | 7 | Valid values for `event` are: 8 | * `active-defrag-cycle` 9 | * `aof-fsync-always` 10 | * `aof-stat` 11 | * `aof-rewrite-diff-write` 12 | * `aof-rename` 13 | * `aof-write` 14 | * `aof-write-active-child` 15 | * `aof-write-alone` 16 | * `aof-write-pending-fsync` 17 | * `command` 18 | * `expire-cycle` 19 | * `eviction-cycle` 20 | * `eviction-del` 21 | * `fast-command` 22 | * `fork` 23 | * `rdb-unlink-temp-file` 24 | 25 | @examples 26 | 27 | ``` 28 | 127.0.0.1:6379> latency history command 29 | 1) 1) (integer) 1405067822 30 | 2) (integer) 251 31 | 2) 1) (integer) 1405067941 32 | 2) (integer) 1001 33 | ``` 34 | 35 | For more information refer to the [Latency Monitoring Framework page][lm]. 36 | 37 | [lm]: /topics/latency-monitor 38 | 39 | @return 40 | 41 | @array-reply: specifically: 42 | 43 | The command returns an array where each element is a two elements array 44 | representing the timestamp and the latency of the event. -------------------------------------------------------------------------------- /iredis/data/commands/latency-latest.md: -------------------------------------------------------------------------------- 1 | The `LATENCY LATEST` command reports the latest latency events logged. 2 | 3 | Each reported event has the following fields: 4 | 5 | * Event name. 6 | * Unix timestamp of the latest latency spike for the event. 7 | * Latest event latency in millisecond. 8 | * All-time maximum latency for this event. 9 | 10 | "All-time" means the maximum latency since the Redis instance was 11 | started, or the time that events were reset `LATENCY RESET`. 12 | 13 | @examples 14 | 15 | ``` 16 | 127.0.0.1:6379> debug sleep 1 17 | OK 18 | (1.00s) 19 | 127.0.0.1:6379> debug sleep .25 20 | OK 21 | 127.0.0.1:6379> latency latest 22 | 1) 1) "command" 23 | 2) (integer) 1405067976 24 | 3) (integer) 251 25 | 4) (integer) 1001 26 | ``` 27 | 28 | For more information refer to the [Latency Monitoring Framework page][lm]. 29 | 30 | [lm]: /topics/latency-monitor 31 | 32 | @return 33 | 34 | @array-reply: specifically: 35 | 36 | The command returns an array where each element is a four elements array 37 | representing the event's name, timestamp, latest and all-time latency measurements. 38 | -------------------------------------------------------------------------------- /iredis/data/commands/latency-reset.md: -------------------------------------------------------------------------------- 1 | The `LATENCY RESET` command resets the latency spikes time series of all, or only some, events. 2 | 3 | When the command is called without arguments, it resets all the 4 | events, discarding the currently logged latency spike events, and resetting 5 | the maximum event time register. 6 | 7 | It is possible to reset only specific events by providing the `event` names 8 | as arguments. 9 | 10 | Valid values for `event` are: 11 | * `active-defrag-cycle` 12 | * `aof-fsync-always` 13 | * `aof-stat` 14 | * `aof-rewrite-diff-write` 15 | * `aof-rename` 16 | * `aof-write` 17 | * `aof-write-active-child` 18 | * `aof-write-alone` 19 | * `aof-write-pending-fsync` 20 | * `command` 21 | * `expire-cycle` 22 | * `eviction-cycle` 23 | * `eviction-del` 24 | * `fast-command` 25 | * `fork` 26 | * `rdb-unlink-temp-file` 27 | 28 | For more information refer to the [Latency Monitoring Framework page][lm]. 29 | 30 | [lm]: /topics/latency-monitor 31 | 32 | @return 33 | 34 | @integer-reply: the number of event time series that were reset. 35 | -------------------------------------------------------------------------------- /iredis/data/commands/latency.md: -------------------------------------------------------------------------------- 1 | This is a container command for latency diagnostics commands. 2 | 3 | To see the list of available commands you can call `LATENCY HELP`. -------------------------------------------------------------------------------- /iredis/data/commands/lindex.md: -------------------------------------------------------------------------------- 1 | Returns the element at index `index` in the list stored at `key`. 2 | The index is zero-based, so `0` means the first element, `1` the second element 3 | and so on. 4 | Negative indices can be used to designate elements starting at the tail of the 5 | list. 6 | Here, `-1` means the last element, `-2` means the penultimate and so forth. 7 | 8 | When the value at `key` is not a list, an error is returned. 9 | 10 | @return 11 | 12 | @bulk-string-reply: the requested element, or `nil` when `index` is out of range. 13 | 14 | @examples 15 | 16 | ```cli 17 | LPUSH mylist "World" 18 | LPUSH mylist "Hello" 19 | LINDEX mylist 0 20 | LINDEX mylist -1 21 | LINDEX mylist 3 22 | ``` 23 | -------------------------------------------------------------------------------- /iredis/data/commands/linsert.md: -------------------------------------------------------------------------------- 1 | Inserts `element` in the list stored at `key` either before or after the reference 2 | value `pivot`. 3 | 4 | When `key` does not exist, it is considered an empty list and no operation is 5 | performed. 6 | 7 | An error is returned when `key` exists but does not hold a list value. 8 | 9 | @return 10 | 11 | @integer-reply: the length of the list after the insert operation, or `-1` when 12 | the value `pivot` was not found. 13 | 14 | @examples 15 | 16 | ```cli 17 | RPUSH mylist "Hello" 18 | RPUSH mylist "World" 19 | LINSERT mylist BEFORE "World" "There" 20 | LRANGE mylist 0 -1 21 | ``` 22 | -------------------------------------------------------------------------------- /iredis/data/commands/llen.md: -------------------------------------------------------------------------------- 1 | Returns the length of the list stored at `key`. 2 | If `key` does not exist, it is interpreted as an empty list and `0` is returned. 3 | An error is returned when the value stored at `key` is not a list. 4 | 5 | @return 6 | 7 | @integer-reply: the length of the list at `key`. 8 | 9 | @examples 10 | 11 | ```cli 12 | LPUSH mylist "World" 13 | LPUSH mylist "Hello" 14 | LLEN mylist 15 | ``` 16 | -------------------------------------------------------------------------------- /iredis/data/commands/lpop.md: -------------------------------------------------------------------------------- 1 | Removes and returns the first elements of the list stored at `key`. 2 | 3 | By default, the command pops a single element from the beginning of the list. 4 | When provided with the optional `count` argument, the reply will consist of up 5 | to `count` elements, depending on the list's length. 6 | 7 | @return 8 | 9 | When called without the `count` argument: 10 | 11 | @bulk-string-reply: the value of the first element, or `nil` when `key` does not exist. 12 | 13 | When called with the `count` argument: 14 | 15 | @array-reply: list of popped elements, or `nil` when `key` does not exist. 16 | 17 | @examples 18 | 19 | ```cli 20 | RPUSH mylist "one" "two" "three" "four" "five" 21 | LPOP mylist 22 | LPOP mylist 2 23 | LRANGE mylist 0 -1 24 | ``` 25 | -------------------------------------------------------------------------------- /iredis/data/commands/lpush.md: -------------------------------------------------------------------------------- 1 | Insert all the specified values at the head of the list stored at `key`. 2 | If `key` does not exist, it is created as empty list before performing the push 3 | operations. 4 | When `key` holds a value that is not a list, an error is returned. 5 | 6 | It is possible to push multiple elements using a single command call just 7 | specifying multiple arguments at the end of the command. 8 | Elements are inserted one after the other to the head of the list, from the 9 | leftmost element to the rightmost element. 10 | So for instance the command `LPUSH mylist a b c` will result into a list 11 | containing `c` as first element, `b` as second element and `a` as third element. 12 | 13 | @return 14 | 15 | @integer-reply: the length of the list after the push operations. 16 | 17 | @examples 18 | 19 | ```cli 20 | LPUSH mylist "world" 21 | LPUSH mylist "hello" 22 | LRANGE mylist 0 -1 23 | ``` 24 | -------------------------------------------------------------------------------- /iredis/data/commands/lpushx.md: -------------------------------------------------------------------------------- 1 | Inserts specified values at the head of the list stored at `key`, only if `key` 2 | already exists and holds a list. 3 | In contrary to `LPUSH`, no operation will be performed when `key` does not yet 4 | exist. 5 | 6 | @return 7 | 8 | @integer-reply: the length of the list after the push operation. 9 | 10 | @examples 11 | 12 | ```cli 13 | LPUSH mylist "World" 14 | LPUSHX mylist "Hello" 15 | LPUSHX myotherlist "Hello" 16 | LRANGE mylist 0 -1 17 | LRANGE myotherlist 0 -1 18 | ``` 19 | -------------------------------------------------------------------------------- /iredis/data/commands/lrem.md: -------------------------------------------------------------------------------- 1 | Removes the first `count` occurrences of elements equal to `element` from the list 2 | stored at `key`. 3 | The `count` argument influences the operation in the following ways: 4 | 5 | * `count > 0`: Remove elements equal to `element` moving from head to tail. 6 | * `count < 0`: Remove elements equal to `element` moving from tail to head. 7 | * `count = 0`: Remove all elements equal to `element`. 8 | 9 | For example, `LREM list -2 "hello"` will remove the last two occurrences of 10 | `"hello"` in the list stored at `list`. 11 | 12 | Note that non-existing keys are treated like empty lists, so when `key` does not 13 | exist, the command will always return `0`. 14 | 15 | @return 16 | 17 | @integer-reply: the number of removed elements. 18 | 19 | @examples 20 | 21 | ```cli 22 | RPUSH mylist "hello" 23 | RPUSH mylist "hello" 24 | RPUSH mylist "foo" 25 | RPUSH mylist "hello" 26 | LREM mylist -2 "hello" 27 | LRANGE mylist 0 -1 28 | ``` 29 | -------------------------------------------------------------------------------- /iredis/data/commands/lset.md: -------------------------------------------------------------------------------- 1 | Sets the list element at `index` to `element`. 2 | For more information on the `index` argument, see `LINDEX`. 3 | 4 | An error is returned for out of range indexes. 5 | 6 | @return 7 | 8 | @simple-string-reply 9 | 10 | @examples 11 | 12 | ```cli 13 | RPUSH mylist "one" 14 | RPUSH mylist "two" 15 | RPUSH mylist "three" 16 | LSET mylist 0 "four" 17 | LSET mylist -2 "five" 18 | LRANGE mylist 0 -1 19 | ``` 20 | -------------------------------------------------------------------------------- /iredis/data/commands/memory-doctor.md: -------------------------------------------------------------------------------- 1 | The `MEMORY DOCTOR` command reports about different memory-related issues that 2 | the Redis server experiences, and advises about possible remedies. 3 | 4 | @return 5 | 6 | @bulk-string-reply -------------------------------------------------------------------------------- /iredis/data/commands/memory-help.md: -------------------------------------------------------------------------------- 1 | The `MEMORY HELP` command returns a helpful text describing the different 2 | subcommands. 3 | 4 | @return 5 | 6 | @array-reply: a list of subcommands and their descriptions 7 | -------------------------------------------------------------------------------- /iredis/data/commands/memory-malloc-stats.md: -------------------------------------------------------------------------------- 1 | The `MEMORY MALLOC-STATS` command provides an internal statistics report from 2 | the memory allocator. 3 | 4 | This command is currently implemented only when using **jemalloc** as an 5 | allocator, and evaluates to a benign NOOP for all others. 6 | 7 | @return 8 | 9 | @bulk-string-reply: the memory allocator's internal statistics report 10 | -------------------------------------------------------------------------------- /iredis/data/commands/memory-purge.md: -------------------------------------------------------------------------------- 1 | The `MEMORY PURGE` command attempts to purge dirty pages so these can be 2 | reclaimed by the allocator. 3 | 4 | This command is currently implemented only when using **jemalloc** as an 5 | allocator, and evaluates to a benign NOOP for all others. 6 | 7 | @return 8 | 9 | @simple-string-reply 10 | -------------------------------------------------------------------------------- /iredis/data/commands/memory-usage.md: -------------------------------------------------------------------------------- 1 | The `MEMORY USAGE` command reports the number of bytes that a key and its value 2 | require to be stored in RAM. 3 | 4 | The reported usage is the total of memory allocations for data and 5 | administrative overheads that a key its value require. 6 | 7 | For nested data types, the optional `SAMPLES` option can be provided, where 8 | `count` is the number of sampled nested values. By default, this option is set 9 | to `5`. To sample the all of the nested values, use `SAMPLES 0`. 10 | 11 | @examples 12 | 13 | With Redis v4.0.1 64-bit and **jemalloc**, the empty string measures as follows: 14 | 15 | ``` 16 | > SET "" "" 17 | OK 18 | > MEMORY USAGE "" 19 | (integer) 51 20 | ``` 21 | 22 | These bytes are pure overhead at the moment as no actual data is stored, and are 23 | used for maintaining the internal data structures of the server. Longer keys and 24 | values show asymptotically linear usage. 25 | 26 | ``` 27 | > SET foo bar 28 | OK 29 | > MEMORY USAGE foo 30 | (integer) 54 31 | > SET cento 01234567890123456789012345678901234567890123 32 | 45678901234567890123456789012345678901234567890123456789 33 | OK 34 | 127.0.0.1:6379> MEMORY USAGE cento 35 | (integer) 153 36 | ``` 37 | 38 | @return 39 | 40 | @integer-reply: the memory usage in bytes, or `nil` when the key does not exist. 41 | -------------------------------------------------------------------------------- /iredis/data/commands/memory.md: -------------------------------------------------------------------------------- 1 | This is a container command for memory introspection and management commands. 2 | 3 | To see the list of available commands you can call `MEMORY HELP`. 4 | -------------------------------------------------------------------------------- /iredis/data/commands/mget.md: -------------------------------------------------------------------------------- 1 | Returns the values of all specified keys. 2 | For every key that does not hold a string value or does not exist, the special 3 | value `nil` is returned. 4 | Because of this, the operation never fails. 5 | 6 | @return 7 | 8 | @array-reply: list of values at the specified keys. 9 | 10 | @examples 11 | 12 | ```cli 13 | SET key1 "Hello" 14 | SET key2 "World" 15 | MGET key1 key2 nonexisting 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/module-help.md: -------------------------------------------------------------------------------- 1 | The `MODULE HELP` command returns a helpful text describing the different subcommands. 2 | 3 | @return 4 | 5 | @array-reply: a list of subcommands and their descriptions 6 | -------------------------------------------------------------------------------- /iredis/data/commands/module-list.md: -------------------------------------------------------------------------------- 1 | Returns information about the modules loaded to the server. 2 | 3 | @return 4 | 5 | @array-reply: list of loaded modules. Each element in the list represents a 6 | module, and is in itself a list of property names and their values. The 7 | following properties is reported for each loaded module: 8 | 9 | * `name`: Name of the module 10 | * `ver`: Version of the module 11 | -------------------------------------------------------------------------------- /iredis/data/commands/module-load.md: -------------------------------------------------------------------------------- 1 | Loads a module from a dynamic library at runtime. 2 | 3 | This command loads and initializes the Redis module from the dynamic library 4 | specified by the `path` argument. The `path` should be the absolute path of the 5 | library, including the full filename. Any additional arguments are passed 6 | unmodified to the module. 7 | 8 | **Note**: modules can also be loaded at server startup with `loadmodule` 9 | configuration directive in `redis.conf`. 10 | 11 | @return 12 | 13 | @simple-string-reply: `OK` if module was loaded. 14 | -------------------------------------------------------------------------------- /iredis/data/commands/module-loadex.md: -------------------------------------------------------------------------------- 1 | Loads a module from a dynamic library at runtime with configuration directives. 2 | 3 | This is an extended version of the `MODULE LOAD` command. 4 | 5 | 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. 6 | 7 | You can use the optional `!CONFIG` argument to provide the module with configuration directives. 8 | Any additional arguments that follow the `ARGS` keyword are passed unmodified to the module. 9 | 10 | **Note**: modules can also be loaded at server startup with `loadmodule` 11 | configuration directive in `redis.conf`. 12 | 13 | @return 14 | 15 | @simple-string-reply: `OK` if module was loaded. 16 | -------------------------------------------------------------------------------- /iredis/data/commands/module-unload.md: -------------------------------------------------------------------------------- 1 | Unloads a module. 2 | 3 | This command unloads the module specified by `name`. Note that the module's name 4 | is reported by the `MODULE LIST` command, and may differ from the dynamic 5 | library's filename. 6 | 7 | Known limitations: 8 | 9 | * Modules that register custom data types can not be unloaded. 10 | 11 | @return 12 | 13 | @simple-string-reply: `OK` if module was unloaded. 14 | -------------------------------------------------------------------------------- /iredis/data/commands/module.md: -------------------------------------------------------------------------------- 1 | This is a container command for module management commands. 2 | 3 | To see the list of available commands you can call `MODULE HELP`. 4 | -------------------------------------------------------------------------------- /iredis/data/commands/move.md: -------------------------------------------------------------------------------- 1 | Move `key` from the currently selected database (see `SELECT`) to the specified 2 | destination database. 3 | When `key` already exists in the destination database, or it does not exist in 4 | the source database, it does nothing. 5 | It is possible to use `MOVE` as a locking primitive because of this. 6 | 7 | @return 8 | 9 | @integer-reply, specifically: 10 | 11 | * `1` if `key` was moved. 12 | * `0` if `key` was not moved. 13 | -------------------------------------------------------------------------------- /iredis/data/commands/mset.md: -------------------------------------------------------------------------------- 1 | Sets the given keys to their respective values. 2 | `MSET` replaces existing values with new values, just as regular `SET`. 3 | See `MSETNX` if you don't want to overwrite existing values. 4 | 5 | `MSET` is atomic, so all given keys are set at once. 6 | It is not possible for clients to see that some of the keys were updated while 7 | others are unchanged. 8 | 9 | @return 10 | 11 | @simple-string-reply: always `OK` since `MSET` can't fail. 12 | 13 | @examples 14 | 15 | ```cli 16 | MSET key1 "Hello" key2 "World" 17 | GET key1 18 | GET key2 19 | ``` 20 | -------------------------------------------------------------------------------- /iredis/data/commands/msetnx.md: -------------------------------------------------------------------------------- 1 | Sets the given keys to their respective values. 2 | `MSETNX` will not perform any operation at all even if just a single key already 3 | exists. 4 | 5 | Because of this semantic `MSETNX` can be used in order to set different keys 6 | representing different fields of a unique logic object in a way that ensures 7 | that either all the fields or none at all are set. 8 | 9 | `MSETNX` is atomic, so all given keys are set at once. 10 | It is not possible for clients to see that some of the keys were updated while 11 | others are unchanged. 12 | 13 | @return 14 | 15 | @integer-reply, specifically: 16 | 17 | * `1` if the all the keys were set. 18 | * `0` if no key was set (at least one key already existed). 19 | 20 | @examples 21 | 22 | ```cli 23 | MSETNX key1 "Hello" key2 "there" 24 | MSETNX key2 "new" key3 "world" 25 | MGET key1 key2 key3 26 | ``` 27 | -------------------------------------------------------------------------------- /iredis/data/commands/multi.md: -------------------------------------------------------------------------------- 1 | Marks the start of a [transaction][tt] block. 2 | Subsequent commands will be queued for atomic execution using `EXEC`. 3 | 4 | [tt]: /topics/transactions 5 | 6 | @return 7 | 8 | @simple-string-reply: always `OK`. 9 | -------------------------------------------------------------------------------- /iredis/data/commands/object-freq.md: -------------------------------------------------------------------------------- 1 | This command returns the logarithmic access frequency counter of a Redis object stored at ``. 2 | 3 | The command is only available when the `maxmemory-policy` configuration directive is set to one of the LFU policies. 4 | 5 | @return 6 | 7 | @integer-reply 8 | 9 | The counter's value. -------------------------------------------------------------------------------- /iredis/data/commands/object-help.md: -------------------------------------------------------------------------------- 1 | The `OBJECT HELP` command returns a helpful text describing the different subcommands. 2 | 3 | @return 4 | 5 | @array-reply: a list of subcommands and their descriptions 6 | -------------------------------------------------------------------------------- /iredis/data/commands/object-idletime.md: -------------------------------------------------------------------------------- 1 | This command returns the time in seconds since the last access to the value stored at ``. 2 | 3 | The command is only available when the `maxmemory-policy` configuration directive is not set to one of the LFU policies. 4 | 5 | @return 6 | 7 | @integer-reply 8 | 9 | The idle time in seconds. -------------------------------------------------------------------------------- /iredis/data/commands/object-refcount.md: -------------------------------------------------------------------------------- 1 | This command returns the reference count of the stored at ``. 2 | 3 | @return 4 | 5 | @integer-reply 6 | 7 | The number of references. -------------------------------------------------------------------------------- /iredis/data/commands/object.md: -------------------------------------------------------------------------------- 1 | This is a container command for object introspection commands. 2 | 3 | To see the list of available commands you can call `OBJECT HELP`. 4 | -------------------------------------------------------------------------------- /iredis/data/commands/persist.md: -------------------------------------------------------------------------------- 1 | Remove the existing timeout on `key`, turning the key from _volatile_ (a key 2 | with an expire set) to _persistent_ (a key that will never expire as no timeout 3 | is associated). 4 | 5 | @return 6 | 7 | @integer-reply, specifically: 8 | 9 | * `1` if the timeout was removed. 10 | * `0` if `key` does not exist or does not have an associated timeout. 11 | 12 | @examples 13 | 14 | ```cli 15 | SET mykey "Hello" 16 | EXPIRE mykey 10 17 | TTL mykey 18 | PERSIST mykey 19 | TTL mykey 20 | ``` 21 | -------------------------------------------------------------------------------- /iredis/data/commands/pexpire.md: -------------------------------------------------------------------------------- 1 | This command works exactly like `EXPIRE` but the time to live of the key is 2 | specified in milliseconds instead of seconds. 3 | 4 | ## Options 5 | 6 | The `PEXPIRE` command supports a set of options since Redis 7.0: 7 | 8 | * `NX` -- Set expiry only when the key has no expiry 9 | * `XX` -- Set expiry only when the key has an existing expiry 10 | * `GT` -- Set expiry only when the new expiry is greater than current one 11 | * `LT` -- Set expiry only when the new expiry is less than current one 12 | 13 | A non-volatile key is treated as an infinite TTL for the purpose of `GT` and `LT`. 14 | The `GT`, `LT` and `NX` options are mutually exclusive. 15 | 16 | @return 17 | 18 | @integer-reply, specifically: 19 | 20 | * `1` if the timeout was set. 21 | * `0` if the timeout was not set. e.g. key doesn't exist, or operation skipped due to the provided arguments. 22 | 23 | @examples 24 | 25 | ```cli 26 | SET mykey "Hello" 27 | PEXPIRE mykey 1500 28 | TTL mykey 29 | PTTL mykey 30 | PEXPIRE mykey 1000 XX 31 | TTL mykey 32 | PEXPIRE mykey 1000 NX 33 | TTL mykey 34 | ``` 35 | -------------------------------------------------------------------------------- /iredis/data/commands/pexpireat.md: -------------------------------------------------------------------------------- 1 | `PEXPIREAT` has the same effect and semantic as `EXPIREAT`, but the Unix time at 2 | which the key will expire is specified in milliseconds instead of seconds. 3 | 4 | ## Options 5 | 6 | The `PEXPIREAT` command supports a set of options since Redis 7.0: 7 | 8 | * `NX` -- Set expiry only when the key has no expiry 9 | * `XX` -- Set expiry only when the key has an existing expiry 10 | * `GT` -- Set expiry only when the new expiry is greater than current one 11 | * `LT` -- Set expiry only when the new expiry is less than current one 12 | 13 | A non-volatile key is treated as an infinite TTL for the purpose of `GT` and `LT`. 14 | The `GT`, `LT` and `NX` options are mutually exclusive. 15 | 16 | @return 17 | 18 | @integer-reply, specifically: 19 | 20 | * `1` if the timeout was set. 21 | * `0` if the timeout was not set. e.g. key doesn't exist, or operation skipped due to the provided arguments. 22 | 23 | @examples 24 | 25 | ```cli 26 | SET mykey "Hello" 27 | PEXPIREAT mykey 1555555555005 28 | TTL mykey 29 | PTTL mykey 30 | ``` 31 | -------------------------------------------------------------------------------- /iredis/data/commands/pexpiretime.md: -------------------------------------------------------------------------------- 1 | `PEXPIRETIME` has the same semantic as `EXPIRETIME`, but returns the absolute Unix expiration timestamp in milliseconds instead of seconds. 2 | 3 | @return 4 | 5 | @integer-reply: Expiration Unix timestamp in milliseconds, or a negative value in order to signal an error (see the description below). 6 | 7 | * The command returns `-1` if the key exists but has no associated expiration time. 8 | * The command returns `-2` if the key does not exist. 9 | 10 | @examples 11 | 12 | ```cli 13 | SET mykey "Hello" 14 | PEXPIREAT mykey 33177117420000 15 | PEXPIRETIME mykey 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/pfadd.md: -------------------------------------------------------------------------------- 1 | Adds all the element arguments to the HyperLogLog data structure stored at the variable name specified as first argument. 2 | 3 | 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). 4 | 5 | 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. 6 | 7 | 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). 8 | 9 | For an introduction to HyperLogLog data structure check the `PFCOUNT` command page. 10 | 11 | @return 12 | 13 | @integer-reply, specifically: 14 | 15 | * 1 if at least 1 HyperLogLog internal register was altered. 0 otherwise. 16 | 17 | @examples 18 | 19 | ```cli 20 | PFADD hll a b c d e f g 21 | PFCOUNT hll 22 | ``` 23 | -------------------------------------------------------------------------------- /iredis/data/commands/pfdebug.md: -------------------------------------------------------------------------------- 1 | The `PFDEBUG` command is an internal command. 2 | It is meant to be used for developing and testing Redis. -------------------------------------------------------------------------------- /iredis/data/commands/pfmerge.md: -------------------------------------------------------------------------------- 1 | Merge multiple HyperLogLog values into a unique value that will approximate 2 | the cardinality of the union of the observed Sets of the source HyperLogLog 3 | structures. 4 | 5 | The computed merged HyperLogLog is set to the destination variable, which is 6 | created if does not exist (defaulting to an empty HyperLogLog). 7 | 8 | If the destination variable exists, it is treated as one of the source sets 9 | and its cardinality will be included in the cardinality of the computed 10 | HyperLogLog. 11 | 12 | @return 13 | 14 | @simple-string-reply: The command just returns `OK`. 15 | 16 | @examples 17 | 18 | ```cli 19 | PFADD hll1 foo bar zap a 20 | PFADD hll2 a b c foo 21 | PFMERGE hll3 hll1 hll2 22 | PFCOUNT hll3 23 | ``` 24 | -------------------------------------------------------------------------------- /iredis/data/commands/pfselftest.md: -------------------------------------------------------------------------------- 1 | The `PFSELFTEST` command is an internal command. 2 | It is meant to be used for developing and testing Redis. -------------------------------------------------------------------------------- /iredis/data/commands/ping.md: -------------------------------------------------------------------------------- 1 | Returns `PONG` if no argument is provided, otherwise return a copy of the 2 | argument as a bulk. 3 | This command is often used to test if a connection is still alive, or to measure 4 | latency. 5 | 6 | If the client is subscribed to a channel or a pattern, it will instead return a 7 | multi-bulk with a "pong" in the first position and an empty bulk in the second 8 | position, unless an argument is provided in which case it returns a copy 9 | of the argument. 10 | 11 | @return 12 | 13 | @simple-string-reply, and specifically `PONG`, when no argument is provided. 14 | 15 | @bulk-string-reply the argument provided, when applicable. 16 | 17 | @examples 18 | 19 | ```cli 20 | PING 21 | 22 | PING "hello world" 23 | ``` 24 | -------------------------------------------------------------------------------- /iredis/data/commands/psetex.md: -------------------------------------------------------------------------------- 1 | `PSETEX` works exactly like `SETEX` with the sole difference that the expire 2 | time is specified in milliseconds instead of seconds. 3 | 4 | @examples 5 | 6 | ```cli 7 | PSETEX mykey 1000 "Hello" 8 | PTTL mykey 9 | GET mykey 10 | ``` 11 | -------------------------------------------------------------------------------- /iredis/data/commands/psubscribe.md: -------------------------------------------------------------------------------- 1 | Subscribes the client to the given patterns. 2 | 3 | Supported glob-style patterns: 4 | 5 | * `h?llo` subscribes to `hello`, `hallo` and `hxllo` 6 | * `h*llo` subscribes to `hllo` and `heeeello` 7 | * `h[ae]llo` subscribes to `hello` and `hallo,` but not `hillo` 8 | 9 | Use `\` to escape special characters if you want to match them verbatim. 10 | -------------------------------------------------------------------------------- /iredis/data/commands/psync.md: -------------------------------------------------------------------------------- 1 | Initiates a replication stream from the master. 2 | 3 | The `PSYNC` command is called by Redis replicas for initiating a replication 4 | stream from the master. 5 | 6 | For more information about replication in Redis please check the 7 | [replication page][tr]. 8 | 9 | [tr]: /topics/replication 10 | 11 | @return 12 | 13 | **Non standard return value**, a bulk transfer of the data followed by `PING` and write requests from the master. 14 | -------------------------------------------------------------------------------- /iredis/data/commands/pttl.md: -------------------------------------------------------------------------------- 1 | Like `TTL` this command returns the remaining time to live of a key that has an 2 | expire set, with the sole difference that `TTL` returns the amount of remaining 3 | time in seconds while `PTTL` returns it in milliseconds. 4 | 5 | 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. 6 | 7 | Starting with Redis 2.8 the return value in case of error changed: 8 | 9 | * The command returns `-2` if the key does not exist. 10 | * The command returns `-1` if the key exists but has no associated expire. 11 | 12 | @return 13 | 14 | @integer-reply: TTL in milliseconds, or a negative value in order to signal an error (see the description above). 15 | 16 | @examples 17 | 18 | ```cli 19 | SET mykey "Hello" 20 | EXPIRE mykey 1 21 | PTTL mykey 22 | ``` 23 | -------------------------------------------------------------------------------- /iredis/data/commands/publish.md: -------------------------------------------------------------------------------- 1 | Posts a message to the given channel. 2 | 3 | In a Redis Cluster clients can publish to every node. The cluster makes sure 4 | that published messages are forwarded as needed, so clients can subscribe to any 5 | channel by connecting to any one of the nodes. 6 | 7 | @return 8 | 9 | @integer-reply: the number of clients that received the message. Note that in a 10 | Redis Cluster, only clients that are connected to the same node as the 11 | publishing client are included in the count. 12 | -------------------------------------------------------------------------------- /iredis/data/commands/pubsub-channels.md: -------------------------------------------------------------------------------- 1 | Lists the currently *active channels*. 2 | 3 | An active channel is a Pub/Sub channel with one or more subscribers (excluding clients subscribed to patterns). 4 | 5 | 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. 6 | 7 | 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. 8 | 9 | @return 10 | 11 | @array-reply: a list of active channels, optionally matching the specified pattern. 12 | -------------------------------------------------------------------------------- /iredis/data/commands/pubsub-help.md: -------------------------------------------------------------------------------- 1 | The `PUBSUB HELP` command returns a helpful text describing the different subcommands. 2 | 3 | @return 4 | 5 | @array-reply: a list of subcommands and their descriptions 6 | -------------------------------------------------------------------------------- /iredis/data/commands/pubsub-numpat.md: -------------------------------------------------------------------------------- 1 | Returns the number of unique patterns that are subscribed to by clients (that are performed using the `PSUBSCRIBE` command). 2 | 3 | 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. 4 | 5 | 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. 6 | 7 | @return 8 | 9 | @integer-reply: the number of patterns all the clients are subscribed to. 10 | -------------------------------------------------------------------------------- /iredis/data/commands/pubsub-numsub.md: -------------------------------------------------------------------------------- 1 | Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified channels. 2 | 3 | Note that it is valid to call this command without channels. In this case it will just return an empty list. 4 | 5 | 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. 6 | 7 | @return 8 | 9 | @array-reply: a list of channels and number of subscribers for every channel. 10 | 11 | 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. 12 | -------------------------------------------------------------------------------- /iredis/data/commands/pubsub-shardchannels.md: -------------------------------------------------------------------------------- 1 | Lists the currently *active shard channels*. 2 | 3 | An active shard channel is a Pub/Sub shard channel with one or more subscribers. 4 | 5 | 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. 6 | 7 | The information returned about the active shard channels are at the shard level and not at the cluster level. 8 | 9 | @return 10 | 11 | @array-reply: a list of active channels, optionally matching the specified pattern. 12 | 13 | @examples 14 | 15 | ``` 16 | > PUBSUB SHARDCHANNELS 17 | 1) "orders" 18 | PUBSUB SHARDCHANNELS o* 19 | 1) "orders" 20 | ``` 21 | -------------------------------------------------------------------------------- /iredis/data/commands/pubsub-shardnumsub.md: -------------------------------------------------------------------------------- 1 | Returns the number of subscribers for the specified shard channels. 2 | 3 | Note that it is valid to call this command without channels, in this case it will just return an empty list. 4 | 5 | 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. 6 | 7 | @return 8 | 9 | @array-reply: a list of channels and number of subscribers for every channel. 10 | 11 | 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. 12 | 13 | @examples 14 | 15 | ``` 16 | > PUBSUB SHARDNUMSUB orders 17 | 1) "orders" 18 | 2) (integer) 1 19 | ``` 20 | -------------------------------------------------------------------------------- /iredis/data/commands/pubsub.md: -------------------------------------------------------------------------------- 1 | This is a container command for Pub/Sub introspection commands. 2 | 3 | To see the list of available commands you can call `PUBSUB HELP`. 4 | -------------------------------------------------------------------------------- /iredis/data/commands/punsubscribe.md: -------------------------------------------------------------------------------- 1 | Unsubscribes the client from the given patterns, or from all of them if none is 2 | given. 3 | 4 | When no patterns are specified, the client is unsubscribed from all the 5 | previously subscribed patterns. 6 | In this case, a message for every unsubscribed pattern will be sent to the 7 | client. 8 | -------------------------------------------------------------------------------- /iredis/data/commands/quit.md: -------------------------------------------------------------------------------- 1 | Ask the server to close the connection. 2 | The connection is closed as soon as all pending replies have been written to the 3 | client. 4 | 5 | @return 6 | 7 | @simple-string-reply: always OK. 8 | -------------------------------------------------------------------------------- /iredis/data/commands/randomkey.md: -------------------------------------------------------------------------------- 1 | Return a random key from the currently selected database. 2 | 3 | @return 4 | 5 | @bulk-string-reply: the random key, or `nil` when the database is empty. 6 | -------------------------------------------------------------------------------- /iredis/data/commands/readonly.md: -------------------------------------------------------------------------------- 1 | Enables read queries for a connection to a Redis Cluster replica node. 2 | 3 | Normally replica nodes will redirect clients to the authoritative master for 4 | the hash slot involved in a given command, however clients can use replicas 5 | in order to scale reads using the `READONLY` command. 6 | 7 | `READONLY` tells a Redis Cluster replica node that the client is willing to 8 | read possibly stale data and is not interested in running write queries. 9 | 10 | When the connection is in readonly mode, the cluster will send a redirection 11 | to the client only if the operation involves keys not served by the replica's 12 | master node. This may happen because: 13 | 14 | 1. The client sent a command about hash slots never served by the master of this replica. 15 | 2. The cluster was reconfigured (for example resharded) and the replica is no longer able to serve commands for a given hash slot. 16 | 17 | @return 18 | 19 | @simple-string-reply 20 | -------------------------------------------------------------------------------- /iredis/data/commands/readwrite.md: -------------------------------------------------------------------------------- 1 | Disables read queries for a connection to a Redis Cluster replica node. 2 | 3 | Read queries against a Redis Cluster replica node are disabled by default, 4 | but you can use the `READONLY` command to change this behavior on a per- 5 | connection basis. The `READWRITE` command resets the readonly mode flag 6 | of a connection back to readwrite. 7 | 8 | @return 9 | 10 | @simple-string-reply 11 | -------------------------------------------------------------------------------- /iredis/data/commands/rename.md: -------------------------------------------------------------------------------- 1 | Renames `key` to `newkey`. 2 | It returns an error when `key` does not exist. 3 | 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. 4 | 5 | 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. 6 | 7 | @return 8 | 9 | @simple-string-reply 10 | 11 | @examples 12 | 13 | ```cli 14 | SET mykey "Hello" 15 | RENAME mykey myotherkey 16 | GET myotherkey 17 | ``` 18 | 19 | ## Behavior change history 20 | 21 | * `>= 3.2.0`: The command no longer returns an error when source and destination names are the same. -------------------------------------------------------------------------------- /iredis/data/commands/renamenx.md: -------------------------------------------------------------------------------- 1 | Renames `key` to `newkey` if `newkey` does not yet exist. 2 | It returns an error when `key` does not exist. 3 | 4 | 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. 5 | 6 | @return 7 | 8 | @integer-reply, specifically: 9 | 10 | * `1` if `key` was renamed to `newkey`. 11 | * `0` if `newkey` already exists. 12 | 13 | @examples 14 | 15 | ```cli 16 | SET mykey "Hello" 17 | SET myotherkey "World" 18 | RENAMENX mykey myotherkey 19 | GET myotherkey 20 | ``` 21 | -------------------------------------------------------------------------------- /iredis/data/commands/replconf.md: -------------------------------------------------------------------------------- 1 | The `REPLCONF` command is an internal command. 2 | It is used by a Redis master to configure a connected replica. -------------------------------------------------------------------------------- /iredis/data/commands/replicaof.md: -------------------------------------------------------------------------------- 1 | The `REPLICAOF` command can change the replication settings of a replica on the fly. 2 | 3 | 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. 4 | 5 | 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. 6 | 7 | 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. 8 | 9 | @return 10 | 11 | @simple-string-reply 12 | 13 | @examples 14 | 15 | ``` 16 | > REPLICAOF NO ONE 17 | "OK" 18 | 19 | > REPLICAOF 127.0.0.1 6799 20 | "OK" 21 | ``` 22 | -------------------------------------------------------------------------------- /iredis/data/commands/reset.md: -------------------------------------------------------------------------------- 1 | This command performs a full reset of the connection's server-side context, 2 | mimicking the effect of disconnecting and reconnecting again. 3 | 4 | When the command is called from a regular client connection, it does the 5 | following: 6 | 7 | * Discards the current `MULTI` transaction block, if one exists. 8 | * Unwatches all keys `WATCH`ed by the connection. 9 | * Disables `CLIENT TRACKING`, if in use. 10 | * Sets the connection to `READWRITE` mode. 11 | * Cancels the connection's `ASKING` mode, if previously set. 12 | * Sets `CLIENT REPLY` to `ON`. 13 | * Sets the protocol version to RESP2. 14 | * `SELECT`s database 0. 15 | * Exits `MONITOR` mode, when applicable. 16 | * Aborts Pub/Sub's subscription state (`SUBSCRIBE` and `PSUBSCRIBE`), when 17 | appropriate. 18 | * Deauthenticates the connection, requiring a call `AUTH` to reauthenticate when 19 | authentication is enabled. 20 | 21 | @return 22 | 23 | @simple-string-reply: always 'RESET'. 24 | -------------------------------------------------------------------------------- /iredis/data/commands/restore-asking.md: -------------------------------------------------------------------------------- 1 | The `RESTORE-ASKING` command is an internal command. 2 | It is used by a Redis cluster master during slot migration. -------------------------------------------------------------------------------- /iredis/data/commands/restore.md: -------------------------------------------------------------------------------- 1 | Create a key associated with a value that is obtained by deserializing the 2 | provided serialized value (obtained via `DUMP`). 3 | 4 | If `ttl` is 0 the key is created without any expire, otherwise the specified 5 | expire time (in milliseconds) is set. 6 | 7 | If the `ABSTTL` modifier was used, `ttl` should represent an absolute 8 | [Unix timestamp][hewowu] (in milliseconds) in which the key will expire. 9 | 10 | [hewowu]: http://en.wikipedia.org/wiki/Unix_time 11 | 12 | For eviction purposes, you may use the `IDLETIME` or `FREQ` modifiers. See 13 | `OBJECT` for more information. 14 | 15 | `!RESTORE` will return a "Target key name is busy" error when `key` already 16 | exists unless you use the `REPLACE` modifier. 17 | 18 | `!RESTORE` checks the RDB version and data checksum. 19 | If they don't match an error is returned. 20 | 21 | @return 22 | 23 | @simple-string-reply: The command returns OK on success. 24 | 25 | @examples 26 | 27 | ``` 28 | redis> DEL mykey 29 | 0 30 | redis> RESTORE mykey 0 "\n\x17\x17\x00\x00\x00\x12\x00\x00\x00\x03\x00\ 31 | x00\xc0\x01\x00\x04\xc0\x02\x00\x04\xc0\x03\x00\ 32 | xff\x04\x00u#<\xc0;.\xe9\xdd" 33 | OK 34 | redis> TYPE mykey 35 | list 36 | redis> LRANGE mykey 0 -1 37 | 1) "1" 38 | 2) "2" 39 | 3) "3" 40 | ``` 41 | -------------------------------------------------------------------------------- /iredis/data/commands/rpop.md: -------------------------------------------------------------------------------- 1 | Removes and returns the last elements of the list stored at `key`. 2 | 3 | By default, the command pops a single element from the end of the list. 4 | When provided with the optional `count` argument, the reply will consist of up 5 | to `count` elements, depending on the list's length. 6 | 7 | @return 8 | 9 | When called without the `count` argument: 10 | 11 | @bulk-string-reply: the value of the last element, or `nil` when `key` does not exist. 12 | 13 | When called with the `count` argument: 14 | 15 | @array-reply: list of popped elements, or `nil` when `key` does not exist. 16 | 17 | @examples 18 | 19 | ```cli 20 | RPUSH mylist "one" "two" "three" "four" "five" 21 | RPOP mylist 22 | RPOP mylist 2 23 | LRANGE mylist 0 -1 24 | ``` 25 | -------------------------------------------------------------------------------- /iredis/data/commands/rpush.md: -------------------------------------------------------------------------------- 1 | Insert all the specified values at the tail of the list stored at `key`. 2 | If `key` does not exist, it is created as empty list before performing the push 3 | operation. 4 | When `key` holds a value that is not a list, an error is returned. 5 | 6 | It is possible to push multiple elements using a single command call just 7 | specifying multiple arguments at the end of the command. 8 | Elements are inserted one after the other to the tail of the list, from the 9 | leftmost element to the rightmost element. 10 | So for instance the command `RPUSH mylist a b c` will result into a list 11 | containing `a` as first element, `b` as second element and `c` as third element. 12 | 13 | @return 14 | 15 | @integer-reply: the length of the list after the push operation. 16 | 17 | @examples 18 | 19 | ```cli 20 | RPUSH mylist "hello" 21 | RPUSH mylist "world" 22 | LRANGE mylist 0 -1 23 | ``` 24 | -------------------------------------------------------------------------------- /iredis/data/commands/rpushx.md: -------------------------------------------------------------------------------- 1 | Inserts specified values at the tail of the list stored at `key`, only if `key` 2 | already exists and holds a list. 3 | In contrary to `RPUSH`, no operation will be performed when `key` does not yet 4 | exist. 5 | 6 | @return 7 | 8 | @integer-reply: the length of the list after the push operation. 9 | 10 | @examples 11 | 12 | ```cli 13 | RPUSH mylist "Hello" 14 | RPUSHX mylist "World" 15 | RPUSHX myotherlist "World" 16 | LRANGE mylist 0 -1 17 | LRANGE myotherlist 0 -1 18 | ``` 19 | -------------------------------------------------------------------------------- /iredis/data/commands/sadd.md: -------------------------------------------------------------------------------- 1 | Add the specified members to the set stored at `key`. 2 | Specified members that are already a member of this set are ignored. 3 | If `key` does not exist, a new set is created before adding the specified 4 | members. 5 | 6 | An error is returned when the value stored at `key` is not a set. 7 | 8 | @return 9 | 10 | @integer-reply: the number of elements that were added to the set, not including 11 | all the elements already present in the set. 12 | 13 | @examples 14 | 15 | ```cli 16 | SADD myset "Hello" 17 | SADD myset "World" 18 | SADD myset "World" 19 | SMEMBERS myset 20 | ``` 21 | -------------------------------------------------------------------------------- /iredis/data/commands/save.md: -------------------------------------------------------------------------------- 1 | The `SAVE` commands performs a **synchronous** save of the dataset producing a 2 | _point in time_ snapshot of all the data inside the Redis instance, in the form 3 | of an RDB file. 4 | 5 | You almost never want to call `SAVE` in production environments where it will 6 | block all the other clients. 7 | Instead usually `BGSAVE` is used. 8 | However in case of issues preventing Redis to create the background saving child 9 | (for instance errors in the fork(2) system call), the `SAVE` command can be a 10 | good last resort to perform the dump of the latest dataset. 11 | 12 | Please refer to the [persistence documentation][tp] for detailed information. 13 | 14 | [tp]: /topics/persistence 15 | 16 | @return 17 | 18 | @simple-string-reply: The commands returns OK on success. 19 | -------------------------------------------------------------------------------- /iredis/data/commands/scard.md: -------------------------------------------------------------------------------- 1 | Returns the set cardinality (number of elements) of the set stored at `key`. 2 | 3 | @return 4 | 5 | @integer-reply: the cardinality (number of elements) of the set, or `0` if `key` 6 | does not exist. 7 | 8 | @examples 9 | 10 | ```cli 11 | SADD myset "Hello" 12 | SADD myset "World" 13 | SCARD myset 14 | ``` 15 | -------------------------------------------------------------------------------- /iredis/data/commands/script-exists.md: -------------------------------------------------------------------------------- 1 | Returns information about the existence of the scripts in the script cache. 2 | 3 | This command accepts one or more SHA1 digests and returns a list of ones or 4 | zeros to signal if the scripts are already defined or not inside the script 5 | cache. 6 | This can be useful before a pipelining operation to ensure that scripts are 7 | loaded (and if not, to load them using `SCRIPT LOAD`) so that the pipelining 8 | operation can be performed solely using `EVALSHA` instead of `EVAL` to save 9 | bandwidth. 10 | 11 | For more information about `EVAL` scripts please refer to [Introduction to Eval Scripts](/topics/eval-intro). 12 | 13 | @return 14 | 15 | @array-reply The command returns an array of integers that correspond to 16 | the specified SHA1 digest arguments. 17 | For every corresponding SHA1 digest of a script that actually exists in the 18 | script cache, a 1 is returned, otherwise 0 is returned. 19 | -------------------------------------------------------------------------------- /iredis/data/commands/script-flush.md: -------------------------------------------------------------------------------- 1 | Flush the Lua scripts cache. 2 | 3 | By default, `SCRIPT FLUSH` will synchronously flush the cache. 4 | Starting with Redis 6.2, setting the **lazyfree-lazy-user-flush** configuration directive to "yes" changes the default flush mode to asynchronous. 5 | 6 | It is possible to use one of the following modifiers to dictate the flushing mode explicitly: 7 | 8 | * `ASYNC`: flushes the cache asynchronously 9 | * `!SYNC`: flushes the cache synchronously 10 | 11 | For more information about `EVAL` scripts please refer to [Introduction to Eval Scripts](/topics/eval-intro). 12 | 13 | @return 14 | 15 | @simple-string-reply 16 | 17 | ## Behavior change history 18 | 19 | * `>= 6.2.0`: Default flush behavior now configurable by the **lazyfree-lazy-user-flush** configuration directive. -------------------------------------------------------------------------------- /iredis/data/commands/script-help.md: -------------------------------------------------------------------------------- 1 | The `SCRIPT HELP` command returns a helpful text describing the different subcommands. 2 | 3 | @return 4 | 5 | @array-reply: a list of subcommands and their descriptions 6 | -------------------------------------------------------------------------------- /iredis/data/commands/script-kill.md: -------------------------------------------------------------------------------- 1 | Kills the currently executing `EVAL` script, assuming no write operation was yet 2 | performed by the script. 3 | 4 | This command is mainly useful to kill a script that is running for too much 5 | time(for instance, because it entered an infinite loop because of a bug). 6 | The script will be killed, and the client currently blocked into EVAL will see 7 | the command returning with an error. 8 | 9 | If the script has already performed write operations, it can not be killed in this 10 | way because it would violate Lua's script atomicity contract. 11 | In such a case, only `SHUTDOWN NOSAVE` can kill the script, killing 12 | the Redis process in a hard way and preventing it from persisting with half-written 13 | information. 14 | 15 | For more information about `EVAL` scripts please refer to [Introduction to Eval Scripts](/topics/eval-intro). 16 | 17 | @return 18 | 19 | @simple-string-reply 20 | -------------------------------------------------------------------------------- /iredis/data/commands/script-load.md: -------------------------------------------------------------------------------- 1 | Load a script into the scripts cache, without executing it. 2 | After the specified command is loaded into the script cache it will be callable 3 | using `EVALSHA` with the correct SHA1 digest of the script, exactly like after 4 | the first successful invocation of `EVAL`. 5 | 6 | The script is guaranteed to stay in the script cache forever (unless `SCRIPT 7 | FLUSH` is called). 8 | 9 | The command works in the same way even if the script was already present in the 10 | script cache. 11 | 12 | For more information about `EVAL` scripts please refer to [Introduction to Eval Scripts](/topics/eval-intro). 13 | 14 | @return 15 | 16 | @bulk-string-reply This command returns the SHA1 digest of the script added into the 17 | script cache. 18 | -------------------------------------------------------------------------------- /iredis/data/commands/script.md: -------------------------------------------------------------------------------- 1 | This is a container command for script management commands. 2 | 3 | To see the list of available commands you can call `SCRIPT HELP`. 4 | -------------------------------------------------------------------------------- /iredis/data/commands/sdiff.md: -------------------------------------------------------------------------------- 1 | Returns the members of the set resulting from the difference between the first 2 | set and all the successive sets. 3 | 4 | For example: 5 | 6 | ``` 7 | key1 = {a,b,c,d} 8 | key2 = {c} 9 | key3 = {a,c,e} 10 | SDIFF key1 key2 key3 = {b,d} 11 | ``` 12 | 13 | Keys that do not exist are considered to be empty sets. 14 | 15 | @return 16 | 17 | @array-reply: list with members of the resulting set. 18 | 19 | @examples 20 | 21 | ```cli 22 | SADD key1 "a" 23 | SADD key1 "b" 24 | SADD key1 "c" 25 | SADD key2 "c" 26 | SADD key2 "d" 27 | SADD key2 "e" 28 | SDIFF key1 key2 29 | ``` 30 | -------------------------------------------------------------------------------- /iredis/data/commands/sdiffstore.md: -------------------------------------------------------------------------------- 1 | This command is equal to `SDIFF`, but instead of returning the resulting set, it 2 | is stored in `destination`. 3 | 4 | If `destination` already exists, it is overwritten. 5 | 6 | @return 7 | 8 | @integer-reply: the number of elements in the resulting set. 9 | 10 | @examples 11 | 12 | ```cli 13 | SADD key1 "a" 14 | SADD key1 "b" 15 | SADD key1 "c" 16 | SADD key2 "c" 17 | SADD key2 "d" 18 | SADD key2 "e" 19 | SDIFFSTORE key key1 key2 20 | SMEMBERS key 21 | ``` 22 | -------------------------------------------------------------------------------- /iredis/data/commands/select.md: -------------------------------------------------------------------------------- 1 | Select the Redis logical database having the specified zero-based numeric index. 2 | New connections always use the database 0. 3 | 4 | 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. 5 | 6 | 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. 7 | 8 | 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. 9 | 10 | 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. 11 | 12 | @return 13 | 14 | @simple-string-reply 15 | -------------------------------------------------------------------------------- /iredis/data/commands/setex.md: -------------------------------------------------------------------------------- 1 | Set `key` to hold the string `value` and set `key` to timeout after a given 2 | number of seconds. 3 | This command is equivalent to executing the following commands: 4 | 5 | ``` 6 | SET mykey value 7 | EXPIRE mykey seconds 8 | ``` 9 | 10 | `SETEX` is atomic, and can be reproduced by using the previous two commands 11 | inside an `MULTI` / `EXEC` block. 12 | It is provided as a faster alternative to the given sequence of operations, 13 | because this operation is very common when Redis is used as a cache. 14 | 15 | An error is returned when `seconds` is invalid. 16 | 17 | @return 18 | 19 | @simple-string-reply 20 | 21 | @examples 22 | 23 | ```cli 24 | SETEX mykey 10 "Hello" 25 | TTL mykey 26 | GET mykey 27 | ``` 28 | -------------------------------------------------------------------------------- /iredis/data/commands/sinter.md: -------------------------------------------------------------------------------- 1 | Returns the members of the set resulting from the intersection of all the given 2 | sets. 3 | 4 | For example: 5 | 6 | ``` 7 | key1 = {a,b,c,d} 8 | key2 = {c} 9 | key3 = {a,c,e} 10 | SINTER key1 key2 key3 = {c} 11 | ``` 12 | 13 | Keys that do not exist are considered to be empty sets. 14 | With one of the keys being an empty set, the resulting set is also empty (since 15 | set intersection with an empty set always results in an empty set). 16 | 17 | @return 18 | 19 | @array-reply: list with members of the resulting set. 20 | 21 | @examples 22 | 23 | ```cli 24 | SADD key1 "a" 25 | SADD key1 "b" 26 | SADD key1 "c" 27 | SADD key2 "c" 28 | SADD key2 "d" 29 | SADD key2 "e" 30 | SINTER key1 key2 31 | ``` 32 | -------------------------------------------------------------------------------- /iredis/data/commands/sintercard.md: -------------------------------------------------------------------------------- 1 | This command is similar to `SINTER`, but instead of returning the result set, it returns just the cardinality of the result. 2 | Returns the cardinality of the set which would result from the intersection of all the given sets. 3 | 4 | Keys that do not exist are considered to be empty sets. 5 | 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). 6 | 7 | By default, the command calculates the cardinality of the intersection of all given sets. 8 | 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. 9 | Such implementation ensures a significant speedup for queries where the limit is lower than the actual intersection cardinality. 10 | 11 | @return 12 | 13 | @integer-reply: the number of elements in the resulting intersection. 14 | 15 | @examples 16 | 17 | ```cli 18 | SADD key1 "a" 19 | SADD key1 "b" 20 | SADD key1 "c" 21 | SADD key1 "d" 22 | SADD key2 "c" 23 | SADD key2 "d" 24 | SADD key2 "e" 25 | SINTER key1 key2 26 | SINTERCARD 2 key1 key2 27 | SINTERCARD 2 key1 key2 LIMIT 1 28 | ``` 29 | -------------------------------------------------------------------------------- /iredis/data/commands/sinterstore.md: -------------------------------------------------------------------------------- 1 | This command is equal to `SINTER`, but instead of returning the resulting set, 2 | it is stored in `destination`. 3 | 4 | If `destination` already exists, it is overwritten. 5 | 6 | @return 7 | 8 | @integer-reply: the number of elements in the resulting set. 9 | 10 | @examples 11 | 12 | ```cli 13 | SADD key1 "a" 14 | SADD key1 "b" 15 | SADD key1 "c" 16 | SADD key2 "c" 17 | SADD key2 "d" 18 | SADD key2 "e" 19 | SINTERSTORE key key1 key2 20 | SMEMBERS key 21 | ``` 22 | -------------------------------------------------------------------------------- /iredis/data/commands/sismember.md: -------------------------------------------------------------------------------- 1 | Returns if `member` is a member of the set stored at `key`. 2 | 3 | @return 4 | 5 | @integer-reply, specifically: 6 | 7 | * `1` if the element is a member of the set. 8 | * `0` if the element is not a member of the set, or if `key` does not exist. 9 | 10 | @examples 11 | 12 | ```cli 13 | SADD myset "one" 14 | SISMEMBER myset "one" 15 | SISMEMBER myset "two" 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/slaveof.md: -------------------------------------------------------------------------------- 1 | **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. 2 | 3 | The `SLAVEOF` command can change the replication settings of a replica on the fly. 4 | If a Redis server is already acting as replica, the command `SLAVEOF` NO ONE will 5 | turn off the replication, turning the Redis server into a MASTER. 6 | In the proper form `SLAVEOF` hostname port will make the server a replica of 7 | another server listening at the specified hostname and port. 8 | 9 | If a server is already a replica of some master, `SLAVEOF` hostname port will stop 10 | the replication against the old server and start the synchronization against the 11 | new one, discarding the old dataset. 12 | 13 | The form `SLAVEOF` NO ONE will stop replication, turning the server into a 14 | MASTER, but will not discard the replication. 15 | So, if the old master stops working, it is possible to turn the replica into a 16 | master and set the application to use this new master in read/write. 17 | Later when the other Redis server is fixed, it can be reconfigured to work as a 18 | replica. 19 | 20 | @return 21 | 22 | @simple-string-reply 23 | -------------------------------------------------------------------------------- /iredis/data/commands/slowlog-help.md: -------------------------------------------------------------------------------- 1 | The `SLOWLOG HELP` command returns a helpful text describing the different subcommands. 2 | 3 | @return 4 | 5 | @array-reply: a list of subcommands and their descriptions 6 | -------------------------------------------------------------------------------- /iredis/data/commands/slowlog-len.md: -------------------------------------------------------------------------------- 1 | This command returns the current number of entries in the slow log. 2 | 3 | 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. 4 | The maximum number of entries in the slow log is governed by the `slowlog-max-len` configuration directive. 5 | Once the slog log reaches its maximal size, the oldest entry is removed whenever a new entry is created. 6 | The slow log can be cleared with the `SLOWLOG RESET` command. 7 | 8 | @reply 9 | 10 | @integer-reply 11 | 12 | The number of entries in the slow log. 13 | -------------------------------------------------------------------------------- /iredis/data/commands/slowlog-reset.md: -------------------------------------------------------------------------------- 1 | This command resets the slow log, clearing all entries in it. 2 | 3 | Once deleted the information is lost forever. 4 | 5 | @reply 6 | 7 | @simple-string-reply: `OK` 8 | -------------------------------------------------------------------------------- /iredis/data/commands/slowlog.md: -------------------------------------------------------------------------------- 1 | This is a container command for slow log management commands. 2 | 3 | To see the list of available commands you can call `SLOWLOG HELP`. 4 | -------------------------------------------------------------------------------- /iredis/data/commands/smembers.md: -------------------------------------------------------------------------------- 1 | Returns all the members of the set value stored at `key`. 2 | 3 | This has the same effect as running `SINTER` with one argument `key`. 4 | 5 | @return 6 | 7 | @array-reply: all elements of the set. 8 | 9 | @examples 10 | 11 | ```cli 12 | SADD myset "Hello" 13 | SADD myset "World" 14 | SMEMBERS myset 15 | ``` 16 | -------------------------------------------------------------------------------- /iredis/data/commands/smismember.md: -------------------------------------------------------------------------------- 1 | Returns whether each `member` is a member of the set stored at `key`. 2 | 3 | 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. 4 | 5 | @return 6 | 7 | @array-reply: list representing the membership of the given elements, in the same 8 | order as they are requested. 9 | 10 | @examples 11 | 12 | ```cli 13 | SADD myset "one" 14 | SADD myset "one" 15 | SMISMEMBER myset "one" "notamember" 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/smove.md: -------------------------------------------------------------------------------- 1 | Move `member` from the set at `source` to the set at `destination`. 2 | This operation is atomic. 3 | In every given moment the element will appear to be a member of `source` **or** 4 | `destination` for other clients. 5 | 6 | If the source set does not exist or does not contain the specified element, no 7 | operation is performed and `0` is returned. 8 | Otherwise, the element is removed from the source set and added to the 9 | destination set. 10 | When the specified element already exists in the destination set, it is only 11 | removed from the source set. 12 | 13 | An error is returned if `source` or `destination` does not hold a set value. 14 | 15 | @return 16 | 17 | @integer-reply, specifically: 18 | 19 | * `1` if the element is moved. 20 | * `0` if the element is not a member of `source` and no operation was performed. 21 | 22 | @examples 23 | 24 | ```cli 25 | SADD myset "one" 26 | SADD myset "two" 27 | SADD myotherset "three" 28 | SMOVE myset myotherset "two" 29 | SMEMBERS myset 30 | SMEMBERS myotherset 31 | ``` 32 | -------------------------------------------------------------------------------- /iredis/data/commands/sort_ro.md: -------------------------------------------------------------------------------- 1 | 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. 2 | 3 | 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). 4 | 5 | The `SORT_RO` variant was introduced in order to allow `SORT` behavior in read-only replicas without breaking compatibility on command flags. 6 | 7 | See original `SORT` for more details. 8 | 9 | @examples 10 | 11 | ``` 12 | SORT_RO mylist BY weight_*->fieldname GET object_*->fieldname 13 | ``` 14 | 15 | @return 16 | 17 | @array-reply: a list of sorted elements. 18 | -------------------------------------------------------------------------------- /iredis/data/commands/spop.md: -------------------------------------------------------------------------------- 1 | Removes and returns one or more random members from the set value store at `key`. 2 | 3 | This operation is similar to `SRANDMEMBER`, that returns one or more random elements from a set but does not remove it. 4 | 5 | By default, the command pops a single member from the set. When provided with 6 | the optional `count` argument, the reply will consist of up to `count` members, 7 | depending on the set's cardinality. 8 | 9 | @return 10 | 11 | When called without the `count` argument: 12 | 13 | @bulk-string-reply: the removed member, or `nil` when `key` does not exist. 14 | 15 | When called with the `count` argument: 16 | 17 | @array-reply: the removed members, or an empty array when `key` does not exist. 18 | 19 | @examples 20 | 21 | ```cli 22 | SADD myset "one" 23 | SADD myset "two" 24 | SADD myset "three" 25 | SPOP myset 26 | SMEMBERS myset 27 | SADD myset "four" 28 | SADD myset "five" 29 | SPOP myset 3 30 | SMEMBERS myset 31 | ``` 32 | ## Distribution of returned elements 33 | 34 | 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. 35 | -------------------------------------------------------------------------------- /iredis/data/commands/spublish.md: -------------------------------------------------------------------------------- 1 | Posts a message to the given shard channel. 2 | 3 | In Redis Cluster, shard channels are assigned to slots by the same algorithm used to assign keys to slots. 4 | A shard message must be sent to a node that own the slot the shard channel is hashed to. 5 | 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. 6 | 7 | For more information about sharded pubsub, see [Sharded Pubsub](/topics/pubsub#sharded-pubsub). 8 | 9 | @return 10 | 11 | @integer-reply: the number of clients that received the message. 12 | 13 | @examples 14 | 15 | For example the following command publish to channel `orders` with a subscriber already waiting for message(s). 16 | 17 | ``` 18 | > spublish orders hello 19 | (integer) 1 20 | ``` 21 | -------------------------------------------------------------------------------- /iredis/data/commands/srem.md: -------------------------------------------------------------------------------- 1 | Remove the specified members from the set stored at `key`. 2 | Specified members that are not a member of this set are ignored. 3 | If `key` does not exist, it is treated as an empty set and this command returns 4 | `0`. 5 | 6 | An error is returned when the value stored at `key` is not a set. 7 | 8 | @return 9 | 10 | @integer-reply: the number of members that were removed from the set, not 11 | including non existing members. 12 | 13 | @examples 14 | 15 | ```cli 16 | SADD myset "one" 17 | SADD myset "two" 18 | SADD myset "three" 19 | SREM myset "one" 20 | SREM myset "four" 21 | SMEMBERS myset 22 | ``` 23 | -------------------------------------------------------------------------------- /iredis/data/commands/sscan.md: -------------------------------------------------------------------------------- 1 | See `SCAN` for `SSCAN` documentation. 2 | -------------------------------------------------------------------------------- /iredis/data/commands/ssubscribe.md: -------------------------------------------------------------------------------- 1 | Subscribes the client to the specified shard channels. 2 | 3 | In a Redis cluster, shard channels are assigned to slots by the same algorithm used to assign keys to slots. 4 | Client(s) can subscribe to a node covering a slot (primary/replica) to receive the messages published. 5 | All the specified shard channels needs to belong to a single slot to subscribe in a given `SSUBSCRIBE` call, 6 | A client can subscribe to channels across different slots over separate `SSUBSCRIBE` call. 7 | 8 | For more information about sharded Pub/Sub, see [Sharded Pub/Sub](/topics/pubsub#sharded-pubsub). 9 | 10 | @examples 11 | 12 | ``` 13 | > ssubscribe orders 14 | Reading messages... (press Ctrl-C to quit) 15 | 1) "ssubscribe" 16 | 2) "orders" 17 | 3) (integer) 1 18 | 1) "smessage" 19 | 2) "orders" 20 | 3) "hello" 21 | ``` 22 | -------------------------------------------------------------------------------- /iredis/data/commands/strlen.md: -------------------------------------------------------------------------------- 1 | Returns the length of the string value stored at `key`. 2 | An error is returned when `key` holds a non-string value. 3 | 4 | @return 5 | 6 | @integer-reply: the length of the string at `key`, or `0` when `key` does not 7 | exist. 8 | 9 | @examples 10 | 11 | ```cli 12 | SET mykey "Hello world" 13 | STRLEN mykey 14 | STRLEN nonexisting 15 | ``` 16 | -------------------------------------------------------------------------------- /iredis/data/commands/subscribe.md: -------------------------------------------------------------------------------- 1 | Subscribes the client to the specified channels. 2 | 3 | Once the client enters the subscribed state it is not supposed to issue any 4 | other commands, except for additional `SUBSCRIBE`, `SSUBSCRIBE`, `PSUBSCRIBE`, `UNSUBSCRIBE`, `SUNSUBSCRIBE`, 5 | `PUNSUBSCRIBE`, `PING`, `RESET` and `QUIT` commands. 6 | 7 | ## Behavior change history 8 | 9 | * `>= 6.2.0`: `RESET` can be called to exit subscribed state. -------------------------------------------------------------------------------- /iredis/data/commands/substr.md: -------------------------------------------------------------------------------- 1 | Returns the substring of the string value stored at `key`, determined by the 2 | offsets `start` and `end` (both are inclusive). 3 | Negative offsets can be used in order to provide an offset starting from the end 4 | of the string. 5 | So -1 means the last character, -2 the penultimate and so forth. 6 | 7 | The function handles out of range requests by limiting the resulting range to 8 | the actual length of the string. 9 | 10 | @return 11 | 12 | @bulk-string-reply 13 | 14 | @examples 15 | 16 | ```cli 17 | SET mykey "This is a string" 18 | GETRANGE mykey 0 3 19 | GETRANGE mykey -3 -1 20 | GETRANGE mykey 0 -1 21 | GETRANGE mykey 10 100 22 | ``` 23 | -------------------------------------------------------------------------------- /iredis/data/commands/sunion.md: -------------------------------------------------------------------------------- 1 | Returns the members of the set resulting from the union of all the given sets. 2 | 3 | For example: 4 | 5 | ``` 6 | key1 = {a,b,c,d} 7 | key2 = {c} 8 | key3 = {a,c,e} 9 | SUNION key1 key2 key3 = {a,b,c,d,e} 10 | ``` 11 | 12 | Keys that do not exist are considered to be empty sets. 13 | 14 | @return 15 | 16 | @array-reply: list with members of the resulting set. 17 | 18 | @examples 19 | 20 | ```cli 21 | SADD key1 "a" 22 | SADD key1 "b" 23 | SADD key1 "c" 24 | SADD key2 "c" 25 | SADD key2 "d" 26 | SADD key2 "e" 27 | SUNION key1 key2 28 | ``` 29 | -------------------------------------------------------------------------------- /iredis/data/commands/sunionstore.md: -------------------------------------------------------------------------------- 1 | This command is equal to `SUNION`, but instead of returning the resulting set, 2 | it is stored in `destination`. 3 | 4 | If `destination` already exists, it is overwritten. 5 | 6 | @return 7 | 8 | @integer-reply: the number of elements in the resulting set. 9 | 10 | @examples 11 | 12 | ```cli 13 | SADD key1 "a" 14 | SADD key1 "b" 15 | SADD key1 "c" 16 | SADD key2 "c" 17 | SADD key2 "d" 18 | SADD key2 "e" 19 | SUNIONSTORE key key1 key2 20 | SMEMBERS key 21 | ``` 22 | -------------------------------------------------------------------------------- /iredis/data/commands/sunsubscribe.md: -------------------------------------------------------------------------------- 1 | Unsubscribes the client from the given shard channels, or from all of them if none is given. 2 | 3 | When no shard channels are specified, the client is unsubscribed from all the previously subscribed shard channels. 4 | In this case a message for every unsubscribed shard channel will be sent to the client. 5 | 6 | Note: The global channels and shard channels needs to be unsubscribed from separately. 7 | 8 | For more information about sharded Pub/Sub, see [Sharded Pub/Sub](/topics/pubsub#sharded-pubsub). 9 | -------------------------------------------------------------------------------- /iredis/data/commands/swapdb.md: -------------------------------------------------------------------------------- 1 | This command swaps two Redis databases, so that immediately all the 2 | clients connected to a given database will see the data of the other database, and 3 | the other way around. Example: 4 | 5 | SWAPDB 0 1 6 | 7 | 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. 8 | 9 | @return 10 | 11 | @simple-string-reply: `OK` if `SWAPDB` was executed correctly. 12 | 13 | @examples 14 | 15 | ``` 16 | SWAPDB 0 1 17 | ``` 18 | -------------------------------------------------------------------------------- /iredis/data/commands/sync.md: -------------------------------------------------------------------------------- 1 | Initiates a replication stream from the master. 2 | 3 | The `SYNC` command is called by Redis replicas for initiating a replication 4 | stream from the master. It has been replaced in newer versions of Redis by 5 | `PSYNC`. 6 | 7 | For more information about replication in Redis please check the 8 | [replication page][tr]. 9 | 10 | [tr]: /topics/replication 11 | 12 | @return 13 | 14 | **Non standard return value**, a bulk transfer of the data followed by `PING` and write requests from the master. 15 | -------------------------------------------------------------------------------- /iredis/data/commands/time.md: -------------------------------------------------------------------------------- 1 | The `TIME` command returns the current server time as a two items lists: a Unix 2 | timestamp and the amount of microseconds already elapsed in the current second. 3 | Basically the interface is very similar to the one of the `gettimeofday` system 4 | call. 5 | 6 | @return 7 | 8 | @array-reply, specifically: 9 | 10 | A multi bulk reply containing two elements: 11 | 12 | * unix time in seconds. 13 | * microseconds. 14 | 15 | @examples 16 | 17 | ```cli 18 | TIME 19 | TIME 20 | ``` 21 | -------------------------------------------------------------------------------- /iredis/data/commands/touch.md: -------------------------------------------------------------------------------- 1 | Alters the last access time of a key(s). 2 | A key is ignored if it does not exist. 3 | 4 | @return 5 | 6 | @integer-reply: The number of keys that were touched. 7 | 8 | @examples 9 | 10 | ```cli 11 | SET key1 "Hello" 12 | SET key2 "World" 13 | TOUCH key1 key2 14 | ``` 15 | -------------------------------------------------------------------------------- /iredis/data/commands/ttl.md: -------------------------------------------------------------------------------- 1 | Returns the remaining time to live of a key that has a timeout. 2 | This introspection capability allows a Redis client to check how many seconds a 3 | given key will continue to be part of the dataset. 4 | 5 | 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. 6 | 7 | Starting with Redis 2.8 the return value in case of error changed: 8 | 9 | * The command returns `-2` if the key does not exist. 10 | * The command returns `-1` if the key exists but has no associated expire. 11 | 12 | See also the `PTTL` command that returns the same information with milliseconds resolution (Only available in Redis 2.6 or greater). 13 | 14 | @return 15 | 16 | @integer-reply: TTL in seconds, or a negative value in order to signal an error (see the description above). 17 | 18 | @examples 19 | 20 | ```cli 21 | SET mykey "Hello" 22 | EXPIRE mykey 10 23 | TTL mykey 24 | ``` 25 | -------------------------------------------------------------------------------- /iredis/data/commands/type.md: -------------------------------------------------------------------------------- 1 | Returns the string representation of the type of the value stored at `key`. 2 | The different types that can be returned are: `string`, `list`, `set`, `zset`, 3 | `hash` and `stream`. 4 | 5 | @return 6 | 7 | @simple-string-reply: type of `key`, or `none` when `key` does not exist. 8 | 9 | @examples 10 | 11 | ```cli 12 | SET key1 "value" 13 | LPUSH key2 "value" 14 | SADD key3 "value" 15 | TYPE key1 16 | TYPE key2 17 | TYPE key3 18 | ``` 19 | -------------------------------------------------------------------------------- /iredis/data/commands/unlink.md: -------------------------------------------------------------------------------- 1 | This command is very similar to `DEL`: it removes the specified keys. 2 | Just like `DEL` a key is ignored if it does not exist. However the command 3 | performs the actual memory reclaiming in a different thread, so it is not 4 | blocking, while `DEL` is. This is where the command name comes from: the 5 | command just **unlinks** the keys from the keyspace. The actual removal 6 | will happen later asynchronously. 7 | 8 | @return 9 | 10 | @integer-reply: The number of keys that were unlinked. 11 | 12 | @examples 13 | 14 | ```cli 15 | SET key1 "Hello" 16 | SET key2 "World" 17 | UNLINK key1 key2 key3 18 | ``` 19 | -------------------------------------------------------------------------------- /iredis/data/commands/unsubscribe.md: -------------------------------------------------------------------------------- 1 | Unsubscribes the client from the given channels, or from all of them if none is 2 | given. 3 | 4 | When no channels are specified, the client is unsubscribed from all the 5 | previously subscribed channels. 6 | In this case, a message for every unsubscribed channel will be sent to the 7 | client. 8 | -------------------------------------------------------------------------------- /iredis/data/commands/unwatch.md: -------------------------------------------------------------------------------- 1 | Flushes all the previously watched keys for a [transaction][tt]. 2 | 3 | [tt]: /topics/transactions 4 | 5 | If you call `EXEC` or `DISCARD`, there's no need to manually call `UNWATCH`. 6 | 7 | @return 8 | 9 | @simple-string-reply: always `OK`. 10 | -------------------------------------------------------------------------------- /iredis/data/commands/watch.md: -------------------------------------------------------------------------------- 1 | Marks the given keys to be watched for conditional execution of a 2 | [transaction][tt]. 3 | 4 | [tt]: /topics/transactions 5 | 6 | @return 7 | 8 | @simple-string-reply: always `OK`. 9 | -------------------------------------------------------------------------------- /iredis/data/commands/xack.md: -------------------------------------------------------------------------------- 1 | The `XACK` command removes one or multiple messages from the 2 | *Pending Entries List* (PEL) of a stream consumer group. A message is pending, 3 | and as such stored inside the PEL, when it was delivered to some consumer, 4 | normally as a side effect of calling `XREADGROUP`, or when a consumer took 5 | ownership of a message calling `XCLAIM`. The pending message was delivered to 6 | some consumer but the server is yet not sure it was processed at least once. 7 | So new calls to `XREADGROUP` to grab the messages history for a consumer 8 | (for instance using an ID of 0), will return such message. 9 | Similarly the pending message will be listed by the `XPENDING` command, 10 | that inspects the PEL. 11 | 12 | Once a consumer *successfully* processes a message, it should call `XACK` 13 | so that such message does not get processed again, and as a side effect, 14 | the PEL entry about this message is also purged, releasing memory from the 15 | Redis server. 16 | 17 | @return 18 | 19 | @integer-reply, specifically: 20 | 21 | The command returns the number of messages successfully acknowledged. 22 | Certain message IDs may no longer be part of the PEL (for example because 23 | they have already been acknowledged), and XACK will not count them as 24 | successfully acknowledged. 25 | 26 | @examples 27 | 28 | ``` 29 | redis> XACK mystream mygroup 1526569495631-0 30 | (integer) 1 31 | ``` 32 | -------------------------------------------------------------------------------- /iredis/data/commands/xgroup-createconsumer.md: -------------------------------------------------------------------------------- 1 | Create a consumer named `` in the consumer group `` of the stream that's stored at ``. 2 | 3 | Consumers are also created automatically whenever an operation, such as `XREADGROUP`, references a consumer that doesn't exist. 4 | 5 | @return 6 | 7 | @integer-reply: the number of created consumers (0 or 1) -------------------------------------------------------------------------------- /iredis/data/commands/xgroup-delconsumer.md: -------------------------------------------------------------------------------- 1 | The `XGROUP DELCONSUMER` command deletes a consumer from the consumer group. 2 | 3 | Sometimes it may be useful to remove old consumers since they are no longer used. 4 | 5 | Note, however, that any pending messages that the consumer had will become unclaimable after it was deleted. 6 | It is strongly recommended, therefore, that any pending messages are claimed or acknowledged prior to deleting the consumer from the group. 7 | 8 | @return 9 | 10 | @integer-reply: the number of pending messages that the consumer had before it was deleted 11 | -------------------------------------------------------------------------------- /iredis/data/commands/xgroup-destroy.md: -------------------------------------------------------------------------------- 1 | The `XGROUP DESTROY` command completely destroys a consumer group. 2 | 3 | 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. 4 | 5 | @return 6 | 7 | @integer-reply: the number of destroyed consumer groups (0 or 1) -------------------------------------------------------------------------------- /iredis/data/commands/xgroup-help.md: -------------------------------------------------------------------------------- 1 | The `XGROUP HELP` command returns a helpful text describing the different subcommands. 2 | 3 | @return 4 | 5 | @array-reply: a list of subcommands and their descriptions 6 | -------------------------------------------------------------------------------- /iredis/data/commands/xgroup-setid.md: -------------------------------------------------------------------------------- 1 | Set the **last delivered ID** for a consumer group. 2 | 3 | Normally, a consumer group's last delivered ID is set when the group is created with `XGROUP CREATE`. 4 | The `XGROUP SETID` command allows modifying the group's last delivered ID, without having to delete and recreate the group. 5 | 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: 6 | 7 | XGROUP SETID mystream mygroup 0 8 | 9 | The optional `entries_read` argument can be specified to enable consumer group lag tracking for an arbitrary ID. 10 | 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. 11 | This can be useful you know exactly how many entries are between the arbitrary ID (excluding it) and the stream's last entry. 12 | In such cases, the `entries_read` can be set to the stream's `entries_added` subtracted with the number of entries. 13 | 14 | @return 15 | 16 | @simple-string-reply: `OK` on success. 17 | -------------------------------------------------------------------------------- /iredis/data/commands/xgroup.md: -------------------------------------------------------------------------------- 1 | This is a container command for stream consumer group management commands. 2 | 3 | To see the list of available commands you can call `XGROUP HELP`. 4 | -------------------------------------------------------------------------------- /iredis/data/commands/xinfo-consumers.md: -------------------------------------------------------------------------------- 1 | This command returns the list of consumers that belong to the `` consumer group of the stream stored at ``. 2 | 3 | The following information is provided for each consumer in the group: 4 | 5 | * **name**: the consumer's name 6 | * **pending**: the number of pending messages for the client, which are messages that were delivered but are yet to be acknowledged 7 | * **idle**: the number of milliseconds that have passed since the consumer last interacted with the server 8 | 9 | @reply 10 | 11 | @array-reply: a list of consumers. 12 | 13 | @examples 14 | 15 | ``` 16 | > XINFO CONSUMERS mystream mygroup 17 | 1) 1) name 18 | 2) "Alice" 19 | 3) pending 20 | 4) (integer) 1 21 | 5) idle 22 | 6) (integer) 9104628 23 | 2) 1) name 24 | 2) "Bob" 25 | 3) pending 26 | 4) (integer) 1 27 | 5) idle 28 | 6) (integer) 83841983 29 | ``` 30 | -------------------------------------------------------------------------------- /iredis/data/commands/xinfo-help.md: -------------------------------------------------------------------------------- 1 | The `XINFO HELP` command returns a helpful text describing the different subcommands. 2 | 3 | @return 4 | 5 | @array-reply: a list of subcommands and their descriptions 6 | -------------------------------------------------------------------------------- /iredis/data/commands/xinfo.md: -------------------------------------------------------------------------------- 1 | This is a container command for stream introspection commands. 2 | 3 | To see the list of available commands you can call `XINFO HELP`. 4 | -------------------------------------------------------------------------------- /iredis/data/commands/xlen.md: -------------------------------------------------------------------------------- 1 | Returns the number of entries inside a stream. If the specified key does not 2 | exist the command returns zero, as if the stream was empty. 3 | However note that unlike other Redis types, zero-length streams are 4 | possible, so you should call `TYPE` or `EXISTS` in order to check if 5 | a key exists or not. 6 | 7 | Streams are not auto-deleted once they have no entries inside (for instance 8 | after an `XDEL` call), because the stream may have consumer groups 9 | associated with it. 10 | 11 | @return 12 | 13 | @integer-reply: the number of entries of the stream at `key`. 14 | 15 | @examples 16 | 17 | ```cli 18 | XADD mystream * item 1 19 | XADD mystream * item 2 20 | XADD mystream * item 3 21 | XLEN mystream 22 | ``` 23 | -------------------------------------------------------------------------------- /iredis/data/commands/xrevrange.md: -------------------------------------------------------------------------------- 1 | This command is exactly like `XRANGE`, but with the notable difference of 2 | returning the entries in reverse order, and also taking the start-end 3 | range in reverse order: in `XREVRANGE` you need to state the *end* ID 4 | and later the *start* ID, and the command will produce all the element 5 | between (or exactly like) the two IDs, starting from the *end* side. 6 | 7 | So for instance, to get all the elements from the higher ID to the lower 8 | ID one could use: 9 | 10 | XREVRANGE somestream + - 11 | 12 | Similarly to get just the last element added into the stream it is 13 | enough to send: 14 | 15 | XREVRANGE somestream + - COUNT 1 16 | 17 | @return 18 | 19 | @array-reply, specifically: 20 | 21 | The command returns the entries with IDs matching the specified range, 22 | from the higher ID to the lower ID matching. 23 | The returned entries are complete, that means that the ID and all the fields 24 | they are composed are returned. Moreover the entries are returned with 25 | their fields and values in the exact same order as `XADD` added them. 26 | 27 | @examples 28 | 29 | ```cli 30 | XADD writers * name Virginia surname Woolf 31 | XADD writers * name Jane surname Austen 32 | XADD writers * name Toni surname Morrison 33 | XADD writers * name Agatha surname Christie 34 | XADD writers * name Ngozi surname Adichie 35 | XLEN writers 36 | XREVRANGE writers + - COUNT 1 37 | ``` 38 | -------------------------------------------------------------------------------- /iredis/data/commands/xsetid.md: -------------------------------------------------------------------------------- 1 | The `XSETID` command is an internal command. 2 | It is used by a Redis master to replicate the last delivered ID of streams. -------------------------------------------------------------------------------- /iredis/data/commands/zcard.md: -------------------------------------------------------------------------------- 1 | Returns the sorted set cardinality (number of elements) of the sorted set stored 2 | at `key`. 3 | 4 | @return 5 | 6 | @integer-reply: the cardinality (number of elements) of the sorted set, or `0` 7 | if `key` does not exist. 8 | 9 | @examples 10 | 11 | ```cli 12 | ZADD myzset 1 "one" 13 | ZADD myzset 2 "two" 14 | ZCARD myzset 15 | ``` 16 | -------------------------------------------------------------------------------- /iredis/data/commands/zcount.md: -------------------------------------------------------------------------------- 1 | Returns the number of elements in the sorted set at `key` with a score between 2 | `min` and `max`. 3 | 4 | The `min` and `max` arguments have the same semantic as described for 5 | `ZRANGEBYSCORE`. 6 | 7 | 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. 8 | 9 | @return 10 | 11 | @integer-reply: the number of elements in the specified score range. 12 | 13 | @examples 14 | 15 | ```cli 16 | ZADD myzset 1 "one" 17 | ZADD myzset 2 "two" 18 | ZADD myzset 3 "three" 19 | ZCOUNT myzset -inf +inf 20 | ZCOUNT myzset (1 3 21 | ``` 22 | -------------------------------------------------------------------------------- /iredis/data/commands/zdiff.md: -------------------------------------------------------------------------------- 1 | This command is similar to `ZDIFFSTORE`, but instead of storing the resulting 2 | sorted set, it is returned to the client. 3 | 4 | @return 5 | 6 | @array-reply: the result of the difference (optionally with their scores, in case 7 | the `WITHSCORES` option is given). 8 | 9 | @examples 10 | 11 | ```cli 12 | ZADD zset1 1 "one" 13 | ZADD zset1 2 "two" 14 | ZADD zset1 3 "three" 15 | ZADD zset2 1 "one" 16 | ZADD zset2 2 "two" 17 | ZDIFF 2 zset1 zset2 18 | ZDIFF 2 zset1 zset2 WITHSCORES 19 | ``` 20 | -------------------------------------------------------------------------------- /iredis/data/commands/zdiffstore.md: -------------------------------------------------------------------------------- 1 | Computes the difference between the first and all successive input sorted sets 2 | and stores the result in `destination`. The total number of input keys is 3 | specified by `numkeys`. 4 | 5 | Keys that do not exist are considered to be empty sets. 6 | 7 | If `destination` already exists, it is overwritten. 8 | 9 | @return 10 | 11 | @integer-reply: the number of elements in the resulting sorted set at 12 | `destination`. 13 | 14 | @examples 15 | 16 | ```cli 17 | ZADD zset1 1 "one" 18 | ZADD zset1 2 "two" 19 | ZADD zset1 3 "three" 20 | ZADD zset2 1 "one" 21 | ZADD zset2 2 "two" 22 | ZDIFFSTORE out 2 zset1 zset2 23 | ZRANGE out 0 -1 WITHSCORES 24 | ``` 25 | -------------------------------------------------------------------------------- /iredis/data/commands/zincrby.md: -------------------------------------------------------------------------------- 1 | Increments the score of `member` in the sorted set stored at `key` by 2 | `increment`. 3 | If `member` does not exist in the sorted set, it is added with `increment` as 4 | its score (as if its previous score was `0.0`). 5 | If `key` does not exist, a new sorted set with the specified `member` as its 6 | sole member is created. 7 | 8 | An error is returned when `key` exists but does not hold a sorted set. 9 | 10 | The `score` value should be the string representation of a numeric value, and 11 | accepts double precision floating point numbers. 12 | It is possible to provide a negative value to decrement the score. 13 | 14 | @return 15 | 16 | @bulk-string-reply: the new score of `member` (a double precision floating point 17 | number), represented as string. 18 | 19 | @examples 20 | 21 | ```cli 22 | ZADD myzset 1 "one" 23 | ZADD myzset 2 "two" 24 | ZINCRBY myzset 2 "one" 25 | ZRANGE myzset 0 -1 WITHSCORES 26 | ``` 27 | -------------------------------------------------------------------------------- /iredis/data/commands/zinter.md: -------------------------------------------------------------------------------- 1 | This command is similar to `ZINTERSTORE`, but instead of storing the resulting 2 | sorted set, it is returned to the client. 3 | 4 | For a description of the `WEIGHTS` and `AGGREGATE` options, see `ZUNIONSTORE`. 5 | 6 | @return 7 | 8 | @array-reply: the result of intersection (optionally with their scores, in case 9 | the `WITHSCORES` option is given). 10 | 11 | @examples 12 | 13 | ```cli 14 | ZADD zset1 1 "one" 15 | ZADD zset1 2 "two" 16 | ZADD zset2 1 "one" 17 | ZADD zset2 2 "two" 18 | ZADD zset2 3 "three" 19 | ZINTER 2 zset1 zset2 20 | ZINTER 2 zset1 zset2 WITHSCORES 21 | ``` 22 | -------------------------------------------------------------------------------- /iredis/data/commands/zintercard.md: -------------------------------------------------------------------------------- 1 | This command is similar to `ZINTER`, but instead of returning the result set, it returns just the cardinality of the result. 2 | 3 | Keys that do not exist are considered to be empty sets. 4 | 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). 5 | 6 | By default, the command calculates the cardinality of the intersection of all given sets. 7 | 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. 8 | Such implementation ensures a significant speedup for queries where the limit is lower than the actual intersection cardinality. 9 | 10 | @return 11 | 12 | @integer-reply: the number of elements in the resulting intersection. 13 | 14 | @examples 15 | 16 | ```cli 17 | ZADD zset1 1 "one" 18 | ZADD zset1 2 "two" 19 | ZADD zset2 1 "one" 20 | ZADD zset2 2 "two" 21 | ZADD zset2 3 "three" 22 | ZINTER 2 zset1 zset2 23 | ZINTERCARD 2 zset1 zset2 24 | ZINTERCARD 2 zset1 zset2 LIMIT 1 25 | ``` 26 | -------------------------------------------------------------------------------- /iredis/data/commands/zinterstore.md: -------------------------------------------------------------------------------- 1 | Computes the intersection of `numkeys` sorted sets given by the specified keys, 2 | and stores the result in `destination`. 3 | It is mandatory to provide the number of input keys (`numkeys`) before passing 4 | the input keys and the other (optional) arguments. 5 | 6 | By default, the resulting score of an element is the sum of its scores in the 7 | sorted sets where it exists. 8 | Because intersection requires an element to be a member of every given sorted 9 | set, this results in the score of every element in the resulting sorted set to 10 | be equal to the number of input sorted sets. 11 | 12 | For a description of the `WEIGHTS` and `AGGREGATE` options, see `ZUNIONSTORE`. 13 | 14 | If `destination` already exists, it is overwritten. 15 | 16 | @return 17 | 18 | @integer-reply: the number of elements in the resulting sorted set at 19 | `destination`. 20 | 21 | @examples 22 | 23 | ```cli 24 | ZADD zset1 1 "one" 25 | ZADD zset1 2 "two" 26 | ZADD zset2 1 "one" 27 | ZADD zset2 2 "two" 28 | ZADD zset2 3 "three" 29 | ZINTERSTORE out 2 zset1 zset2 WEIGHTS 2 3 30 | ZRANGE out 0 -1 WITHSCORES 31 | ``` 32 | -------------------------------------------------------------------------------- /iredis/data/commands/zlexcount.md: -------------------------------------------------------------------------------- 1 | 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`. 2 | 3 | The `min` and `max` arguments have the same meaning as described for 4 | `ZRANGEBYLEX`. 5 | 6 | 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. 7 | 8 | @return 9 | 10 | @integer-reply: the number of elements in the specified score range. 11 | 12 | @examples 13 | 14 | ```cli 15 | ZADD myzset 0 a 0 b 0 c 0 d 0 e 16 | ZADD myzset 0 f 0 g 17 | ZLEXCOUNT myzset - + 18 | ZLEXCOUNT myzset [b [f 19 | ``` 20 | -------------------------------------------------------------------------------- /iredis/data/commands/zmscore.md: -------------------------------------------------------------------------------- 1 | Returns the scores associated with the specified `members` in the sorted set stored at `key`. 2 | 3 | For every `member` that does not exist in the sorted set, a `nil` value is returned. 4 | 5 | @return 6 | 7 | @array-reply: list of scores or `nil` associated with the specified `member` values (a double precision floating point number), 8 | represented as strings. 9 | 10 | @examples 11 | 12 | ```cli 13 | ZADD myzset 1 "one" 14 | ZADD myzset 2 "two" 15 | ZMSCORE myzset "one" "two" "nofield" 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/zpopmax.md: -------------------------------------------------------------------------------- 1 | Removes and returns up to `count` members with the highest scores in the sorted 2 | set stored at `key`. 3 | 4 | When left unspecified, the default value for `count` is 1. Specifying a `count` 5 | value that is higher than the sorted set's cardinality will not produce an 6 | error. When returning multiple elements, the one with the highest score will 7 | be the first, followed by the elements with lower scores. 8 | 9 | @return 10 | 11 | @array-reply: list of popped elements and scores. 12 | 13 | @examples 14 | 15 | ```cli 16 | ZADD myzset 1 "one" 17 | ZADD myzset 2 "two" 18 | ZADD myzset 3 "three" 19 | ZPOPMAX myzset 20 | ``` 21 | -------------------------------------------------------------------------------- /iredis/data/commands/zpopmin.md: -------------------------------------------------------------------------------- 1 | Removes and returns up to `count` members with the lowest scores in the sorted 2 | set stored at `key`. 3 | 4 | When left unspecified, the default value for `count` is 1. Specifying a `count` 5 | value that is higher than the sorted set's cardinality will not produce an 6 | error. When returning multiple elements, the one with the lowest score will 7 | be the first, followed by the elements with greater scores. 8 | 9 | @return 10 | 11 | @array-reply: list of popped elements and scores. 12 | 13 | @examples 14 | 15 | ```cli 16 | ZADD myzset 1 "one" 17 | ZADD myzset 2 "two" 18 | ZADD myzset 3 "three" 19 | ZPOPMIN myzset 20 | ``` 21 | -------------------------------------------------------------------------------- /iredis/data/commands/zrangestore.md: -------------------------------------------------------------------------------- 1 | This command is like `ZRANGE`, but stores the result in the `` destination key. 2 | 3 | @return 4 | 5 | @integer-reply: the number of elements in the resulting sorted set. 6 | 7 | @examples 8 | 9 | ```cli 10 | ZADD srczset 1 "one" 2 "two" 3 "three" 4 "four" 11 | ZRANGESTORE dstzset srczset 2 -1 12 | ZRANGE dstzset 0 -1 13 | ``` 14 | -------------------------------------------------------------------------------- /iredis/data/commands/zrank.md: -------------------------------------------------------------------------------- 1 | Returns the rank of `member` in the sorted set stored at `key`, with the scores 2 | ordered from low to high. 3 | The rank (or index) is 0-based, which means that the member with the lowest 4 | score has rank `0`. 5 | 6 | Use `ZREVRANK` to get the rank of an element with the scores ordered from high 7 | to low. 8 | 9 | @return 10 | 11 | * If `member` exists in the sorted set, @integer-reply: the rank of `member`. 12 | * If `member` does not exist in the sorted set or `key` does not exist, 13 | @bulk-string-reply: `nil`. 14 | 15 | @examples 16 | 17 | ```cli 18 | ZADD myzset 1 "one" 19 | ZADD myzset 2 "two" 20 | ZADD myzset 3 "three" 21 | ZRANK myzset "three" 22 | ZRANK myzset "four" 23 | ``` 24 | -------------------------------------------------------------------------------- /iredis/data/commands/zrem.md: -------------------------------------------------------------------------------- 1 | Removes the specified members from the sorted set stored at `key`. 2 | Non existing members are ignored. 3 | 4 | An error is returned when `key` exists and does not hold a sorted set. 5 | 6 | @return 7 | 8 | @integer-reply, specifically: 9 | 10 | * The number of members removed from the sorted set, not including non existing 11 | members. 12 | 13 | @examples 14 | 15 | ```cli 16 | ZADD myzset 1 "one" 17 | ZADD myzset 2 "two" 18 | ZADD myzset 3 "three" 19 | ZREM myzset "two" 20 | ZRANGE myzset 0 -1 WITHSCORES 21 | ``` 22 | -------------------------------------------------------------------------------- /iredis/data/commands/zremrangebylex.md: -------------------------------------------------------------------------------- 1 | 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`. 2 | 3 | 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. 4 | 5 | @return 6 | 7 | @integer-reply: the number of elements removed. 8 | 9 | @examples 10 | 11 | ```cli 12 | ZADD myzset 0 aaaa 0 b 0 c 0 d 0 e 13 | ZADD myzset 0 foo 0 zap 0 zip 0 ALPHA 0 alpha 14 | ZRANGE myzset 0 -1 15 | ZREMRANGEBYLEX myzset [alpha [omega 16 | ZRANGE myzset 0 -1 17 | ``` 18 | -------------------------------------------------------------------------------- /iredis/data/commands/zremrangebyrank.md: -------------------------------------------------------------------------------- 1 | Removes all elements in the sorted set stored at `key` with rank between `start` 2 | and `stop`. 3 | Both `start` and `stop` are `0` -based indexes with `0` being the element with 4 | the lowest score. 5 | These indexes can be negative numbers, where they indicate offsets starting at 6 | the element with the highest score. 7 | For example: `-1` is the element with the highest score, `-2` the element with 8 | the second highest score and so forth. 9 | 10 | @return 11 | 12 | @integer-reply: the number of elements removed. 13 | 14 | @examples 15 | 16 | ```cli 17 | ZADD myzset 1 "one" 18 | ZADD myzset 2 "two" 19 | ZADD myzset 3 "three" 20 | ZREMRANGEBYRANK myzset 0 1 21 | ZRANGE myzset 0 -1 WITHSCORES 22 | ``` 23 | -------------------------------------------------------------------------------- /iredis/data/commands/zremrangebyscore.md: -------------------------------------------------------------------------------- 1 | Removes all elements in the sorted set stored at `key` with a score between 2 | `min` and `max` (inclusive). 3 | 4 | @return 5 | 6 | @integer-reply: the number of elements removed. 7 | 8 | @examples 9 | 10 | ```cli 11 | ZADD myzset 1 "one" 12 | ZADD myzset 2 "two" 13 | ZADD myzset 3 "three" 14 | ZREMRANGEBYSCORE myzset -inf (2 15 | ZRANGE myzset 0 -1 WITHSCORES 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/zrevrange.md: -------------------------------------------------------------------------------- 1 | Returns the specified range of elements in the sorted set stored at `key`. 2 | The elements are considered to be ordered from the highest to the lowest score. 3 | Descending lexicographical order is used for elements with equal score. 4 | 5 | Apart from the reversed ordering, `ZREVRANGE` is similar to `ZRANGE`. 6 | 7 | @return 8 | 9 | @array-reply: list of elements in the specified range (optionally with 10 | their scores). 11 | 12 | @examples 13 | 14 | ```cli 15 | ZADD myzset 1 "one" 16 | ZADD myzset 2 "two" 17 | ZADD myzset 3 "three" 18 | ZREVRANGE myzset 0 -1 19 | ZREVRANGE myzset 2 3 20 | ZREVRANGE myzset -2 -1 21 | ``` 22 | -------------------------------------------------------------------------------- /iredis/data/commands/zrevrangebylex.md: -------------------------------------------------------------------------------- 1 | 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`. 2 | 3 | Apart from the reversed ordering, `ZREVRANGEBYLEX` is similar to `ZRANGEBYLEX`. 4 | 5 | @return 6 | 7 | @array-reply: list of elements in the specified score range. 8 | 9 | @examples 10 | 11 | ```cli 12 | ZADD myzset 0 a 0 b 0 c 0 d 0 e 0 f 0 g 13 | ZREVRANGEBYLEX myzset [c - 14 | ZREVRANGEBYLEX myzset (c - 15 | ZREVRANGEBYLEX myzset (g [aaa 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/zrevrangebyscore.md: -------------------------------------------------------------------------------- 1 | Returns all the elements in the sorted set at `key` with a score between `max` 2 | and `min` (including elements with score equal to `max` or `min`). 3 | In contrary to the default ordering of sorted sets, for this command the 4 | elements are considered to be ordered from high to low scores. 5 | 6 | The elements having the same score are returned in reverse lexicographical 7 | order. 8 | 9 | Apart from the reversed ordering, `ZREVRANGEBYSCORE` is similar to 10 | `ZRANGEBYSCORE`. 11 | 12 | @return 13 | 14 | @array-reply: list of elements in the specified score range (optionally 15 | with their scores). 16 | 17 | @examples 18 | 19 | ```cli 20 | ZADD myzset 1 "one" 21 | ZADD myzset 2 "two" 22 | ZADD myzset 3 "three" 23 | ZREVRANGEBYSCORE myzset +inf -inf 24 | ZREVRANGEBYSCORE myzset 2 1 25 | ZREVRANGEBYSCORE myzset 2 (1 26 | ZREVRANGEBYSCORE myzset (2 (1 27 | ``` 28 | -------------------------------------------------------------------------------- /iredis/data/commands/zrevrank.md: -------------------------------------------------------------------------------- 1 | Returns the rank of `member` in the sorted set stored at `key`, with the scores 2 | ordered from high to low. 3 | The rank (or index) is 0-based, which means that the member with the highest 4 | score has rank `0`. 5 | 6 | Use `ZRANK` to get the rank of an element with the scores ordered from low to 7 | high. 8 | 9 | @return 10 | 11 | * If `member` exists in the sorted set, @integer-reply: the rank of `member`. 12 | * If `member` does not exist in the sorted set or `key` does not exist, 13 | @bulk-string-reply: `nil`. 14 | 15 | @examples 16 | 17 | ```cli 18 | ZADD myzset 1 "one" 19 | ZADD myzset 2 "two" 20 | ZADD myzset 3 "three" 21 | ZREVRANK myzset "one" 22 | ZREVRANK myzset "four" 23 | ``` 24 | -------------------------------------------------------------------------------- /iredis/data/commands/zscan.md: -------------------------------------------------------------------------------- 1 | See `SCAN` for `ZSCAN` documentation. 2 | -------------------------------------------------------------------------------- /iredis/data/commands/zscore.md: -------------------------------------------------------------------------------- 1 | Returns the score of `member` in the sorted set at `key`. 2 | 3 | If `member` does not exist in the sorted set, or `key` does not exist, `nil` is 4 | returned. 5 | 6 | @return 7 | 8 | @bulk-string-reply: the score of `member` (a double precision floating point number), 9 | represented as string. 10 | 11 | @examples 12 | 13 | ```cli 14 | ZADD myzset 1 "one" 15 | ZSCORE myzset "one" 16 | ``` 17 | -------------------------------------------------------------------------------- /iredis/data/commands/zunion.md: -------------------------------------------------------------------------------- 1 | This command is similar to `ZUNIONSTORE`, but instead of storing the resulting 2 | sorted set, it is returned to the client. 3 | 4 | For a description of the `WEIGHTS` and `AGGREGATE` options, see `ZUNIONSTORE`. 5 | 6 | @return 7 | 8 | @array-reply: the result of union (optionally with their scores, in case 9 | the `WITHSCORES` option is given). 10 | 11 | @examples 12 | 13 | ```cli 14 | ZADD zset1 1 "one" 15 | ZADD zset1 2 "two" 16 | ZADD zset2 1 "one" 17 | ZADD zset2 2 "two" 18 | ZADD zset2 3 "three" 19 | ZUNION 2 zset1 zset2 20 | ZUNION 2 zset1 zset2 WITHSCORES 21 | ``` 22 | -------------------------------------------------------------------------------- /iredis/data/dangerous_commands.csv: -------------------------------------------------------------------------------- 1 | Command,Reason 2 | FLUSHDB,"FLUSHDB will delete all the keys of the currently selected DB" 3 | FLUSHALL,"FLUSHALL will delete all the keys of all the existing databases" 4 | KEYS,"KEYS will hang redis server, use SCAN instead" 5 | PEXPIRE,"PEXPIRE may delete keys" 6 | DEL,"DEL will delete keys, it may cause high latency when the value is big" 7 | CONFIG SET,"CONFIG SET will change the server's configs" 8 | SHUTDOWN,"SHUTDOWN will shutdown the server" 9 | SAVE,"SAVE performs a synchronous save, it will hang redis server" 10 | SPOP,"SPOP will delete items" 11 | SREM,"SREM will delete items" 12 | RENAME,"RENAME use DELETE command to overwrite exist key, it may cause high latency when the value is big" 13 | DEBUG,"It's a dangerous command" 14 | -------------------------------------------------------------------------------- /iredis/exceptions.py: -------------------------------------------------------------------------------- 1 | class IRedisException(Exception): 2 | pass 3 | 4 | 5 | class UsageError(IRedisException): 6 | pass 7 | 8 | 9 | class InvalidArguments(IRedisException): 10 | """Invalid argument(s)""" 11 | 12 | 13 | class NotRedisCommand(IRedisException): 14 | """Not a Redis command""" 15 | 16 | 17 | class AmbiguousCommand(IRedisException): 18 | """Command is not finished, don't it's command's name""" 19 | 20 | 21 | class NotSupport(IRedisException): 22 | """IRedis currently not support this.""" 23 | -------------------------------------------------------------------------------- /iredis/key_bindings.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from prompt_toolkit.filters import completion_is_selected 4 | from prompt_toolkit.key_binding import KeyBindings 5 | 6 | logger = logging.getLogger(__name__) 7 | 8 | kb = KeyBindings() 9 | 10 | 11 | @kb.add("enter", filter=completion_is_selected) 12 | def _(event): 13 | """Makes the enter key work as the tab key only when showing the menu. 14 | In other words, don't execute query when enter is pressed in 15 | the completion dropdown menu, instead close the dropdown menu 16 | (accept current selection). 17 | """ 18 | logger.debug("Detected enter key.") 19 | 20 | event.current_buffer.complete_state = None 21 | b = event.app.current_buffer 22 | b.complete_state = None 23 | -------------------------------------------------------------------------------- /scripts/add_fooset_commands.txt: -------------------------------------------------------------------------------- 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 2 | -------------------------------------------------------------------------------- /scripts/add_hash.txt: -------------------------------------------------------------------------------- 1 | HMSET hash1 Tolerant intolerant Decent indecent Discrete indiscreet Excusable inexcusable 2 | HMSET hash2 Behave misbehave Interpret misinterpret Lead mislead Trust mistrust Likely unlikely Able unable Fortunate unfortunate Forgiving unforgiving 3 | HMSET hash3 Entity nonentity Conformist nonconformist Payment nonpayment Sense nonsense 4 | -------------------------------------------------------------------------------- /scripts/add_lists.txt: -------------------------------------------------------------------------------- 1 | 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 2 | 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" 3 | LPUSH list:restaurant bill breakfast check cup dessert dinner dressing drink fork hamburger knife lunch menu napkin order salt spoon water coffee tea 4 | -------------------------------------------------------------------------------- /scripts/check_renders.sh: -------------------------------------------------------------------------------- 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 2 | -------------------------------------------------------------------------------- /scripts/conf/slave/slave.conf: -------------------------------------------------------------------------------- 1 | slaveof localhost 6379 2 | port 6479 3 | -------------------------------------------------------------------------------- /scripts/display_all_command_hints.py: -------------------------------------------------------------------------------- 1 | from iredis.utils import command_syntax 2 | from iredis.style import STYLE 3 | from iredis.commands import commands_summary 4 | from prompt_toolkit import print_formatted_text 5 | 6 | for command, info in commands_summary.items(): 7 | print_formatted_text(command_syntax(command, info), style=STYLE) 8 | -------------------------------------------------------------------------------- /scripts/multi_del.txt: -------------------------------------------------------------------------------- 1 | DEL key-001 2 | DEL key-002 3 | DEL key-003 4 | DEL key-004 5 | -------------------------------------------------------------------------------- /scripts/redis.conf: -------------------------------------------------------------------------------- 1 | port 7379 2 | unixsocket /tmp/redis.sock 3 | unixsocketperm 775 4 | aclfile /tmp/redis.acl 5 | -------------------------------------------------------------------------------- /scripts/set_999_keys_in_redis.py: -------------------------------------------------------------------------------- 1 | import redis 2 | 3 | client = redis.StrictRedis(db=3) 4 | 5 | for i in range(100000): 6 | client.set(f"key-{i}", "hello world") 7 | -------------------------------------------------------------------------------- /scripts/tcp-proxy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # Display TCP packets 3 | # code from: 4 | # https://notes.tweakblogs.net/blog/7955/using-netcat-to-build-a-simple-tcp-proxy-in-linux.html 5 | 6 | if [ $# != 3 ] 7 | then 8 | echo "usage: $0 " 9 | exit 0 10 | fi 11 | 12 | TMP=`mktemp -d` 13 | BACK=$TMP/pipe.back 14 | SENT=$TMP/pipe.sent 15 | RCVD=$TMP/pipe.rcvd 16 | trap 'rm -rf "$TMP"' EXIT 17 | mkfifo -m 0600 "$BACK" "$SENT" "$RCVD" 18 | sed 's/^/ => /' <"$SENT" & 19 | sed 's/^/<= /' <"$RCVD" & 20 | nc -l 127.0.0.1 "$1" <"$BACK" | tee "$SENT" | nc "$2" "$3" | tee "$RCVD" >"$BACK" 21 | -------------------------------------------------------------------------------- /scripts/update_command_from_redis_doc.sh: -------------------------------------------------------------------------------- 1 | wget https://raw.githubusercontent.com/antirez/redis-doc/master/commands.json -O commands.json 2 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laixintao/iredis/27be126e4ea798115547111752f83c8998d66707/tests/__init__.py -------------------------------------------------------------------------------- /tests/cli_tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laixintao/iredis/27be126e4ea798115547111752f83c8998d66707/tests/cli_tests/__init__.py -------------------------------------------------------------------------------- /tests/cli_tests/test_cli_pubsub.py: -------------------------------------------------------------------------------- 1 | def test_subscribe(cli, clean_redis): 2 | cli.sendline("subscribe foo") 3 | cli.expect("subscribe from") 4 | cli.expect("foo") 5 | cli.expect("1") 6 | 7 | clean_redis.publish("foo", "test message") 8 | cli.expect("from") 9 | cli.expect("foo") 10 | cli.expect("test message") 11 | 12 | # unsubscribe, send ctrl-c 13 | cli.send(chr(3)) 14 | cli.expect("unsubscribe from") 15 | cli.expect("0") 16 | 17 | 18 | def test_subscribe_in_raw_mode(raw_cli, clean_redis): 19 | raw_cli.sendline("subscribe foo") 20 | raw_cli.expect("subscribe\r") 21 | raw_cli.expect("foo\r") 22 | raw_cli.expect("1\r") 23 | 24 | clean_redis.publish("foo", "test message") 25 | raw_cli.expect("message\r") 26 | raw_cli.expect("foo\r") 27 | raw_cli.expect("test message") 28 | 29 | # unsubscribe, send ctrl-c 30 | raw_cli.send(chr(3)) 31 | raw_cli.expect("0\r") 32 | -------------------------------------------------------------------------------- /tests/cli_tests/test_command_restore.py: -------------------------------------------------------------------------------- 1 | def test_restore_command(clean_redis, cli): 2 | cli.sendline(r'restore foo1 0 "\x00\x03bar\t\x006L\x18\xac\xba\xe0\x9e\xa6"') 3 | cli.expect(["OK", "127.0.0.1"]) 4 | 5 | cli.sendline("get foo1") 6 | cli.expect('"bar"') 7 | -------------------------------------------------------------------------------- /tests/cli_tests/test_history.py: -------------------------------------------------------------------------------- 1 | import os 2 | import pexpect 3 | from pathlib import Path 4 | from textwrap import dedent 5 | 6 | 7 | def test_history_not_log_auth(cli): 8 | cli.sendline("AUTH 123") 9 | cli.expect(["Client sent AUTH, but no password is set", "127.0.0.1"]) 10 | cli.sendline("set foo bar") 11 | cli.expect("OK") 12 | 13 | with open(os.path.expanduser("~/.iredis_history")) as history_file: 14 | content = history_file.read() 15 | 16 | assert "set foo bar" in content 17 | assert "AUTH" not in content 18 | 19 | 20 | def test_history_create_and_writing_with_config(): 21 | config_content = dedent( 22 | """ 23 | [main] 24 | history_location = /tmp/iredis_history.txt 25 | """ 26 | ) 27 | with open("/tmp/iredisrc", "w+") as etc_config: 28 | etc_config.write(config_content) 29 | 30 | cli = pexpect.spawn("iredis -n 15 --iredisrc /tmp/iredisrc", timeout=2) 31 | cli.expect("127.0.0.1") 32 | cli.sendline("set hello world") 33 | cli.expect("OK") 34 | cli.close() 35 | 36 | log = Path("/tmp/iredis_history.txt") 37 | assert log.exists() 38 | 39 | with open(log) as logfile: 40 | content = logfile.read() 41 | 42 | assert "set hello world" in content 43 | -------------------------------------------------------------------------------- /tests/cli_tests/test_on_error.py: -------------------------------------------------------------------------------- 1 | def test_wrong_stream_type(clean_redis, cli): 2 | clean_redis.lpush("mylist", "foo") 3 | cli.sendline("xrange mylist 0 -1") 4 | cli.expect("error") 5 | cli.expect("Invalid stream ID specified as stream command argument") 6 | 7 | 8 | def test_wrong_stream_type_in_raw_mode(clean_redis, raw_cli): 9 | clean_redis.lpush("mylist", "foo") 10 | raw_cli.sendline("xrange mylist 0 -1") 11 | raw_cli.expect("ERROR") 12 | raw_cli.expect("Invalid stream ID specified as stream command argument") 13 | -------------------------------------------------------------------------------- /tests/cli_tests/test_self_implemented_command.py: -------------------------------------------------------------------------------- 1 | """ 2 | check ascii table: 3 | http://ascii-table.com/ansi-escape-sequences.php 4 | """ 5 | 6 | 7 | def test_clear(cli): 8 | cli.sendline("clear") 9 | cli.expect("\\[2J") # clear screen 10 | 11 | 12 | def test_exirt(cli): 13 | cli.sendline("EXIT") 14 | cli.expect("Goodbye!") 15 | -------------------------------------------------------------------------------- /tests/cli_tests/test_shell_pipeline.py: -------------------------------------------------------------------------------- 1 | import pexpect 2 | 3 | 4 | def test_running_disable_shell_pipeline(): 5 | cli = pexpect.spawn("iredis -n 15 --no-shell", timeout=2) 6 | cli.expect("127.0.0.1") 7 | cli.sendline("set foo hello") 8 | cli.expect("OK") 9 | cli.sendline("get foo | grep w") 10 | cli.expect(r"hello") 11 | cli.close() 12 | 13 | 14 | def test_running_disable_shell_pipeline_with_decode_option(): 15 | cli = pexpect.spawn("iredis -n 15 --decode=utf-8", timeout=2) 16 | cli.expect("127.0.0.1") 17 | cli.sendline("set foo hello") 18 | cli.expect("OK") 19 | cli.sendline("get foo | cat") 20 | cli.expect(r"hello") 21 | cli.close() 22 | -------------------------------------------------------------------------------- /tests/cli_tests/test_string_execute.py: -------------------------------------------------------------------------------- 1 | def test_set(cli): 2 | cli.sendline("set foo bar") 3 | cli.expect(["OK", "127.0.0.1"]) 4 | 5 | cli.sendline("set foo bar nx") 6 | cli.expect(["(nil)", "127.0.0.1"]) 7 | 8 | cli.sendline("set foo bar xx") 9 | cli.expect(["OK", "127.0.0.1"]) 10 | 11 | cli.sendline("set foo1 bar xx") 12 | cli.expect(["(nil)", "127.0.0.1"]) 13 | 14 | 15 | def test_get(cli): 16 | cli.sendline("set foo bar") 17 | cli.expect("OK") 18 | 19 | cli.sendline("get foo") 20 | cli.expect('"bar"') 21 | 22 | 23 | def test_delete_string(clean_redis, cli, config): 24 | config.warning = True 25 | cli.sendline("set foo bar") 26 | cli.expect("OK") 27 | cli.sendline("del foo") 28 | cli.expect("Do you want to proceed") 29 | cli.sendline("yes") 30 | cli.expect("1") 31 | 32 | cli.sendline("get foo") 33 | cli.expect("(nil)") 34 | 35 | 36 | def test_on_dangerous_commands(cli, config): 37 | config.warning = True 38 | cli.sendline("keys *") 39 | cli.expect("KEYS will hang redis server, use SCAN instead") 40 | -------------------------------------------------------------------------------- /tests/cli_tests/wrappager.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | import fileinput 4 | 5 | 6 | def wrappager(boundary): 7 | print(boundary) 8 | for line in fileinput.input(files="-"): 9 | sys.stdout.write(line) 10 | print(boundary) 11 | 12 | 13 | if __name__ == "__main__": 14 | wrappager(sys.argv[1]) 15 | -------------------------------------------------------------------------------- /tests/helpers.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | 4 | def formatted_text_rematch(value_to_test, expected_formatted_text): 5 | """ 6 | ``expected_formatted_text`` can be regex. 7 | """ 8 | for value, expected in zip(value_to_test, expected_formatted_text): 9 | assert value[0] == expected[0] 10 | print(expected[1], value[1]) 11 | assert re.match(expected[1], value[1]) 12 | -------------------------------------------------------------------------------- /tests/unittests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laixintao/iredis/27be126e4ea798115547111752f83c8998d66707/tests/unittests/__init__.py -------------------------------------------------------------------------------- /tests/unittests/command_parse/test_hll_parse.py: -------------------------------------------------------------------------------- 1 | def test_pfmerge(judge_command): 2 | judge_command( 3 | "PFMERGE hll3 hll1 hll2", 4 | {"command": "PFMERGE", "newkey": "hll3", "keys": "hll1 hll2"}, 5 | ) 6 | -------------------------------------------------------------------------------- /tests/unittests/command_parse/test_pubsub.py: -------------------------------------------------------------------------------- 1 | def test_publish(judge_command): 2 | judge_command( 3 | "publish foo bar", {"command": "publish", "channel": "foo", "message": "bar"} 4 | ) 5 | 6 | 7 | def test_subscribe(judge_command): 8 | judge_command("subscribe foo bar", {"command": "subscribe", "channel": "bar"}) 9 | 10 | 11 | def test_pubsub(judge_command): 12 | judge_command( 13 | "PUBSUB NUMSUB foo bar", 14 | {"command": "PUBSUB", "pubsubcmd": "NUMSUB", "channel": "bar"}, 15 | ) 16 | -------------------------------------------------------------------------------- /tests/unittests/command_parse/test_script.py: -------------------------------------------------------------------------------- 1 | def test_eval(judge_command): 2 | judge_command( 3 | 'eval "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}" 2 key1 key2 first second', 4 | { 5 | "command": "eval", 6 | "double_lua": "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", 7 | "any": "2 key1 key2 first second", 8 | }, 9 | ) 10 | judge_command( 11 | "eval 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}' 2 key1 key2 first second", 12 | { 13 | "command": "eval", 14 | "single_lua": "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", 15 | "any": "2 key1 key2 first second", 16 | }, 17 | ) 18 | 19 | 20 | def test_scriptdebug(judge_command): 21 | judge_command("SCRIPT DEBUG YES", {"command": "SCRIPT DEBUG", "scriptdebug": "YES"}) 22 | judge_command("SCRIPT DEBUG no", {"command": "SCRIPT DEBUG", "scriptdebug": "no"}) 23 | -------------------------------------------------------------------------------- /tests/unittests/test_markdown_doc_render.py: -------------------------------------------------------------------------------- 1 | """ 2 | This test ensures that all of redis-doc's markdown can be rendered. 3 | Why do we need this? 4 | see: 5 | https://github.com/antirez/redis-doc/commit/02b3d1a345093c1794fd86273e9d516fffd3b819 6 | """ 7 | 8 | import pytest 9 | from importlib.resources import read_text 10 | 11 | from iredis.commands import commands_summary 12 | from iredis.data import commands as commands_data 13 | from iredis.markdown import render 14 | 15 | 16 | doc_files = [] 17 | for command, info in commands_summary.items(): 18 | command_docs_name = "-".join(command.split()).lower() 19 | if info["group"] == "iredis": 20 | continue 21 | doc_files.append(f"{command_docs_name}.md") 22 | 23 | 24 | @pytest.mark.parametrize("filename", doc_files) 25 | def test_markdown_render(filename): 26 | print(filename) 27 | doc = read_text(commands_data, filename) 28 | render(doc) 29 | --------------------------------------------------------------------------------