├── INSTALL ├── tests ├── tmp │ └── .gitignore ├── cluster │ ├── tmp │ │ └── .gitignore │ ├── tests │ │ ├── helpers │ │ │ └── onlydots.tcl │ │ └── 01-faildet.tcl │ └── run.tcl ├── sentinel │ ├── tmp │ │ └── .gitignore │ └── tests │ │ ├── 04-slave-selection.tcl │ │ ├── includes │ │ ├── sentinel.conf │ │ ├── start-init-tests.tcl │ │ └── utils.tcl │ │ └── 14-debug-command.tcl ├── assets │ ├── nodefaultuser.acl │ ├── userwithselectors.acl │ ├── encodings.rdb │ ├── hash-zipmap.rdb │ ├── hash-ziplist.rdb │ ├── rdb-preamble.aof │ ├── scriptbackup.rdb │ ├── zset-ziplist.rdb │ ├── corrupt_ziplist.rdb │ ├── list-quicklist.rdb │ ├── corrupt_empty_keys.rdb │ ├── user.acl │ ├── minimal.conf │ └── default.conf ├── unit │ ├── printver.tcl │ ├── type │ │ └── list-common.tcl │ ├── limits.tcl │ ├── moduleapi │ │ ├── mallocsize.tcl │ │ ├── infra.tcl │ │ └── eventloop.tcl │ ├── cluster │ │ └── misc.tcl │ └── quit.tcl ├── helpers │ ├── bg_complex_data.tcl │ └── gen_write_load.tcl └── support │ └── tmpfile.tcl ├── deps ├── jemalloc │ ├── config.stamp.in │ ├── VERSION │ ├── test │ │ ├── unit │ │ │ ├── double_free.h │ │ │ ├── junk_alloc.c │ │ │ ├── junk_free.c │ │ │ ├── batch_alloc_prof.c │ │ │ ├── malloc_conf_2.sh │ │ │ ├── tcache_max.sh │ │ │ ├── zero_reallocs.sh │ │ │ ├── zero_realloc_abort.sh │ │ │ ├── zero_realloc_alloc.sh │ │ │ ├── zero_realloc_free.sh │ │ │ ├── san.sh │ │ │ ├── arena_reset_prof.sh │ │ │ ├── batch_alloc.sh │ │ │ ├── batch_alloc_prof.sh │ │ │ ├── binshard.sh │ │ │ ├── arena_decay.sh │ │ │ ├── inspect.sh │ │ │ ├── arena_reset_prof.c │ │ │ ├── size_check.sh │ │ │ ├── hpa_background_thread.sh │ │ │ ├── junk.sh │ │ │ ├── pack.sh │ │ │ ├── thread_event.sh │ │ │ ├── zero.sh │ │ │ ├── junk_alloc.sh │ │ │ ├── junk_free.sh │ │ │ ├── prof_mdump.sh │ │ │ ├── prof_thread_name.sh │ │ │ ├── prof_log.sh │ │ │ ├── prof_tctx.sh │ │ │ ├── prof_gdump.sh │ │ │ ├── prof_hook.sh │ │ │ ├── safety_check.sh │ │ │ ├── prof_stats.sh │ │ │ ├── prof_accum.sh │ │ │ ├── prof_recent.sh │ │ │ ├── prof_reset.sh │ │ │ ├── prof_active.sh │ │ │ ├── prof_sys_thread_name.sh │ │ │ ├── prof_idump.sh │ │ │ ├── a0.c │ │ │ ├── spin.c │ │ │ ├── zero_realloc_abort.c │ │ │ ├── div.c │ │ │ ├── malloc_conf_2.c │ │ │ ├── pages.c │ │ │ ├── zero_realloc_free.c │ │ │ ├── test_hooks.c │ │ │ └── thread_event.c │ │ ├── include │ │ │ └── test │ │ │ │ ├── sleep.h │ │ │ │ ├── thd.h │ │ │ │ ├── jemalloc_test_defs.h.in │ │ │ │ ├── timer.h │ │ │ │ ├── bgthd.h │ │ │ │ ├── san.h │ │ │ │ ├── mtx.h │ │ │ │ └── btalloc.h │ │ ├── src │ │ │ ├── math.c │ │ │ ├── btalloc_0.c │ │ │ ├── btalloc_1.c │ │ │ ├── btalloc.c │ │ │ ├── sleep.c │ │ │ └── thd.c │ │ ├── integration │ │ │ ├── extent.sh │ │ │ ├── mallocx.sh │ │ │ ├── xallocx.sh │ │ │ ├── smallocx.sh │ │ │ ├── slab_sizes.sh │ │ │ ├── cpp │ │ │ │ ├── infallible_new_false.sh │ │ │ │ ├── infallible_new_true.sh │ │ │ │ ├── basic.cpp │ │ │ │ └── infallible_new_false.cpp │ │ │ └── malloc.c │ │ └── stress │ │ │ └── large_microbench.c │ ├── .gitattributes │ ├── run_tests.sh │ ├── scripts │ │ ├── freebsd │ │ │ ├── script.sh │ │ │ ├── before_install.sh │ │ │ └── before_script.sh │ │ ├── windows │ │ │ ├── script.sh │ │ │ └── before_script.sh │ │ ├── linux │ │ │ └── before_install.sh │ │ └── check-formatting.sh │ ├── msvc │ │ ├── test_threads │ │ │ ├── test_threads.h │ │ │ └── test_threads_main.cpp │ │ └── ReadMe.txt │ ├── .autom4te.cfg │ ├── include │ │ ├── jemalloc │ │ │ ├── internal │ │ │ │ ├── private_namespace.sh │ │ │ │ ├── public_unnamespace.sh │ │ │ │ ├── public_namespace.sh │ │ │ │ ├── tsd_types.h │ │ │ │ ├── slab_data.h │ │ │ │ ├── extent_mmap.h │ │ │ │ ├── bin_types.h │ │ │ │ ├── hpa_hooks.h │ │ │ │ ├── prof_stats.h │ │ │ │ ├── prof_log.h │ │ │ │ ├── arena_inlines_a.h │ │ │ │ ├── spin.h │ │ │ │ ├── prof_hook.h │ │ │ │ ├── extent_dss.h │ │ │ │ ├── activity_callback.h │ │ │ │ └── peak_event.h │ │ │ ├── jemalloc_rename.sh │ │ │ └── jemalloc.sh │ │ └── msvc_compat │ │ │ ├── windows_extra.h │ │ │ └── C99 │ │ │ └── stdbool.h │ ├── bin │ │ └── jemalloc.sh.in │ ├── doc │ │ ├── manpages.xsl.in │ │ ├── html.xsl.in │ │ └── stylesheet.xsl │ ├── src │ │ ├── edata.c │ │ ├── exp_grow.c │ │ ├── test_hooks.c │ │ ├── ticker.py │ │ └── counter.c │ ├── autogen.sh │ └── jemalloc.pc.in ├── linenoise │ ├── .gitignore │ └── Makefile ├── lua │ ├── etc │ │ ├── lua.ico │ │ ├── lua.hpp │ │ ├── lua.pc │ │ ├── all.c │ │ └── min.c │ ├── doc │ │ ├── cover.png │ │ ├── logo.gif │ │ ├── manual.css │ │ └── readme.html │ ├── test │ │ ├── life.lua │ │ ├── echo.lua │ │ ├── hello.lua │ │ ├── printf.lua │ │ ├── env.lua │ │ ├── luac.lua │ │ ├── fibfor.lua │ │ ├── readonly.lua │ │ ├── table.lua │ │ ├── cf.lua │ │ ├── xd.lua │ │ ├── globals.lua │ │ ├── bisect.lua │ │ ├── fib.lua │ │ ├── factorial.lua │ │ ├── sieve.lua │ │ ├── trace-calls.lua │ │ └── trace-globals.lua │ └── src │ │ ├── lapi.h │ │ ├── fpconv.h │ │ ├── linit.c │ │ └── lstring.h ├── hiredis │ ├── .gitignore │ ├── fmacros.h │ ├── hiredis-config.cmake.in │ ├── hiredis_ssl.pc.in │ ├── hiredis.pc.in │ ├── hiredis_ssl-config.cmake.in │ ├── hiredis.targets │ ├── .github │ │ └── workflows │ │ │ └── release-drafter.yml │ ├── examples │ │ └── example-qt.h │ └── appveyor.yml ├── hdr_histogram │ ├── hdr_redis_malloc.h │ ├── Makefile │ └── hdr_tests.h └── fpconv │ ├── Makefile │ └── README.md ├── utils ├── hyperloglog │ ├── .gitignore │ └── hll-err.rb ├── req-res-validator │ └── requirements.txt ├── create-cluster │ └── .gitignore ├── releasetools │ ├── 01_create_tarball.sh │ ├── 04_release_hash.sh │ └── 03_test_release.sh ├── srandmember │ ├── showfreq.rb │ ├── README.md │ └── showdist.rb ├── build-static-symbols.tcl ├── graphs │ └── commits-over-time │ │ └── README.md ├── whatisdoing.sh ├── lru │ └── README └── generate-fmtargs.py ├── src ├── modules │ └── .gitignore ├── .gitignore ├── version.h ├── commands │ ├── module.json │ ├── pubsub.json │ ├── slowlog.json │ ├── cluster.json │ ├── function.json │ ├── xgroup.json │ ├── config.json │ ├── latency.json │ ├── memory.json │ ├── object.json │ ├── xinfo.json │ ├── script.json │ ├── acl.json │ ├── client.json │ ├── sentinel.json │ ├── sync.json │ ├── monitor.json │ ├── cluster-myid.json │ ├── asking.json │ ├── debug.json │ ├── cluster-flushslots.json │ ├── cluster-saveconfig.json │ ├── save.json │ ├── memory-purge.json │ ├── readonly.json │ ├── multi.json │ ├── pfselftest.json │ ├── readwrite.json │ ├── sentinel-myid.json │ ├── acl-load.json │ ├── memory-doctor.json │ ├── reset.json │ ├── unwatch.json │ ├── command.json │ ├── replconf.json │ ├── acl-whoami.json │ ├── bgrewriteaof.json │ ├── cluster-myshardid.json │ ├── discard.json │ ├── pubsub-numpat.json │ ├── slowlog-help.json │ ├── cluster-help.json │ ├── config-help.json │ ├── latency-help.json │ ├── memory-help.json │ ├── module-help.json │ ├── pubsub-help.json │ ├── function-dump.json │ ├── sentinel-flushconfig.json │ ├── sentinel-remove.json │ ├── cluster-nodes.json │ ├── command-count.json │ ├── psync.json │ ├── acl-help.json │ ├── cluster-forget.json │ ├── config-resetstat.json │ ├── client-id.json │ ├── module-unload.json │ ├── config-rewrite.json │ ├── cluster-replicate.json │ ├── client-unpause.json │ ├── select.json │ ├── slowlog-reset.json │ ├── memory-malloc-stats.json │ ├── cluster-set-config-epoch.json │ ├── cluster-info.json │ ├── function-kill.json │ ├── script-kill.json │ ├── sentinel-help.json │ ├── xinfo-help.json │ ├── object-help.json │ ├── xgroup-help.json │ ├── acl-users.json │ ├── script-help.json │ ├── function-help.json │ ├── subscribe.json │ ├── echo.json │ ├── psubscribe.json │ ├── dbsize.json │ ├── acl-save.json │ ├── cluster-countkeysinslot.json │ ├── client-help.json │ ├── unsubscribe.json │ ├── acl-list.json │ ├── cluster-keyslot.json │ ├── command-help.json │ ├── cluster-addslots.json │ ├── lolwut.json │ ├── cluster-delslots.json │ ├── lastsave.json │ ├── quit.json │ ├── sentinel-failover.json │ ├── punsubscribe.json │ ├── slowlog-len.json │ ├── latency-doctor.json │ ├── sentinel-reset.json │ ├── client-info.json │ ├── time.json │ ├── sentinel-masters.json │ ├── module-load.json │ ├── function-delete.json │ ├── sentinel-master.json │ ├── sentinel-ckquorum.json │ ├── swapdb.json │ ├── client-setname.json │ ├── latency-graph.json │ ├── cluster-count-failure-reports.json │ ├── client-getname.json │ ├── pubsub-numsub.json │ ├── latency-reset.json │ ├── sentinel-monitor.json │ ├── sentinel-sentinels.json │ └── script-load.json ├── crc64.h ├── geo.h ├── valgrind.sup ├── cli_commands.c ├── commands.c ├── sha1.h └── mkreleasehdr.sh ├── .codespell ├── requirements.txt ├── .codespellrc └── wordlist.txt ├── BUGS ├── .github ├── ISSUE_TEMPLATE │ ├── other_stuff.md │ ├── bug_report.md │ ├── crash_report.md │ └── feature_request.md ├── workflows │ ├── reply-schemas-linter.yml │ ├── codeql-analysis.yml │ └── spell-check.yml └── dependabot.yml ├── Makefile ├── runtest ├── runtest-cluster ├── runtest-sentinel ├── .gitattributes ├── 00-RELEASENOTES └── .gitignore /INSTALL: -------------------------------------------------------------------------------- 1 | See README 2 | -------------------------------------------------------------------------------- /tests/tmp/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /deps/jemalloc/config.stamp.in: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /deps/jemalloc/VERSION: -------------------------------------------------------------------------------- 1 | 5.3.0-0-g0 2 | -------------------------------------------------------------------------------- /utils/hyperloglog/.gitignore: -------------------------------------------------------------------------------- 1 | *.txt 2 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/double_free.h: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/modules/.gitignore: -------------------------------------------------------------------------------- 1 | *.so 2 | *.xo 3 | -------------------------------------------------------------------------------- /.codespell/requirements.txt: -------------------------------------------------------------------------------- 1 | codespell==2.2.5 2 | -------------------------------------------------------------------------------- /deps/jemalloc/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/junk_alloc.c: -------------------------------------------------------------------------------- 1 | #include "junk.c" 2 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/junk_free.c: -------------------------------------------------------------------------------- 1 | #include "junk.c" 2 | -------------------------------------------------------------------------------- /tests/cluster/tmp/.gitignore: -------------------------------------------------------------------------------- 1 | redis_* 2 | sentinel_* 3 | -------------------------------------------------------------------------------- /tests/sentinel/tmp/.gitignore: -------------------------------------------------------------------------------- 1 | redis_* 2 | sentinel_* 3 | -------------------------------------------------------------------------------- /BUGS: -------------------------------------------------------------------------------- 1 | Please check https://github.com/redis/redis/issues 2 | -------------------------------------------------------------------------------- /deps/jemalloc/test/include/test/sleep.h: -------------------------------------------------------------------------------- 1 | void sleep_ns(unsigned ns); 2 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/batch_alloc_prof.c: -------------------------------------------------------------------------------- 1 | #include "batch_alloc.c" 2 | -------------------------------------------------------------------------------- /deps/jemalloc/run_tests.sh: -------------------------------------------------------------------------------- 1 | $(dirname "$)")/scripts/gen_run_tests.py | bash 2 | -------------------------------------------------------------------------------- /deps/jemalloc/scripts/freebsd/script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/tcsh 2 | 3 | gmake check 4 | -------------------------------------------------------------------------------- /deps/linenoise/.gitignore: -------------------------------------------------------------------------------- 1 | linenoise_example 2 | *.dSYM 3 | history.txt 4 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.gcda 2 | *.gcno 3 | *.gcov 4 | redis.info 5 | lcov-html 6 | -------------------------------------------------------------------------------- /utils/req-res-validator/requirements.txt: -------------------------------------------------------------------------------- 1 | jsonschema==4.17.3 2 | redis==4.5.1 -------------------------------------------------------------------------------- /deps/jemalloc/test/src/math.c: -------------------------------------------------------------------------------- 1 | #define MATH_C_ 2 | #include "test/jemalloc_test.h" 3 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/malloc_conf_2.sh: -------------------------------------------------------------------------------- 1 | export MALLOC_CONF="dirty_decay_ms:500" 2 | -------------------------------------------------------------------------------- /deps/jemalloc/msvc/test_threads/test_threads.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int test_threads(); 4 | -------------------------------------------------------------------------------- /deps/lua/etc/lua.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanveerpot/redis/HEAD/deps/lua/etc/lua.ico -------------------------------------------------------------------------------- /deps/jemalloc/test/src/btalloc_0.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | btalloc_n_gen(0) 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/src/btalloc_1.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | btalloc_n_gen(1) 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/tcache_max.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="tcache_max:1024" 4 | -------------------------------------------------------------------------------- /deps/lua/doc/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanveerpot/redis/HEAD/deps/lua/doc/cover.png -------------------------------------------------------------------------------- /deps/lua/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanveerpot/redis/HEAD/deps/lua/doc/logo.gif -------------------------------------------------------------------------------- /deps/lua/test/life.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanveerpot/redis/HEAD/deps/lua/test/life.lua -------------------------------------------------------------------------------- /src/version.h: -------------------------------------------------------------------------------- 1 | #define REDIS_VERSION "255.255.255" 2 | #define REDIS_VERSION_NUM 0x00ffffff 3 | -------------------------------------------------------------------------------- /tests/assets/nodefaultuser.acl: -------------------------------------------------------------------------------- 1 | user alice on nopass ~* +@all 2 | user bob on nopass ~* &* +@all -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/zero_reallocs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="zero_realloc:free" 4 | -------------------------------------------------------------------------------- /tests/assets/userwithselectors.acl: -------------------------------------------------------------------------------- 1 | user alice on (+get ~rw*) 2 | user bob on (+set %W~w*) (+get %R~r*) -------------------------------------------------------------------------------- /deps/jemalloc/scripts/freebsd/before_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/tcsh 2 | 3 | su -m root -c 'pkg install -y git' 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/zero_realloc_abort.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="zero_realloc:abort" 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/zero_realloc_alloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="zero_realloc:alloc" 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/zero_realloc_free.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="zero_realloc:free" 4 | -------------------------------------------------------------------------------- /tests/assets/encodings.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanveerpot/redis/HEAD/tests/assets/encodings.rdb -------------------------------------------------------------------------------- /tests/assets/hash-zipmap.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanveerpot/redis/HEAD/tests/assets/hash-zipmap.rdb -------------------------------------------------------------------------------- /utils/create-cluster/.gitignore: -------------------------------------------------------------------------------- 1 | config.sh 2 | *.rdb 3 | *.aof 4 | *.conf 5 | *.log 6 | appendonlydir-* 7 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/san.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="san_guard_large:1,san_guard_small:1" 4 | -------------------------------------------------------------------------------- /tests/assets/hash-ziplist.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanveerpot/redis/HEAD/tests/assets/hash-ziplist.rdb -------------------------------------------------------------------------------- /tests/assets/rdb-preamble.aof: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanveerpot/redis/HEAD/tests/assets/rdb-preamble.aof -------------------------------------------------------------------------------- /tests/assets/scriptbackup.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanveerpot/redis/HEAD/tests/assets/scriptbackup.rdb -------------------------------------------------------------------------------- /tests/assets/zset-ziplist.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanveerpot/redis/HEAD/tests/assets/zset-ziplist.rdb -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/arena_reset_prof.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="prof:true,lg_prof_sample:0" 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/batch_alloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="tcache_gc_incr_bytes:2147483648" 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/batch_alloc_prof.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="prof:true,lg_prof_sample:14" 4 | -------------------------------------------------------------------------------- /tests/assets/corrupt_ziplist.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanveerpot/redis/HEAD/tests/assets/corrupt_ziplist.rdb -------------------------------------------------------------------------------- /tests/assets/list-quicklist.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanveerpot/redis/HEAD/tests/assets/list-quicklist.rdb -------------------------------------------------------------------------------- /deps/lua/test/echo.lua: -------------------------------------------------------------------------------- 1 | -- echo command line arguments 2 | 3 | for i=0,table.getn(arg) do 4 | print(i,arg[i]) 5 | end 6 | -------------------------------------------------------------------------------- /deps/lua/test/hello.lua: -------------------------------------------------------------------------------- 1 | -- the first program in every language 2 | 3 | io.write("Hello world, from ",_VERSION,"!\n") 4 | -------------------------------------------------------------------------------- /tests/assets/corrupt_empty_keys.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanveerpot/redis/HEAD/tests/assets/corrupt_empty_keys.rdb -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/binshard.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="narenas:1,bin_shards:1-160:16|129-512:4|256-256:8" 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/arena_decay.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="dirty_decay_ms:1000,muzzy_decay_ms:1000,tcache_max:1024" 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/inspect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:false" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/.autom4te.cfg: -------------------------------------------------------------------------------- 1 | begin-language: "Autoconf-without-aclocal-m4" 2 | args: --no-cache 3 | end-language: "Autoconf-without-aclocal-m4" 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/extent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/mallocx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/xallocx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/arena_reset_prof.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | #define ARENA_RESET_PROF_C_ 3 | 4 | #include "arena_reset.c" 5 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/size_check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:false" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/hiredis/.gitignore: -------------------------------------------------------------------------------- 1 | /hiredis-test 2 | /examples/hiredis-example* 3 | /*.o 4 | /*.so 5 | /*.dylib 6 | /*.a 7 | /*.pc 8 | *.dSYM 9 | tags 10 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/smallocx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /tests/assets/user.acl: -------------------------------------------------------------------------------- 1 | user alice on allcommands allkeys &* >alice 2 | user bob on -@all +@set +acl ~set* &* >bob 3 | user default on nopass ~* &* +@all 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/hpa_background_thread.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="hpa_dirty_mult:0,hpa_min_purge_interval_ms:50,hpa_sec_nshards:0" 4 | 5 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/junk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,zero:false,junk:true" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/pack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Immediately purge to minimize fragmentation. 4 | export MALLOC_CONF="dirty_decay_ms:0,muzzy_decay_ms:0" 5 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/thread_event.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/zero.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,junk:false,zero:true" 5 | fi 6 | -------------------------------------------------------------------------------- /tests/assets/minimal.conf: -------------------------------------------------------------------------------- 1 | # Minimal configuration for testing. 2 | always-show-logo yes 3 | daemonize no 4 | pidfile /var/run/redis.pid 5 | loglevel verbose 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/slab_sizes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Some screwy-looking slab sizes. 4 | export MALLOC_CONF="slab_sizes:1-4096:17|100-200:1|128-128:2" 5 | -------------------------------------------------------------------------------- /deps/jemalloc/test/src/btalloc.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | void * 4 | btalloc(size_t size, unsigned bits) { 5 | return btalloc_0(size, bits); 6 | } 7 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/junk_alloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,zero:false,junk:alloc" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/junk_free.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,zero:false,junk:free" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_mdump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,lg_prof_sample:0" 5 | fi 6 | 7 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_thread_name.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:false" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/private_namespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for symbol in `cat "$@"` ; do 4 | echo "#define ${symbol} JEMALLOC_N(${symbol})" 5 | done 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_log.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_tctx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /.codespell/.codespellrc: -------------------------------------------------------------------------------- 1 | [codespell] 2 | quiet-level = 2 3 | count = 4 | skip = ./deps,./src/crc16_slottable.h,tmp*,./.git,./lcov-html 5 | ignore-words = ./.codespell/wordlist.txt 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/other_stuff.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Other 3 | about: Can't find the right issue type? Use this one! 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_gdump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:false,prof_gdump:true" 5 | fi 6 | 7 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_hook.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0" 5 | fi 6 | 7 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/safety_check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_stats.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0,prof_stats:true" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/public_unnamespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for nm in `cat $1` ; do 4 | n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'` 5 | echo "#undef je_${n}" 6 | done 7 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_accum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_recent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0,prof_recent_alloc_max:3" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_reset.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:false,lg_prof_sample:0,prof_recent_alloc_max:0" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/include/msvc_compat/windows_extra.h: -------------------------------------------------------------------------------- 1 | #ifndef MSVC_COMPAT_WINDOWS_EXTRA_H 2 | #define MSVC_COMPAT_WINDOWS_EXTRA_H 3 | 4 | #include 5 | 6 | #endif /* MSVC_COMPAT_WINDOWS_EXTRA_H */ 7 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_active.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:true,prof_thread_active_init:false,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/public_namespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for nm in `cat $1` ; do 4 | n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'` 5 | echo "#define je_${n} JEMALLOC_N(${n})" 6 | done 7 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_sys_thread_name.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0,prof_sys_thread_name:true" 5 | fi 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Top level makefile, the real shit is at src/Makefile 2 | 3 | default: all 4 | 5 | .DEFAULT: 6 | cd src && $(MAKE) $@ 7 | 8 | install: 9 | cd src && $(MAKE) $@ 10 | 11 | .PHONY: install 12 | -------------------------------------------------------------------------------- /deps/lua/test/printf.lua: -------------------------------------------------------------------------------- 1 | -- an implementation of printf 2 | 3 | function printf(...) 4 | io.write(string.format(...)) 5 | end 6 | 7 | printf("Hello %s from %s on %s\n",os.getenv"USER" or "there",_VERSION,os.date()) 8 | -------------------------------------------------------------------------------- /deps/jemalloc/bin/jemalloc.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | 7 | @LD_PRELOAD_VAR@=${libdir}/libjemalloc.@SOREV@ 8 | export @LD_PRELOAD_VAR@ 9 | exec "$@" 10 | -------------------------------------------------------------------------------- /deps/lua/test/env.lua: -------------------------------------------------------------------------------- 1 | -- read environment variables as if they were global variables 2 | 3 | local f=function (t,i) return os.getenv(i) end 4 | setmetatable(getfenv(),{__index=f}) 5 | 6 | -- an example 7 | print(a,USER,PATH) 8 | -------------------------------------------------------------------------------- /.codespell/wordlist.txt: -------------------------------------------------------------------------------- 1 | ake 2 | bale 3 | fle 4 | fo 5 | gameboy 6 | mutli 7 | nd 8 | nees 9 | oll 10 | optin 11 | ot 12 | smove 13 | te 14 | tre 15 | cancelability 16 | ist 17 | statics 18 | filetest 19 | ro 20 | exat 21 | clen -------------------------------------------------------------------------------- /tests/unit/printver.tcl: -------------------------------------------------------------------------------- 1 | start_server {} { 2 | set i [r info] 3 | regexp {redis_version:(.*?)\r\n} $i - version 4 | regexp {redis_git_sha1:(.*?)\r\n} $i - sha1 5 | puts "Testing Redis version $version ($sha1)" 6 | } 7 | -------------------------------------------------------------------------------- /tests/unit/type/list-common.tcl: -------------------------------------------------------------------------------- 1 | # We need a value to make sure the list has the right encoding when it is inserted. 2 | array set largevalue {} 3 | set largevalue(listpack) "hello" 4 | set largevalue(quicklist) [string repeat "x" 8192] 5 | -------------------------------------------------------------------------------- /deps/jemalloc/doc/manpages.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /deps/lua/etc/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/cpp/infallible_new_false.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | XMALLOC_STR="" 4 | if [ "x${enable_xmalloc}" = "x1" ] ; then 5 | XMALLOC_STR="xmalloc:false," 6 | fi 7 | 8 | export MALLOC_CONF="${XMALLOC_STR}experimental_infallible_new:false" 9 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/cpp/infallible_new_true.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | XMALLOC_STR="" 4 | if [ "x${enable_xmalloc}" = "x1" ] ; then 5 | XMALLOC_STR="xmalloc:false," 6 | fi 7 | 8 | export MALLOC_CONF="${XMALLOC_STR}experimental_infallible_new:true" 9 | -------------------------------------------------------------------------------- /src/commands/module.json: -------------------------------------------------------------------------------- 1 | { 2 | "MODULE": { 3 | "summary": "A container for module commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "server", 6 | "since": "4.0.0", 7 | "arity": -2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/commands/pubsub.json: -------------------------------------------------------------------------------- 1 | { 2 | "PUBSUB": { 3 | "summary": "A container for Pub/Sub commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "pubsub", 6 | "since": "2.8.0", 7 | "arity": -2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/sentinel/tests/04-slave-selection.tcl: -------------------------------------------------------------------------------- 1 | # Test slave selection algorithm. 2 | # 3 | # This unit should test: 4 | # 1) That when there are no suitable slaves no failover is performed. 5 | # 2) That among the available slaves, the one with better offset is picked. 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_idump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="tcache:false" 4 | if [ "x${enable_prof}" = "x1" ] ; then 5 | export MALLOC_CONF="${MALLOC_CONF},prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0,lg_prof_interval:0" 6 | fi 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/commands/slowlog.json: -------------------------------------------------------------------------------- 1 | { 2 | "SLOWLOG": { 3 | "summary": "A container for slow log commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "server", 6 | "since": "2.2.12", 7 | "arity": -2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /deps/jemalloc/scripts/windows/script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then 6 | echo "Incorrect \$TRAVIS_OS_NAME: expected windows, got $TRAVIS_OS_NAME" 7 | exit 1 8 | fi 9 | 10 | $build_env mingw32-make -k check 11 | -------------------------------------------------------------------------------- /deps/jemalloc/src/edata.c: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_preamble.h" 2 | #include "jemalloc/internal/jemalloc_internal_includes.h" 3 | 4 | ph_gen(, edata_avail, edata_t, avail_link, 5 | edata_esnead_comp) 6 | ph_gen(, edata_heap, edata_t, heap_link, edata_snad_comp) 7 | -------------------------------------------------------------------------------- /src/commands/cluster.json: -------------------------------------------------------------------------------- 1 | { 2 | "CLUSTER": { 3 | "summary": "A container for Redis Cluster commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "cluster", 6 | "since": "3.0.0", 7 | "arity": -2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/commands/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "FUNCTION": { 3 | "summary": "A container for function commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "scripting", 6 | "since": "7.0.0", 7 | "arity": -2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/commands/xgroup.json: -------------------------------------------------------------------------------- 1 | { 2 | "XGROUP": { 3 | "summary": "A container for consumer groups commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "stream", 6 | "since": "5.0.0", 7 | "arity": -2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /deps/lua/test/luac.lua: -------------------------------------------------------------------------------- 1 | -- bare-bones luac in Lua 2 | -- usage: lua luac.lua file.lua 3 | 4 | assert(arg[1]~=nil and arg[2]==nil,"usage: lua luac.lua file.lua") 5 | f=assert(io.open("luac.out","wb")) 6 | assert(f:write(string.dump(assert(loadfile(arg[1]))))) 7 | assert(f:close()) 8 | -------------------------------------------------------------------------------- /src/commands/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "CONFIG": { 3 | "summary": "A container for server configuration commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "server", 6 | "since": "2.0.0", 7 | "arity": -2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/commands/latency.json: -------------------------------------------------------------------------------- 1 | { 2 | "LATENCY": { 3 | "summary": "A container for latency diagnostics commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "server", 6 | "since": "2.8.13", 7 | "arity": -2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/commands/memory.json: -------------------------------------------------------------------------------- 1 | { 2 | "MEMORY": { 3 | "summary": "A container for memory diagnostics commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "server", 6 | "since": "4.0.0", 7 | "arity": -2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/commands/object.json: -------------------------------------------------------------------------------- 1 | { 2 | "OBJECT": { 3 | "summary": "A container for object introspection commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "generic", 6 | "since": "2.2.3", 7 | "arity": -2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/commands/xinfo.json: -------------------------------------------------------------------------------- 1 | { 2 | "XINFO": { 3 | "summary": "A container for stream introspection commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "stream", 6 | "since": "5.0.0", 7 | "arity": -2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/commands/script.json: -------------------------------------------------------------------------------- 1 | { 2 | "SCRIPT": { 3 | "summary": "A container for Lua scripts management commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "scripting", 6 | "since": "2.6.0", 7 | "arity": -2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /deps/jemalloc/doc/html.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /deps/jemalloc/src/exp_grow.c: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_preamble.h" 2 | #include "jemalloc/internal/jemalloc_internal_includes.h" 3 | 4 | void 5 | exp_grow_init(exp_grow_t *exp_grow) { 6 | exp_grow->next = sz_psz2ind(HUGEPAGE); 7 | exp_grow->limit = sz_psz2ind(SC_LARGE_MAXCLASS); 8 | } 9 | -------------------------------------------------------------------------------- /deps/jemalloc/test/include/test/thd.h: -------------------------------------------------------------------------------- 1 | /* Abstraction layer for threading in tests. */ 2 | #ifdef _WIN32 3 | typedef HANDLE thd_t; 4 | #else 5 | typedef pthread_t thd_t; 6 | #endif 7 | 8 | void thd_create(thd_t *thd, void *(*proc)(void *), void *arg); 9 | void thd_join(thd_t thd, void **ret); 10 | -------------------------------------------------------------------------------- /src/crc64.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC64_H 2 | #define CRC64_H 3 | 4 | #include 5 | 6 | void crc64_init(void); 7 | uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l); 8 | 9 | #ifdef REDIS_TEST 10 | int crc64Test(int argc, char *argv[], int flags); 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /deps/jemalloc/msvc/test_threads/test_threads_main.cpp: -------------------------------------------------------------------------------- 1 | #include "test_threads.h" 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std::chrono_literals; 7 | 8 | int main(int argc, char** argv) { 9 | int rc = test_threads(); 10 | return rc; 11 | } 12 | -------------------------------------------------------------------------------- /deps/hiredis/fmacros.h: -------------------------------------------------------------------------------- 1 | #ifndef __HIREDIS_FMACRO_H 2 | #define __HIREDIS_FMACRO_H 3 | 4 | #ifndef _AIX 5 | #define _XOPEN_SOURCE 600 6 | #define _POSIX_C_SOURCE 200112L 7 | #endif 8 | 9 | #if defined(__APPLE__) && defined(__MACH__) 10 | /* Enable TCP_KEEPALIVE */ 11 | #define _DARWIN_C_SOURCE 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/a0.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_a0) { 4 | void *p; 5 | 6 | p = a0malloc(1); 7 | expect_ptr_not_null(p, "Unexpected a0malloc() error"); 8 | a0dalloc(p); 9 | } 10 | TEST_END 11 | 12 | int 13 | main(void) { 14 | return test_no_malloc_init( 15 | test_a0); 16 | } 17 | -------------------------------------------------------------------------------- /deps/lua/test/fibfor.lua: -------------------------------------------------------------------------------- 1 | -- example of for with generator functions 2 | 3 | function generatefib (n) 4 | return coroutine.wrap(function () 5 | local a,b = 1, 1 6 | while a <= n do 7 | coroutine.yield(a) 8 | a, b = b, a+b 9 | end 10 | end) 11 | end 12 | 13 | for i in generatefib(1000) do print(i) end 14 | -------------------------------------------------------------------------------- /deps/lua/test/readonly.lua: -------------------------------------------------------------------------------- 1 | -- make global variables readonly 2 | 3 | local f=function (t,i) error("cannot redefine global variable `"..i.."'",2) end 4 | local g={} 5 | local G=getfenv() 6 | setmetatable(g,{__index=G,__newindex=f}) 7 | setfenv(1,g) 8 | 9 | -- an example 10 | rawset(g,"x",3) 11 | x=2 12 | y=1 -- cannot redefine `y' 13 | -------------------------------------------------------------------------------- /runtest: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6 8.7" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis test" 12 | exit 1 13 | fi 14 | $TCLSH tests/test_helper.tcl "${@}" 15 | -------------------------------------------------------------------------------- /src/commands/acl.json: -------------------------------------------------------------------------------- 1 | { 2 | "ACL": { 3 | "summary": "A container for Access List Control commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "server", 6 | "since": "6.0.0", 7 | "arity": -2, 8 | "command_flags": [ 9 | "SENTINEL" 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/tsd_types.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_TSD_TYPES_H 2 | #define JEMALLOC_INTERNAL_TSD_TYPES_H 3 | 4 | #define MALLOC_TSD_CLEANUPS_MAX 4 5 | 6 | typedef struct tsd_s tsd_t; 7 | typedef struct tsdn_s tsdn_t; 8 | typedef bool (*malloc_tsd_cleanup_t)(void); 9 | 10 | #endif /* JEMALLOC_INTERNAL_TSD_TYPES_H */ 11 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/malloc.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_zero_alloc) { 4 | void *res = malloc(0); 5 | assert(res); 6 | size_t usable = TEST_MALLOC_SIZE(res); 7 | assert(usable > 0); 8 | free(res); 9 | } 10 | TEST_END 11 | 12 | int 13 | main(void) { 14 | return test( 15 | test_zero_alloc); 16 | } 17 | -------------------------------------------------------------------------------- /deps/lua/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/commands/client.json: -------------------------------------------------------------------------------- 1 | { 2 | "CLIENT": { 3 | "summary": "A container for client connection commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "connection", 6 | "since": "2.4.0", 7 | "arity": -2, 8 | "command_flags": [ 9 | "SENTINEL" 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /deps/lua/test/table.lua: -------------------------------------------------------------------------------- 1 | -- make table, grouping all data for the same item 2 | -- input is 2 columns (item, data) 3 | 4 | local A 5 | while 1 do 6 | local l=io.read() 7 | if l==nil then break end 8 | local _,_,a,b=string.find(l,'"?([_%w]+)"?%s*(.*)$') 9 | if a~=A then A=a io.write("\n",a,":") end 10 | io.write(" ",b) 11 | end 12 | io.write("\n") 13 | -------------------------------------------------------------------------------- /runtest-cluster: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6 8.7" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis Cluster test" 12 | exit 1 13 | fi 14 | $TCLSH tests/cluster/run.tcl $* 15 | -------------------------------------------------------------------------------- /runtest-sentinel: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6 8.7" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis Sentinel test" 12 | exit 1 13 | fi 14 | $TCLSH tests/sentinel/run.tcl $* 15 | -------------------------------------------------------------------------------- /deps/jemalloc/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for i in autoconf; do 4 | echo "$i" 5 | $i 6 | if [ $? -ne 0 ]; then 7 | echo "Error $? in $i" 8 | exit 1 9 | fi 10 | done 11 | 12 | echo "./configure --enable-autogen $@" 13 | ./configure --enable-autogen $@ 14 | if [ $? -ne 0 ]; then 15 | echo "Error $? in ./configure" 16 | exit 1 17 | fi 18 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/spin.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #include "jemalloc/internal/spin.h" 4 | 5 | TEST_BEGIN(test_spin) { 6 | spin_t spinner = SPIN_INITIALIZER; 7 | 8 | for (unsigned i = 0; i < 100; i++) { 9 | spin_adaptive(&spinner); 10 | } 11 | } 12 | TEST_END 13 | 14 | int 15 | main(void) { 16 | return test( 17 | test_spin); 18 | } 19 | -------------------------------------------------------------------------------- /deps/jemalloc/test/include/test/jemalloc_test_defs.h.in: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_internal_defs.h" 2 | #include "jemalloc/internal/jemalloc_internal_decls.h" 3 | 4 | /* 5 | * For use by SFMT. configure.ac doesn't actually define HAVE_SSE2 because its 6 | * dependencies are notoriously unportable in practice. 7 | */ 8 | #undef HAVE_SSE2 9 | #undef HAVE_ALTIVEC 10 | -------------------------------------------------------------------------------- /deps/jemalloc/scripts/linux/before_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ev 4 | 5 | if [[ "$TRAVIS_OS_NAME" != "linux" ]]; then 6 | echo "Incorrect \$TRAVIS_OS_NAME: expected linux, got $TRAVIS_OS_NAME" 7 | exit 1 8 | fi 9 | 10 | if [[ "$CROSS_COMPILE_32BIT" == "yes" ]]; then 11 | sudo apt-get update 12 | sudo apt-get -y install gcc-multilib g++-multilib 13 | fi 14 | -------------------------------------------------------------------------------- /deps/lua/test/cf.lua: -------------------------------------------------------------------------------- 1 | -- temperature conversion table (celsius to farenheit) 2 | 3 | for c0=-20,50-1,10 do 4 | io.write("C ") 5 | for c=c0,c0+10-1 do 6 | io.write(string.format("%3.0f ",c)) 7 | end 8 | io.write("\n") 9 | 10 | io.write("F ") 11 | for c=c0,c0+10-1 do 12 | f=(9/5)*c+32 13 | io.write(string.format("%3.0f ",f)) 14 | end 15 | io.write("\n\n") 16 | end 17 | -------------------------------------------------------------------------------- /deps/hdr_histogram/hdr_redis_malloc.h: -------------------------------------------------------------------------------- 1 | #ifndef HDR_MALLOC_H__ 2 | #define HDR_MALLOC_H__ 3 | 4 | void *zmalloc(size_t size); 5 | void *zcalloc_num(size_t num, size_t size); 6 | void *zrealloc(void *ptr, size_t size); 7 | void zfree(void *ptr); 8 | 9 | #define hdr_malloc zmalloc 10 | #define hdr_calloc zcalloc_num 11 | #define hdr_realloc zrealloc 12 | #define hdr_free zfree 13 | #endif 14 | -------------------------------------------------------------------------------- /deps/jemalloc/test/include/test/timer.h: -------------------------------------------------------------------------------- 1 | /* Simple timer, for use in benchmark reporting. */ 2 | 3 | typedef struct { 4 | nstime_t t0; 5 | nstime_t t1; 6 | } timedelta_t; 7 | 8 | void timer_start(timedelta_t *timer); 9 | void timer_stop(timedelta_t *timer); 10 | uint64_t timer_usec(const timedelta_t *timer); 11 | void timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen); 12 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/slab_data.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_SLAB_DATA_H 2 | #define JEMALLOC_INTERNAL_SLAB_DATA_H 3 | 4 | #include "jemalloc/internal/bitmap.h" 5 | 6 | typedef struct slab_data_s slab_data_t; 7 | struct slab_data_s { 8 | /* Per region allocated/deallocated bitmap. */ 9 | bitmap_t bitmap[BITMAP_GROUPS_MAX]; 10 | }; 11 | 12 | #endif /* JEMALLOC_INTERNAL_SLAB_DATA_H */ 13 | -------------------------------------------------------------------------------- /src/commands/sentinel.json: -------------------------------------------------------------------------------- 1 | { 2 | "SENTINEL": { 3 | "summary": "A container for Redis Sentinel commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "sentinel", 6 | "since": "2.8.4", 7 | "arity": -2, 8 | "command_flags": [ 9 | "ADMIN", 10 | "SENTINEL", 11 | "ONLY_SENTINEL" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/sentinel/tests/includes/sentinel.conf: -------------------------------------------------------------------------------- 1 | # assume master is down after being unresponsive for 20s 2 | sentinel down-after-milliseconds setmaster 20000 3 | # reconfigure one slave at a time 4 | sentinel parallel-syncs setmaster 2 5 | # wait for 4m before assuming failover went wrong 6 | sentinel failover-timeout setmaster 240000 7 | # monitoring set 8 | sentinel monitor setmaster 10.0.0.1 30000 2 9 | 10 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/extent_mmap.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_EXTENT_MMAP_EXTERNS_H 2 | #define JEMALLOC_INTERNAL_EXTENT_MMAP_EXTERNS_H 3 | 4 | extern bool opt_retain; 5 | 6 | void *extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, 7 | bool *zero, bool *commit); 8 | bool extent_dalloc_mmap(void *addr, size_t size); 9 | 10 | #endif /* JEMALLOC_INTERNAL_EXTENT_MMAP_EXTERNS_H */ 11 | -------------------------------------------------------------------------------- /src/commands/sync.json: -------------------------------------------------------------------------------- 1 | { 2 | "SYNC": { 3 | "summary": "An internal command used in replication.", 4 | "group": "server", 5 | "since": "1.0.0", 6 | "arity": 1, 7 | "function": "syncCommand", 8 | "command_flags": [ 9 | "NO_ASYNC_LOADING", 10 | "ADMIN", 11 | "NO_MULTI", 12 | "NOSCRIPT" 13 | ] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /deps/hiredis/hiredis-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | set_and_check(hiredis_INCLUDEDIR "@PACKAGE_INCLUDE_INSTALL_DIR@") 4 | 5 | IF (NOT TARGET hiredis::@hiredis_export_name@) 6 | INCLUDE(${CMAKE_CURRENT_LIST_DIR}/hiredis-targets.cmake) 7 | ENDIF() 8 | 9 | SET(hiredis_LIBRARIES hiredis::@hiredis_export_name@) 10 | SET(hiredis_INCLUDE_DIRS ${hiredis_INCLUDEDIR}) 11 | 12 | check_required_components(hiredis) 13 | 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # We set commands.c's merge driver to `binary` so when it conflicts during a 2 | # merge git will leave the local version unmodified. This way our Makefile 3 | # will rebuild it based on src/commands/*.json before trying to compile it. 4 | # Otherwise the file gets modified and gets the same timestamp as the .json 5 | # files. So the Makefile doesn't attempt to rebuild it before compiling. 6 | src/commands.c merge=binary 7 | -------------------------------------------------------------------------------- /utils/releasetools/01_create_tarball.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ $# != "1" ] 3 | then 4 | echo "Usage: ./utils/releasetools/01_create_tarball.sh " 5 | exit 1 6 | fi 7 | 8 | TAG=$1 9 | TARNAME="redis-${TAG}.tar" 10 | echo "Generating /tmp/${TARNAME}" 11 | git archive $TAG --prefix redis-${TAG}/ > /tmp/$TARNAME || exit 1 12 | echo "Gizipping the archive" 13 | rm -f /tmp/$TARNAME.gz 14 | gzip -9 /tmp/$TARNAME 15 | -------------------------------------------------------------------------------- /deps/linenoise/Makefile: -------------------------------------------------------------------------------- 1 | STD= 2 | WARN= -Wall 3 | OPT= -Os 4 | 5 | R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) 6 | R_LDFLAGS= $(LDFLAGS) 7 | DEBUG= -g 8 | 9 | R_CC=$(CC) $(R_CFLAGS) 10 | R_LD=$(CC) $(R_LDFLAGS) 11 | 12 | linenoise.o: linenoise.h linenoise.c 13 | 14 | linenoise_example: linenoise.o example.o 15 | $(R_LD) -o $@ $^ 16 | 17 | .c.o: 18 | $(R_CC) -c $< 19 | 20 | clean: 21 | rm -f linenoise_example *.o 22 | -------------------------------------------------------------------------------- /deps/hiredis/hiredis_ssl.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | install_libdir=@CMAKE_INSTALL_LIBDIR@ 3 | exec_prefix=${prefix} 4 | libdir=${exec_prefix}/${install_libdir} 5 | includedir=${prefix}/include 6 | pkgincludedir=${includedir}/hiredis 7 | 8 | Name: hiredis_ssl 9 | Description: SSL Support for hiredis. 10 | Version: @PROJECT_VERSION@ 11 | Requires: hiredis 12 | Libs: -L${libdir} -lhiredis_ssl 13 | Libs.private: -lssl -lcrypto 14 | -------------------------------------------------------------------------------- /deps/lua/test/xd.lua: -------------------------------------------------------------------------------- 1 | -- hex dump 2 | -- usage: lua xd.lua < file 3 | 4 | local offset=0 5 | while true do 6 | local s=io.read(16) 7 | if s==nil then return end 8 | io.write(string.format("%08X ",offset)) 9 | string.gsub(s,"(.)", 10 | function (c) io.write(string.format("%02X ",string.byte(c))) end) 11 | io.write(string.rep(" ",3*(16-string.len(s)))) 12 | io.write(" ",string.gsub(s,"%c","."),"\n") 13 | offset=offset+16 14 | end 15 | -------------------------------------------------------------------------------- /tests/helpers/bg_complex_data.tcl: -------------------------------------------------------------------------------- 1 | source tests/support/redis.tcl 2 | source tests/support/util.tcl 3 | 4 | set ::tlsdir "tests/tls" 5 | 6 | proc bg_complex_data {host port db ops tls} { 7 | set r [redis $host $port 0 $tls] 8 | $r client setname LOAD_HANDLER 9 | $r select $db 10 | createComplexDataset $r $ops 11 | } 12 | 13 | bg_complex_data [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] [lindex $argv 4] 14 | -------------------------------------------------------------------------------- /deps/hiredis/hiredis.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | install_libdir=@CMAKE_INSTALL_LIBDIR@ 3 | exec_prefix=${prefix} 4 | libdir=${exec_prefix}/${install_libdir} 5 | includedir=${prefix}/include 6 | pkgincludedir=${includedir}/hiredis 7 | 8 | Name: hiredis 9 | Description: Minimalistic C client library for Redis. 10 | Version: @PROJECT_VERSION@ 11 | Libs: -L${libdir} -lhiredis 12 | Cflags: -I${pkgincludedir} -I${includedir} -D_FILE_OFFSET_BITS=64 13 | -------------------------------------------------------------------------------- /src/commands/monitor.json: -------------------------------------------------------------------------------- 1 | { 2 | "MONITOR": { 3 | "summary": "Listens for all requests received by the server in real-time.", 4 | "group": "server", 5 | "since": "1.0.0", 6 | "arity": 1, 7 | "function": "monitorCommand", 8 | "history": [], 9 | "command_flags": [ 10 | "ADMIN", 11 | "NOSCRIPT", 12 | "LOADING", 13 | "STALE" 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/sentinel/tests/14-debug-command.tcl: -------------------------------------------------------------------------------- 1 | source "../tests/includes/init-tests.tcl" 2 | 3 | test "Sentinel debug test with arguments and without argument" { 4 | set current_info_period [lindex [S 0 SENTINEL DEBUG] 1] 5 | S 0 SENTINEL DEBUG info-period 8888 6 | assert_equal {8888} [lindex [S 0 SENTINEL DEBUG] 1] 7 | S 0 SENTINEL DEBUG info-period $current_info_period 8 | assert_equal $current_info_period [lindex [S 0 SENTINEL DEBUG] 1] 9 | } 10 | -------------------------------------------------------------------------------- /deps/fpconv/Makefile: -------------------------------------------------------------------------------- 1 | STD= 2 | WARN= -Wall 3 | OPT= -Os 4 | 5 | R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) 6 | R_LDFLAGS= $(LDFLAGS) 7 | DEBUG= -g 8 | 9 | R_CC=$(CC) $(R_CFLAGS) 10 | R_LD=$(CC) $(R_LDFLAGS) 11 | 12 | AR= ar 13 | ARFLAGS= rcs 14 | 15 | libfpconv.a: fpconv_dtoa.o 16 | $(AR) $(ARFLAGS) $@ $+ 17 | 18 | fpconv_dtoa.o: fpconv_dtoa.h fpconv_dtoa.c 19 | 20 | .c.o: 21 | $(R_CC) -c $< 22 | 23 | clean: 24 | rm -f *.o 25 | rm -f *.a 26 | 27 | 28 | -------------------------------------------------------------------------------- /deps/jemalloc/scripts/freebsd/before_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/tcsh 2 | 3 | autoconf 4 | # We don't perfectly track freebsd stdlib.h definitions. This is fine when 5 | # we count as a system header, but breaks otherwise, like during these 6 | # tests. 7 | ./configure --with-jemalloc-prefix=ci_ ${COMPILER_FLAGS:+ CC="$CC $COMPILER_FLAGS" CXX="$CXX $COMPILER_FLAGS"} $CONFIGURE_FLAGS 8 | JE_NCPUS=`sysctl -n kern.smp.cpus` 9 | gmake -j${JE_NCPUS} 10 | gmake -j${JE_NCPUS} tests 11 | -------------------------------------------------------------------------------- /deps/lua/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | float: right ; 12 | font-family: inherit ; 13 | font-style: normal ; 14 | font-size: small ; 15 | color: gray ; 16 | } 17 | 18 | p+h1, ul+h1 { 19 | padding-top: 0.4em ; 20 | padding-bottom: 0.4em ; 21 | padding-left: 30px ; 22 | margin-left: -30px ; 23 | background-color: #E0E0FF ; 24 | } 25 | -------------------------------------------------------------------------------- /deps/jemalloc/doc/stylesheet.xsl: -------------------------------------------------------------------------------- 1 | 2 | ansi 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /deps/jemalloc/src/test_hooks.c: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_preamble.h" 2 | 3 | /* 4 | * The hooks are a little bit screwy -- they're not genuinely exported in the 5 | * sense that we want them available to end-users, but we do want them visible 6 | * from outside the generated library, so that we can use them in test code. 7 | */ 8 | JEMALLOC_EXPORT 9 | void (*test_hooks_arena_new_hook)() = NULL; 10 | 11 | JEMALLOC_EXPORT 12 | void (*test_hooks_libc_hook)() = NULL; 13 | -------------------------------------------------------------------------------- /deps/jemalloc/src/ticker.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import math 4 | 5 | # Must match TICKER_GEOM_NBITS 6 | lg_table_size = 6 7 | table_size = 2**lg_table_size 8 | byte_max = 255 9 | mul = math.floor(-byte_max/math.log(1 / table_size)) 10 | values = [round(-mul * math.log(i / table_size)) 11 | for i in range(1, table_size+1)] 12 | print("mul =", mul) 13 | print("values:") 14 | for i in range(table_size // 8): 15 | print(", ".join((str(x) for x in values[i*8 : i*8 + 8]))) 16 | -------------------------------------------------------------------------------- /tests/support/tmpfile.tcl: -------------------------------------------------------------------------------- 1 | set ::tmpcounter 0 2 | set ::tmproot "./tests/tmp" 3 | file mkdir $::tmproot 4 | 5 | # returns a dirname unique to this process to write to 6 | proc tmpdir {basename} { 7 | set dir [file join $::tmproot $basename.[pid].[incr ::tmpcounter]] 8 | file mkdir $dir 9 | set _ $dir 10 | } 11 | 12 | # return a filename unique to this process to write to 13 | proc tmpfile {basename} { 14 | file join $::tmproot $basename.[pid].[incr ::tmpcounter] 15 | } 16 | -------------------------------------------------------------------------------- /deps/lua/test/globals.lua: -------------------------------------------------------------------------------- 1 | -- reads luac listings and reports global variable usage 2 | -- lines where a global is written to are marked with "*" 3 | -- typical usage: luac -p -l file.lua | lua globals.lua | sort | lua table.lua 4 | 5 | while 1 do 6 | local s=io.read() 7 | if s==nil then break end 8 | local ok,_,l,op,g=string.find(s,"%[%-?(%d*)%]%s*([GS])ETGLOBAL.-;%s+(.*)$") 9 | if ok then 10 | if op=="S" then op="*" else op="" end 11 | io.write(g,"\t",l,op,"\n") 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /deps/fpconv/README.md: -------------------------------------------------------------------------------- 1 | libfpconv 2 | 3 | ---------------------------------------------- 4 | 5 | Fast and accurate double to string conversion based on Florian Loitsch's Grisu-algorithm[1]. 6 | 7 | This port contains a subset of the 'C' version of Fast and accurate double to string conversion based on Florian Loitsch's Grisu-algorithm available at [github.com/night-shift/fpconv](https://github.com/night-shift/fpconv)). 8 | 9 | [1] https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf 10 | -------------------------------------------------------------------------------- /deps/hiredis/hiredis_ssl-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | set_and_check(hiredis_ssl_INCLUDEDIR "@PACKAGE_INCLUDE_INSTALL_DIR@") 4 | 5 | include(CMakeFindDependencyMacro) 6 | find_dependency(OpenSSL) 7 | 8 | IF (NOT TARGET hiredis::hiredis_ssl) 9 | INCLUDE(${CMAKE_CURRENT_LIST_DIR}/hiredis_ssl-targets.cmake) 10 | ENDIF() 11 | 12 | SET(hiredis_ssl_LIBRARIES hiredis::hiredis_ssl) 13 | SET(hiredis_ssl_INCLUDE_DIRS ${hiredis_ssl_INCLUDEDIR}) 14 | 15 | check_required_components(hiredis_ssl) 16 | 17 | -------------------------------------------------------------------------------- /src/geo.h: -------------------------------------------------------------------------------- 1 | #ifndef __GEO_H__ 2 | #define __GEO_H__ 3 | 4 | #include "server.h" 5 | 6 | /* Structures used inside geo.c in order to represent points and array of 7 | * points on the earth. */ 8 | typedef struct geoPoint { 9 | double longitude; 10 | double latitude; 11 | double dist; 12 | double score; 13 | char *member; 14 | } geoPoint; 15 | 16 | typedef struct geoArray { 17 | struct geoPoint *array; 18 | size_t buckets; 19 | size_t used; 20 | } geoArray; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/commands/cluster-myid.json: -------------------------------------------------------------------------------- 1 | { 2 | "MYID": { 3 | "summary": "Returns the ID of a node.", 4 | "complexity": "O(1)", 5 | "group": "cluster", 6 | "since": "3.0.0", 7 | "arity": 2, 8 | "container": "CLUSTER", 9 | "function": "clusterCommand", 10 | "command_flags": [ 11 | "STALE" 12 | ], 13 | "reply_schema": { 14 | "description": "the node id", 15 | "type": "string" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/valgrind.sup: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Cond 4 | fun:lzf_compress 5 | } 6 | 7 | { 8 | 9 | Memcheck:Value4 10 | fun:lzf_compress 11 | } 12 | 13 | { 14 | 15 | Memcheck:Value8 16 | fun:lzf_compress 17 | } 18 | 19 | { 20 | 21 | Memcheck:FishyValue 22 | malloc(size) 23 | fun:malloc 24 | fun:ztrymalloc_usable 25 | fun:ztrymalloc 26 | } 27 | -------------------------------------------------------------------------------- /deps/jemalloc/test/include/test/bgthd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Shared utility for checking if background_thread is enabled, which affects 3 | * the purging behavior and assumptions in some tests. 4 | */ 5 | 6 | static inline bool 7 | is_background_thread_enabled(void) { 8 | bool enabled; 9 | size_t sz = sizeof(bool); 10 | int ret = mallctl("background_thread", (void *)&enabled, &sz, NULL,0); 11 | if (ret == ENOENT) { 12 | return false; 13 | } 14 | assert_d_eq(ret, 0, "Unexpected mallctl error"); 15 | 16 | return enabled; 17 | } 18 | -------------------------------------------------------------------------------- /deps/jemalloc/test/include/test/san.h: -------------------------------------------------------------------------------- 1 | #if defined(JEMALLOC_UAF_DETECTION) || defined(JEMALLOC_DEBUG) 2 | # define TEST_SAN_UAF_ALIGN_ENABLE "lg_san_uaf_align:12" 3 | # define TEST_SAN_UAF_ALIGN_DISABLE "lg_san_uaf_align:-1" 4 | #else 5 | # define TEST_SAN_UAF_ALIGN_ENABLE "" 6 | # define TEST_SAN_UAF_ALIGN_DISABLE "" 7 | #endif 8 | 9 | static inline bool 10 | extent_is_guarded(tsdn_t *tsdn, void *ptr) { 11 | edata_t *edata = emap_edata_lookup(tsdn, &arena_emap_global, ptr); 12 | return edata_guarded_get(edata); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /src/commands/asking.json: -------------------------------------------------------------------------------- 1 | { 2 | "ASKING": { 3 | "summary": "Signals that a cluster client is following an -ASK redirect.", 4 | "complexity": "O(1)", 5 | "group": "cluster", 6 | "since": "3.0.0", 7 | "arity": 1, 8 | "function": "askingCommand", 9 | "command_flags": [ 10 | "FAST" 11 | ], 12 | "acl_categories": [ 13 | "CONNECTION" 14 | ], 15 | "reply_schema": { 16 | "const": "OK" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /deps/jemalloc/jemalloc.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | install_suffix=@install_suffix@ 6 | 7 | Name: jemalloc 8 | Description: A general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support. 9 | URL: http://jemalloc.net/ 10 | Version: @jemalloc_version_major@.@jemalloc_version_minor@.@jemalloc_version_bugfix@_@jemalloc_version_nrev@ 11 | Cflags: -I${includedir} 12 | Libs: -L${libdir} -ljemalloc${install_suffix} 13 | -------------------------------------------------------------------------------- /deps/hdr_histogram/Makefile: -------------------------------------------------------------------------------- 1 | STD= -std=c99 2 | WARN= -Wall 3 | OPT= -Os 4 | 5 | R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) -DHDR_MALLOC_INCLUDE=\"hdr_redis_malloc.h\" 6 | R_LDFLAGS= $(LDFLAGS) 7 | DEBUG= -g 8 | 9 | R_CC=$(CC) $(R_CFLAGS) 10 | R_LD=$(CC) $(R_LDFLAGS) 11 | 12 | AR= ar 13 | ARFLAGS= rcs 14 | 15 | libhdrhistogram.a: hdr_histogram.o 16 | $(AR) $(ARFLAGS) $@ $+ 17 | 18 | hdr_histogram.o: hdr_histogram.h hdr_histogram.c 19 | 20 | .c.o: 21 | $(R_CC) -c $< 22 | 23 | clean: 24 | rm -f *.o 25 | rm -f *.a 26 | 27 | 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Help us improve Redis by reporting a bug 4 | title: '[BUG]' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | 12 | A short description of the bug. 13 | 14 | **To reproduce** 15 | 16 | Steps to reproduce the behavior and/or a minimal code sample. 17 | 18 | **Expected behavior** 19 | 20 | A description of what you expected to happen. 21 | 22 | **Additional information** 23 | 24 | Any additional information that is relevant to the problem. 25 | -------------------------------------------------------------------------------- /src/commands/debug.json: -------------------------------------------------------------------------------- 1 | { 2 | "DEBUG": { 3 | "summary": "A container for debugging commands.", 4 | "complexity": "Depends on subcommand.", 5 | "group": "server", 6 | "since": "1.0.0", 7 | "arity": -2, 8 | "function": "debugCommand", 9 | "doc_flags": [ 10 | "SYSCMD" 11 | ], 12 | "command_flags": [ 13 | "ADMIN", 14 | "NOSCRIPT", 15 | "LOADING", 16 | "STALE", 17 | "PROTECTED" 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /utils/srandmember/showfreq.rb: -------------------------------------------------------------------------------- 1 | require 'redis' 2 | 3 | r = Redis.new 4 | r.select(9) 5 | r.del("myset"); 6 | r.sadd("myset",(0..999).to_a) 7 | freq = {} 8 | 500.times { 9 | res = r.pipelined { 10 | 1000.times { 11 | r.srandmember("myset") 12 | } 13 | } 14 | res.each{|ele| 15 | freq[ele] = 0 if freq[ele] == nil 16 | freq[ele] += 1 17 | } 18 | } 19 | 20 | # Print the frequency each element was yield to process it with gnuplot 21 | freq.each{|item,count| 22 | puts "#{item} #{count}" 23 | } 24 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/cpp/basic.cpp: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_basic) { 4 | auto foo = new long(4); 5 | expect_ptr_not_null(foo, "Unexpected new[] failure"); 6 | delete foo; 7 | // Test nullptr handling. 8 | foo = nullptr; 9 | delete foo; 10 | 11 | auto bar = new long; 12 | expect_ptr_not_null(bar, "Unexpected new failure"); 13 | delete bar; 14 | // Test nullptr handling. 15 | bar = nullptr; 16 | delete bar; 17 | } 18 | TEST_END 19 | 20 | int 21 | main() { 22 | return test( 23 | test_basic); 24 | } 25 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/cpp/infallible_new_false.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "test/jemalloc_test.h" 4 | 5 | TEST_BEGIN(test_failing_alloc) { 6 | bool saw_exception = false; 7 | try { 8 | /* Too big of an allocation to succeed. */ 9 | void *volatile ptr = ::operator new((size_t)-1); 10 | (void)ptr; 11 | } catch (...) { 12 | saw_exception = true; 13 | } 14 | expect_true(saw_exception, "Didn't get a failure"); 15 | } 16 | TEST_END 17 | 18 | int 19 | main(void) { 20 | return test( 21 | test_failing_alloc); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/commands/cluster-flushslots.json: -------------------------------------------------------------------------------- 1 | { 2 | "FLUSHSLOTS": { 3 | "summary": "Deletes all slots information from a node.", 4 | "complexity": "O(1)", 5 | "group": "cluster", 6 | "since": "3.0.0", 7 | "arity": 2, 8 | "container": "CLUSTER", 9 | "function": "clusterCommand", 10 | "command_flags": [ 11 | "NO_ASYNC_LOADING", 12 | "ADMIN", 13 | "STALE" 14 | ], 15 | "reply_schema": { 16 | "const": "OK" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /utils/releasetools/04_release_hash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ $# != "1" ] 3 | then 4 | echo "Usage: ./utils/releasetools/04_release_hash.sh " 5 | exit 1 6 | fi 7 | 8 | SHA=$(curl -s http://download.redis.io/releases/redis-${1}.tar.gz | shasum -a 256 | cut -f 1 -d' ') 9 | ENTRY="hash redis-${1}.tar.gz sha256 $SHA http://download.redis.io/releases/redis-${1}.tar.gz" 10 | echo $ENTRY >> ../redis-hashes/README 11 | echo "Press any key to commit, Ctrl-C to abort)." 12 | read yes 13 | (cd ../redis-hashes; git commit -a -m "${1} hash."; git push) 14 | -------------------------------------------------------------------------------- /tests/helpers/gen_write_load.tcl: -------------------------------------------------------------------------------- 1 | source tests/support/redis.tcl 2 | 3 | set ::tlsdir "tests/tls" 4 | 5 | proc gen_write_load {host port seconds tls} { 6 | set start_time [clock seconds] 7 | set r [redis $host $port 1 $tls] 8 | $r client setname LOAD_HANDLER 9 | $r select 9 10 | while 1 { 11 | $r set [expr rand()] [expr rand()] 12 | if {[clock seconds]-$start_time > $seconds} { 13 | exit 0 14 | } 15 | } 16 | } 17 | 18 | gen_write_load [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] 19 | -------------------------------------------------------------------------------- /.github/workflows/reply-schemas-linter.yml: -------------------------------------------------------------------------------- 1 | name: Reply-schemas linter 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'src/commands/*.json' 7 | pull_request: 8 | paths: 9 | - 'src/commands/*.json' 10 | 11 | jobs: 12 | reply-schemas-linter: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | - name: Setup nodejs 17 | uses: actions/setup-node@v4 18 | - name: Install packages 19 | run: npm install ajv 20 | - name: linter 21 | run: node ./utils/reply_schema_linter.js 22 | 23 | -------------------------------------------------------------------------------- /src/commands/cluster-saveconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "SAVECONFIG": { 3 | "summary": "Forces a node to save the cluster configuration to disk.", 4 | "complexity": "O(1)", 5 | "group": "cluster", 6 | "since": "3.0.0", 7 | "arity": 2, 8 | "container": "CLUSTER", 9 | "function": "clusterCommand", 10 | "command_flags": [ 11 | "NO_ASYNC_LOADING", 12 | "ADMIN", 13 | "STALE" 14 | ], 15 | "reply_schema": { 16 | "const": "OK" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/cluster/tests/helpers/onlydots.tcl: -------------------------------------------------------------------------------- 1 | # Read the standard input and only shows dots in the output, filtering out 2 | # all the other characters. Designed to avoid bufferization so that when 3 | # we get the output of redis-trib and want to show just the dots, we'll see 4 | # the dots as soon as redis-trib will output them. 5 | 6 | fconfigure stdin -buffering none 7 | 8 | while 1 { 9 | set c [read stdin 1] 10 | if {$c eq {}} { 11 | exit 0; # EOF 12 | } elseif {$c eq {.}} { 13 | puts -nonewline . 14 | flush stdout 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /deps/jemalloc/include/msvc_compat/C99/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef stdbool_h 2 | #define stdbool_h 3 | 4 | #include 5 | 6 | /* MSVC doesn't define _Bool or bool in C, but does have BOOL */ 7 | /* Note this doesn't pass autoconf's test because (bool) 0.5 != true */ 8 | /* Clang-cl uses MSVC headers, so needs msvc_compat, but has _Bool as 9 | * a built-in type. */ 10 | #ifndef __clang__ 11 | typedef BOOL _Bool; 12 | #endif 13 | 14 | #define bool _Bool 15 | #define true 1 16 | #define false 0 17 | 18 | #define __bool_true_false_are_defined 1 19 | 20 | #endif /* stdbool_h */ 21 | -------------------------------------------------------------------------------- /deps/hiredis/hiredis.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $(MSBuildThisFileDirectory)\..\..\include;%(AdditionalIncludeDirectories) 6 | 7 | 8 | $(MSBuildThisFileDirectory)\..\..\lib;%(AdditionalLibraryDirectories) 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/commands/save.json: -------------------------------------------------------------------------------- 1 | { 2 | "SAVE": { 3 | "summary": "Synchronously saves the database(s) to disk.", 4 | "complexity": "O(N) where N is the total number of keys in all databases", 5 | "group": "server", 6 | "since": "1.0.0", 7 | "arity": 1, 8 | "function": "saveCommand", 9 | "command_flags": [ 10 | "NO_ASYNC_LOADING", 11 | "ADMIN", 12 | "NOSCRIPT", 13 | "NO_MULTI" 14 | ], 15 | "reply_schema": { 16 | "const": "OK" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/bin_types.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_BIN_TYPES_H 2 | #define JEMALLOC_INTERNAL_BIN_TYPES_H 3 | 4 | #include "jemalloc/internal/sc.h" 5 | 6 | #define BIN_SHARDS_MAX (1 << EDATA_BITS_BINSHARD_WIDTH) 7 | #define N_BIN_SHARDS_DEFAULT 1 8 | 9 | /* Used in TSD static initializer only. Real init in arena_bind(). */ 10 | #define TSD_BINSHARDS_ZERO_INITIALIZER {{UINT8_MAX}} 11 | 12 | typedef struct tsd_binshards_s tsd_binshards_t; 13 | struct tsd_binshards_s { 14 | uint8_t binshard[SC_NBINS]; 15 | }; 16 | 17 | #endif /* JEMALLOC_INTERNAL_BIN_TYPES_H */ 18 | -------------------------------------------------------------------------------- /src/commands/memory-purge.json: -------------------------------------------------------------------------------- 1 | { 2 | "PURGE": { 3 | "summary": "Asks the allocator to release memory.", 4 | "complexity": "Depends on how much memory is allocated, could be slow", 5 | "group": "server", 6 | "since": "4.0.0", 7 | "arity": 2, 8 | "container": "MEMORY", 9 | "function": "memoryCommand", 10 | "command_tips": [ 11 | "REQUEST_POLICY:ALL_SHARDS", 12 | "RESPONSE_POLICY:ALL_SUCCEEDED" 13 | ], 14 | "reply_schema": { 15 | "const": "OK" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/jemalloc_rename.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | public_symbols_txt=$1 4 | 5 | cat < 4 | 5 | static bool abort_called = false; 6 | 7 | void set_abort_called() { 8 | abort_called = true; 9 | }; 10 | 11 | TEST_BEGIN(test_realloc_abort) { 12 | abort_called = false; 13 | safety_check_set_abort(&set_abort_called); 14 | void *ptr = mallocx(42, 0); 15 | expect_ptr_not_null(ptr, "Unexpected mallocx error"); 16 | ptr = realloc(ptr, 0); 17 | expect_true(abort_called, "Realloc with zero size didn't abort"); 18 | } 19 | TEST_END 20 | 21 | int 22 | main(void) { 23 | return test( 24 | test_realloc_abort); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/commands/reset.json: -------------------------------------------------------------------------------- 1 | { 2 | "RESET": { 3 | "summary": "Resets the connection.", 4 | "complexity": "O(1)", 5 | "group": "connection", 6 | "since": "6.2.0", 7 | "arity": 1, 8 | "function": "resetCommand", 9 | "command_flags": [ 10 | "NOSCRIPT", 11 | "LOADING", 12 | "STALE", 13 | "FAST", 14 | "NO_AUTH", 15 | "ALLOW_BUSY" 16 | ], 17 | "acl_categories": [ 18 | "CONNECTION" 19 | ], 20 | "reply_schema": { 21 | "const": "RESET" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/commands/unwatch.json: -------------------------------------------------------------------------------- 1 | { 2 | "UNWATCH": { 3 | "summary": "Forgets about watched keys of a transaction.", 4 | "complexity": "O(1)", 5 | "group": "transactions", 6 | "since": "2.2.0", 7 | "arity": 1, 8 | "function": "unwatchCommand", 9 | "command_flags": [ 10 | "NOSCRIPT", 11 | "LOADING", 12 | "STALE", 13 | "FAST", 14 | "ALLOW_BUSY" 15 | ], 16 | "acl_categories": [ 17 | "TRANSACTION" 18 | ], 19 | "reply_schema": { 20 | "const": "OK" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/prof_stats.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_PROF_STATS_H 2 | #define JEMALLOC_INTERNAL_PROF_STATS_H 3 | 4 | typedef struct prof_stats_s prof_stats_t; 5 | struct prof_stats_s { 6 | uint64_t req_sum; 7 | uint64_t count; 8 | }; 9 | 10 | extern malloc_mutex_t prof_stats_mtx; 11 | 12 | void prof_stats_inc(tsd_t *tsd, szind_t ind, size_t size); 13 | void prof_stats_dec(tsd_t *tsd, szind_t ind, size_t size); 14 | void prof_stats_get_live(tsd_t *tsd, szind_t ind, prof_stats_t *stats); 15 | void prof_stats_get_accum(tsd_t *tsd, szind_t ind, prof_stats_t *stats); 16 | 17 | #endif /* JEMALLOC_INTERNAL_PROF_STATS_H */ 18 | -------------------------------------------------------------------------------- /src/commands/command.json: -------------------------------------------------------------------------------- 1 | { 2 | "COMMAND": { 3 | "summary": "Returns detailed information about all commands.", 4 | "complexity": "O(N) where N is the total number of Redis commands", 5 | "group": "server", 6 | "since": "2.8.13", 7 | "arity": -1, 8 | "function": "commandCommand", 9 | "command_flags": [ 10 | "LOADING", 11 | "STALE", 12 | "SENTINEL" 13 | ], 14 | "acl_categories": [ 15 | "CONNECTION" 16 | ], 17 | "command_tips": [ 18 | "NONDETERMINISTIC_OUTPUT_ORDER" 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/commands/replconf.json: -------------------------------------------------------------------------------- 1 | { 2 | "REPLCONF": { 3 | "summary": "An internal command for configuring the replication stream.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "3.0.0", 7 | "arity": -1, 8 | "function": "replconfCommand", 9 | "doc_flags": [ 10 | "SYSCMD" 11 | ], 12 | "command_flags": [ 13 | "ADMIN", 14 | "NOSCRIPT", 15 | "LOADING", 16 | "STALE", 17 | "ALLOW_BUSY" 18 | ], 19 | "reply_schema": { 20 | "const": "OK" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/commands/acl-whoami.json: -------------------------------------------------------------------------------- 1 | { 2 | "WHOAMI": { 3 | "summary": "Returns the authenticated username of the current connection.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "6.0.0", 7 | "arity": 2, 8 | "container": "ACL", 9 | "function": "aclCommand", 10 | "command_flags": [ 11 | "NOSCRIPT", 12 | "LOADING", 13 | "STALE", 14 | "SENTINEL" 15 | ], 16 | "reply_schema": { 17 | "type": "string", 18 | "description": "The username of the current connection." 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /deps/jemalloc/test/include/test/mtx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mtx is a slightly simplified version of malloc_mutex. This code duplication 3 | * is unfortunate, but there are allocator bootstrapping considerations that 4 | * would leak into the test infrastructure if malloc_mutex were used directly 5 | * in tests. 6 | */ 7 | 8 | typedef struct { 9 | #ifdef _WIN32 10 | CRITICAL_SECTION lock; 11 | #elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) 12 | os_unfair_lock lock; 13 | #else 14 | pthread_mutex_t lock; 15 | #endif 16 | } mtx_t; 17 | 18 | bool mtx_init(mtx_t *mtx); 19 | void mtx_fini(mtx_t *mtx); 20 | void mtx_lock(mtx_t *mtx); 21 | void mtx_unlock(mtx_t *mtx); 22 | -------------------------------------------------------------------------------- /src/commands/bgrewriteaof.json: -------------------------------------------------------------------------------- 1 | { 2 | "BGREWRITEAOF": { 3 | "summary": "Asynchronously rewrites the append-only file to disk.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "1.0.0", 7 | "arity": 1, 8 | "function": "bgrewriteaofCommand", 9 | "command_flags": [ 10 | "NO_ASYNC_LOADING", 11 | "ADMIN", 12 | "NOSCRIPT" 13 | ], 14 | "reply_schema": { 15 | "description": "A simple string reply indicating that the rewriting started or is about to start ASAP", 16 | "type": "string" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/commands/cluster-myshardid.json: -------------------------------------------------------------------------------- 1 | { 2 | "MYSHARDID": { 3 | "summary": "Returns the shard ID of a node.", 4 | "complexity": "O(1)", 5 | "group": "cluster", 6 | "since": "7.2.0", 7 | "arity": 2, 8 | "container": "CLUSTER", 9 | "function": "clusterCommand", 10 | "history": [], 11 | "command_flags": [ 12 | "STALE" 13 | ], 14 | "command_tips": [ 15 | "NONDETERMINISTIC_OUTPUT" 16 | ], 17 | "reply_schema": { 18 | "description": "the node's shard id", 19 | "type": "string" 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/commands/discard.json: -------------------------------------------------------------------------------- 1 | { 2 | "DISCARD": { 3 | "summary": "Discards a transaction.", 4 | "complexity": "O(N), when N is the number of queued commands", 5 | "group": "transactions", 6 | "since": "2.0.0", 7 | "arity": 1, 8 | "function": "discardCommand", 9 | "command_flags": [ 10 | "NOSCRIPT", 11 | "LOADING", 12 | "STALE", 13 | "FAST", 14 | "ALLOW_BUSY" 15 | ], 16 | "acl_categories": [ 17 | "TRANSACTION" 18 | ], 19 | "reply_schema": { 20 | "const": "OK" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /deps/jemalloc/msvc/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | How to build jemalloc for Windows 3 | ================================= 4 | 5 | 1. Install Cygwin with at least the following packages: 6 | * autoconf 7 | * autogen 8 | * gawk 9 | * grep 10 | * sed 11 | 12 | 2. Install Visual Studio 2015 or 2017 with Visual C++ 13 | 14 | 3. Add Cygwin\bin to the PATH environment variable 15 | 16 | 4. Open "x64 Native Tools Command Prompt for VS 2017" 17 | (note: x86/x64 doesn't matter at this point) 18 | 19 | 5. Generate header files: 20 | sh -c "CC=cl ./autogen.sh" 21 | 22 | 6. Now the project can be opened and built in Visual Studio: 23 | msvc\jemalloc_vc2017.sln 24 | -------------------------------------------------------------------------------- /src/commands/pubsub-numpat.json: -------------------------------------------------------------------------------- 1 | { 2 | "NUMPAT": { 3 | "summary": "Returns a count of unique pattern subscriptions.", 4 | "complexity": "O(1)", 5 | "group": "pubsub", 6 | "since": "2.8.0", 7 | "arity": 2, 8 | "container": "PUBSUB", 9 | "function": "pubsubCommand", 10 | "command_flags": [ 11 | "PUBSUB", 12 | "LOADING", 13 | "STALE" 14 | ], 15 | "reply_schema": { 16 | "description": "the number of patterns all the clients are subscribed to", 17 | "type": "integer", 18 | "minimum": 0 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/commands/slowlog-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Show helpful text about the different subcommands", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "6.2.0", 7 | "arity": 2, 8 | "container": "SLOWLOG", 9 | "function": "slowlogCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE" 13 | ], 14 | "reply_schema": { 15 | "type": "array", 16 | "description": "Helpful text about subcommands.", 17 | "items": { 18 | "type": "string" 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/commands/cluster-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "cluster", 6 | "since": "5.0.0", 7 | "arity": 2, 8 | "container": "CLUSTER", 9 | "function": "clusterCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE" 13 | ], 14 | "reply_schema": { 15 | "type": "array", 16 | "description": "Helpful text about subcommands.", 17 | "items": { 18 | "type": "string" 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/commands/config-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "5.0.0", 7 | "arity": 2, 8 | "container": "CONFIG", 9 | "function": "configHelpCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE" 13 | ], 14 | "reply_schema": { 15 | "type": "array", 16 | "description": "Helpful text about subcommands.", 17 | "items": { 18 | "type": "string" 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/commands/latency-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "2.8.13", 7 | "arity": 2, 8 | "container": "LATENCY", 9 | "function": "latencyCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE" 13 | ], 14 | "reply_schema": { 15 | "type": "array", 16 | "description": "Helpful text about subcommands.", 17 | "items": { 18 | "type": "string" 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/commands/memory-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "4.0.0", 7 | "arity": 2, 8 | "container": "MEMORY", 9 | "function": "memoryCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE" 13 | ], 14 | "reply_schema": { 15 | "type": "array", 16 | "description": "Helpful text about subcommands.", 17 | "items": { 18 | "type": "string" 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/commands/module-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "5.0.0", 7 | "arity": 2, 8 | "container": "MODULE", 9 | "function": "moduleCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE" 13 | ], 14 | "reply_schema": { 15 | "type": "array", 16 | "description": "Helpful text about subcommands.", 17 | "items": { 18 | "type": "string" 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/commands/pubsub-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "pubsub", 6 | "since": "6.2.0", 7 | "arity": 2, 8 | "container": "PUBSUB", 9 | "function": "pubsubCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE" 13 | ], 14 | "reply_schema": { 15 | "type": "array", 16 | "description": "Helpful text about subcommands.", 17 | "items": { 18 | "type": "string" 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/commands/function-dump.json: -------------------------------------------------------------------------------- 1 | { 2 | "DUMP": { 3 | "summary": "Dumps all libraries into a serialized binary payload.", 4 | "complexity": "O(N) where N is the number of functions", 5 | "group": "scripting", 6 | "since": "7.0.0", 7 | "arity": 2, 8 | "container": "FUNCTION", 9 | "function": "functionDumpCommand", 10 | "command_flags": [ 11 | "NOSCRIPT" 12 | ], 13 | "acl_categories": [ 14 | "SCRIPTING" 15 | ], 16 | "reply_schema": { 17 | "description": "the serialized payload", 18 | "type": "string" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /utils/releasetools/03_test_release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | if [ $# != "1" ] 4 | then 5 | echo "Usage: ./utils/releasetools/03_test_release.sh " 6 | exit 1 7 | fi 8 | 9 | TAG=$1 10 | TARNAME="redis-${TAG}.tar.gz" 11 | DOWNLOADURL="http://download.redis.io/releases/${TARNAME}" 12 | 13 | echo "Doing sanity test on the actual tarball" 14 | 15 | cd /tmp 16 | rm -rf test_release_tmp_dir 17 | mkdir test_release_tmp_dir 18 | cd test_release_tmp_dir 19 | rm -f $TARNAME 20 | rm -rf redis-${TAG} 21 | wget $DOWNLOADURL 22 | tar xvzf $TARNAME 23 | cd redis-${TAG} 24 | make 25 | ./runtest 26 | ./runtest-sentinel 27 | ./runtest-cluster 28 | ./runtest-moduleapi 29 | -------------------------------------------------------------------------------- /tests/unit/limits.tcl: -------------------------------------------------------------------------------- 1 | start_server {tags {"limits network external:skip"} overrides {maxclients 10}} { 2 | if {$::tls} { 3 | set expected_code "*I/O error*" 4 | } else { 5 | set expected_code "*ERR max*reached*" 6 | } 7 | test {Check if maxclients works refusing connections} { 8 | set c 0 9 | catch { 10 | while {$c < 50} { 11 | incr c 12 | set rd [redis_deferring_client] 13 | $rd ping 14 | $rd read 15 | after 100 16 | } 17 | } e 18 | assert {$c > 8 && $c <= 10} 19 | set e 20 | } $expected_code 21 | } 22 | -------------------------------------------------------------------------------- /deps/hiredis/.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | # branches to consider in the event; optional, defaults to all 6 | branches: 7 | - master 8 | 9 | jobs: 10 | update_release_draft: 11 | runs-on: ubuntu-latest 12 | steps: 13 | # Drafts your next Release notes as Pull Requests are merged into "master" 14 | - uses: release-drafter/release-drafter@v5 15 | with: 16 | # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml 17 | config-name: release-drafter-config.yml 18 | env: 19 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 20 | -------------------------------------------------------------------------------- /src/commands/sentinel-flushconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "FLUSHCONFIG": { 3 | "summary": "Rewrites the Redis Sentinel configuration file.", 4 | "complexity": "O(1)", 5 | "group": "sentinel", 6 | "since": "2.8.4", 7 | "arity": 2, 8 | "container": "SENTINEL", 9 | "function": "sentinelCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "SENTINEL", 13 | "ONLY_SENTINEL" 14 | ], 15 | "reply_schema": { 16 | "const": "OK", 17 | "description": "Force Sentinel to rewrite its configuration on disk, including the current Sentinel state." 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/commands/sentinel-remove.json: -------------------------------------------------------------------------------- 1 | { 2 | "REMOVE": { 3 | "summary": "Stops monitoring.", 4 | "complexity": "O(1)", 5 | "group": "sentinel", 6 | "since": "2.8.4", 7 | "arity": 3, 8 | "container": "SENTINEL", 9 | "function": "sentinelCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "SENTINEL", 13 | "ONLY_SENTINEL" 14 | ], 15 | "reply_schema": { 16 | "const": "OK" 17 | }, 18 | "arguments": [ 19 | { 20 | "name": "master-name", 21 | "type": "string" 22 | } 23 | ] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/commands/cluster-nodes.json: -------------------------------------------------------------------------------- 1 | { 2 | "NODES": { 3 | "summary": "Returns the cluster configuration for a node.", 4 | "complexity": "O(N) where N is the total number of Cluster nodes", 5 | "group": "cluster", 6 | "since": "3.0.0", 7 | "arity": 2, 8 | "container": "CLUSTER", 9 | "function": "clusterCommand", 10 | "command_flags": [ 11 | "STALE" 12 | ], 13 | "command_tips": [ 14 | "NONDETERMINISTIC_OUTPUT" 15 | ], 16 | "reply_schema": { 17 | "description": "the serialized cluster configuration", 18 | "type": "string" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/commands/command-count.json: -------------------------------------------------------------------------------- 1 | { 2 | "COUNT": { 3 | "summary": "Returns a count of commands.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "2.8.13", 7 | "arity": 2, 8 | "container": "COMMAND", 9 | "function": "commandCountCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE", 13 | "SENTINEL" 14 | ], 15 | "acl_categories": [ 16 | "CONNECTION" 17 | ], 18 | "reply_schema": { 19 | "description": "Number of total commands in this Redis server.", 20 | "type": "integer" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/commands/psync.json: -------------------------------------------------------------------------------- 1 | { 2 | "PSYNC": { 3 | "summary": "An internal command used in replication.", 4 | "group": "server", 5 | "since": "2.8.0", 6 | "arity": -3, 7 | "function": "syncCommand", 8 | "command_flags": [ 9 | "NO_ASYNC_LOADING", 10 | "ADMIN", 11 | "NO_MULTI", 12 | "NOSCRIPT" 13 | ], 14 | "arguments": [ 15 | { 16 | "name": "replicationid", 17 | "type": "string" 18 | }, 19 | { 20 | "name": "offset", 21 | "type": "integer" 22 | } 23 | ] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /00-RELEASENOTES: -------------------------------------------------------------------------------- 1 | Hello! This file is just a placeholder, since this is the "unstable" branch 2 | of Redis, the place where all the development happens. 3 | 4 | There is no release notes for this branch, it gets forked into another branch 5 | every time there is a partial feature freeze in order to eventually create 6 | a new stable release. 7 | 8 | Usually "unstable" is stable enough for you to use it in development environments 9 | however you should never use it in production environments. It is possible 10 | to download the latest stable release here: 11 | 12 | https://download.redis.io/redis-stable.tar.gz 13 | 14 | More information is available at https://redis.io 15 | 16 | Happy hacking! 17 | -------------------------------------------------------------------------------- /src/commands/acl-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "6.0.0", 7 | "arity": 2, 8 | "container": "ACL", 9 | "function": "aclCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE", 13 | "SENTINEL" 14 | ], 15 | "reply_schema": { 16 | "type": "array", 17 | "description": "A list of subcommands and their description", 18 | "items": { 19 | "type": "string" 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/commands/cluster-forget.json: -------------------------------------------------------------------------------- 1 | { 2 | "FORGET": { 3 | "summary": "Removes a node from the nodes table.", 4 | "complexity": "O(1)", 5 | "group": "cluster", 6 | "since": "3.0.0", 7 | "arity": 3, 8 | "container": "CLUSTER", 9 | "function": "clusterCommand", 10 | "command_flags": [ 11 | "NO_ASYNC_LOADING", 12 | "ADMIN", 13 | "STALE" 14 | ], 15 | "arguments": [ 16 | { 17 | "name": "node-id", 18 | "type": "string" 19 | } 20 | ], 21 | "reply_schema": { 22 | "const": "OK" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/commands/config-resetstat.json: -------------------------------------------------------------------------------- 1 | { 2 | "RESETSTAT": { 3 | "summary": "Resets the server's statistics.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "2.0.0", 7 | "arity": 2, 8 | "container": "CONFIG", 9 | "function": "configResetStatCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "NOSCRIPT", 13 | "LOADING", 14 | "STALE" 15 | ], 16 | "command_tips": [ 17 | "REQUEST_POLICY:ALL_NODES", 18 | "RESPONSE_POLICY:ALL_SUCCEEDED" 19 | ], 20 | "reply_schema": { 21 | "const": "OK" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /utils/srandmember/README.md: -------------------------------------------------------------------------------- 1 | The utilities in this directory plot the distribution of SRANDMEMBER to 2 | evaluate how fair it is. 3 | 4 | See http://theshfl.com/redis_sets for more information on the topic that lead 5 | to such investigation fix. 6 | 7 | showdist.rb -- shows the distribution of the frequency elements are returned. 8 | The x axis is the number of times elements were returned, and 9 | the y axis is how many elements were returned with such 10 | frequency. 11 | 12 | showfreq.rb -- shows the frequency each element was returned. 13 | The x axis is the element number. 14 | The y axis is the times it was returned. 15 | -------------------------------------------------------------------------------- /src/commands/client-id.json: -------------------------------------------------------------------------------- 1 | { 2 | "ID": { 3 | "summary": "Returns the unique client ID of the connection.", 4 | "complexity": "O(1)", 5 | "group": "connection", 6 | "since": "5.0.0", 7 | "arity": 2, 8 | "container": "CLIENT", 9 | "function": "clientCommand", 10 | "command_flags": [ 11 | "NOSCRIPT", 12 | "LOADING", 13 | "STALE", 14 | "SENTINEL" 15 | ], 16 | "acl_categories": [ 17 | "CONNECTION" 18 | ], 19 | "reply_schema": { 20 | "type": "integer", 21 | "description": "The id of the client" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/commands/module-unload.json: -------------------------------------------------------------------------------- 1 | { 2 | "UNLOAD": { 3 | "summary": "Unloads a module.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "4.0.0", 7 | "arity": 3, 8 | "container": "MODULE", 9 | "function": "moduleCommand", 10 | "command_flags": [ 11 | "NO_ASYNC_LOADING", 12 | "ADMIN", 13 | "NOSCRIPT", 14 | "PROTECTED" 15 | ], 16 | "reply_schema": { 17 | "const": "OK" 18 | }, 19 | "arguments": [ 20 | { 21 | "name": "name", 22 | "type": "string" 23 | } 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/commands/config-rewrite.json: -------------------------------------------------------------------------------- 1 | { 2 | "REWRITE": { 3 | "summary": "Persists the effective configuration to file.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "2.8.0", 7 | "arity": 2, 8 | "container": "CONFIG", 9 | "function": "configRewriteCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "NOSCRIPT", 13 | "LOADING", 14 | "STALE" 15 | ], 16 | "command_tips": [ 17 | "REQUEST_POLICY:ALL_NODES", 18 | "RESPONSE_POLICY:ALL_SUCCEEDED" 19 | ], 20 | "reply_schema": { 21 | "const": "OK" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/commands/cluster-replicate.json: -------------------------------------------------------------------------------- 1 | { 2 | "REPLICATE": { 3 | "summary": "Configure a node as replica of a master node.", 4 | "complexity": "O(1)", 5 | "group": "cluster", 6 | "since": "3.0.0", 7 | "arity": 3, 8 | "container": "CLUSTER", 9 | "function": "clusterCommand", 10 | "command_flags": [ 11 | "NO_ASYNC_LOADING", 12 | "ADMIN", 13 | "STALE" 14 | ], 15 | "arguments": [ 16 | { 17 | "name": "node-id", 18 | "type": "string" 19 | } 20 | ], 21 | "reply_schema": { 22 | "const": "OK" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /utils/build-static-symbols.tcl: -------------------------------------------------------------------------------- 1 | # Build a symbol table for static symbols of redis.c 2 | # Useful to get stack traces on segfault without a debugger. See redis.c 3 | # for more information. 4 | # 5 | # Copyright(C) 2009 Salvatore Sanfilippo, under the BSD license. 6 | 7 | set fd [open redis.c] 8 | set symlist {} 9 | while {[gets $fd line] != -1} { 10 | if {[regexp {^static +[A-z0-9]+[ *]+([A-z0-9]*)\(} $line - sym]} { 11 | lappend symlist $sym 12 | } 13 | } 14 | set symlist [lsort -unique $symlist] 15 | puts "static struct redisFunctionSym symsTable\[\] = {" 16 | foreach sym $symlist { 17 | puts "{\"$sym\",(unsigned long)$sym}," 18 | } 19 | puts "{NULL,0}" 20 | puts "};" 21 | 22 | close $fd 23 | -------------------------------------------------------------------------------- /src/commands/client-unpause.json: -------------------------------------------------------------------------------- 1 | { 2 | "UNPAUSE": { 3 | "summary": "Resumes processing commands from paused clients.", 4 | "complexity": "O(N) Where N is the number of paused clients", 5 | "group": "connection", 6 | "since": "6.2.0", 7 | "arity": 2, 8 | "container": "CLIENT", 9 | "function": "clientCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "NOSCRIPT", 13 | "LOADING", 14 | "STALE", 15 | "SENTINEL" 16 | ], 17 | "acl_categories": [ 18 | "CONNECTION" 19 | ], 20 | "reply_schema": { 21 | "const": "OK" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/commands/select.json: -------------------------------------------------------------------------------- 1 | { 2 | "SELECT": { 3 | "summary": "Changes the selected database.", 4 | "complexity": "O(1)", 5 | "group": "connection", 6 | "since": "1.0.0", 7 | "arity": 2, 8 | "function": "selectCommand", 9 | "command_flags": [ 10 | "LOADING", 11 | "STALE", 12 | "FAST" 13 | ], 14 | "acl_categories": [ 15 | "CONNECTION" 16 | ], 17 | "reply_schema": { 18 | "const": "OK" 19 | }, 20 | "arguments": [ 21 | { 22 | "name": "index", 23 | "type": "integer" 24 | } 25 | ] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/commands/slowlog-reset.json: -------------------------------------------------------------------------------- 1 | { 2 | "RESET": { 3 | "summary": "Clears all entries from the slow log.", 4 | "complexity": "O(N) where N is the number of entries in the slowlog", 5 | "group": "server", 6 | "since": "2.2.12", 7 | "arity": 2, 8 | "container": "SLOWLOG", 9 | "function": "slowlogCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "LOADING", 13 | "STALE" 14 | ], 15 | "command_tips": [ 16 | "REQUEST_POLICY:ALL_NODES", 17 | "RESPONSE_POLICY:ALL_SUCCEEDED" 18 | ], 19 | "reply_schema": { 20 | "const": "OK" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/crash_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Crash report 3 | about: Submit a crash report 4 | title: '[CRASH] ' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Notice! 11 | - If a Redis module was involved, please open an issue in the module's repo instead! 12 | - If you're using docker on Apple M1, please make sure the image you're using was compiled for ARM! 13 | 14 | 15 | **Crash report** 16 | 17 | Paste the complete crash log between the quotes below. Please include a few lines from the log preceding the crash report to provide some context. 18 | 19 | ``` 20 | ``` 21 | 22 | **Additional information** 23 | 24 | 1. OS distribution and version 25 | 2. Steps to reproduce (if any) 26 | -------------------------------------------------------------------------------- /src/commands/memory-malloc-stats.json: -------------------------------------------------------------------------------- 1 | { 2 | "MALLOC-STATS": { 3 | "summary": "Returns the allocator statistics.", 4 | "complexity": "Depends on how much memory is allocated, could be slow", 5 | "group": "server", 6 | "since": "4.0.0", 7 | "arity": 2, 8 | "container": "MEMORY", 9 | "function": "memoryCommand", 10 | "command_tips": [ 11 | "NONDETERMINISTIC_OUTPUT", 12 | "REQUEST_POLICY:ALL_SHARDS", 13 | "RESPONSE_POLICY:SPECIAL" 14 | ], 15 | "reply_schema": { 16 | "type": "string", 17 | "description": "The memory allocator's internal statistics report." 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/cli_commands.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "cli_commands.h" 3 | 4 | /* Definitions to configure commands.c to generate the above structs. */ 5 | #define MAKE_CMD(name,summary,complexity,since,doc_flags,replaced,deprecated,group,group_enum,history,num_history,tips,num_tips,function,arity,flags,acl,key_specs,key_specs_num,get_keys,numargs) name,summary,group,since,numargs 6 | #define MAKE_ARG(name,type,key_spec_index,token,summary,since,flags,numsubargs,deprecated_since) name,type,token,since,flags,numsubargs 7 | #define COMMAND_ARG cliCommandArg 8 | #define COMMAND_STRUCT commandDocs 9 | #define SKIP_CMD_HISTORY_TABLE 10 | #define SKIP_CMD_TIPS_TABLE 11 | #define SKIP_CMD_KEY_SPECS_TABLE 12 | 13 | #include "commands.def" 14 | -------------------------------------------------------------------------------- /src/commands/cluster-set-config-epoch.json: -------------------------------------------------------------------------------- 1 | { 2 | "SET-CONFIG-EPOCH": { 3 | "summary": "Sets the configuration epoch for a new node.", 4 | "complexity": "O(1)", 5 | "group": "cluster", 6 | "since": "3.0.0", 7 | "arity": 3, 8 | "container": "CLUSTER", 9 | "function": "clusterCommand", 10 | "command_flags": [ 11 | "NO_ASYNC_LOADING", 12 | "ADMIN", 13 | "STALE" 14 | ], 15 | "arguments": [ 16 | { 17 | "name": "config-epoch", 18 | "type": "integer" 19 | } 20 | ], 21 | "reply_schema": { 22 | "const": "OK" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/sentinel/tests/includes/start-init-tests.tcl: -------------------------------------------------------------------------------- 1 | test "(start-init) Flush config and compare rewrite config file lines" { 2 | foreach_sentinel_id id { 3 | assert_match "OK" [S $id SENTINEL FLUSHCONFIG] 4 | set file1 ../tests/includes/sentinel.conf 5 | set file2 [file join "sentinel_${id}" "sentinel.conf"] 6 | set fh1 [open $file1 r] 7 | set fh2 [open $file2 r] 8 | while {[gets $fh1 line1]} { 9 | if {[gets $fh2 line2]} { 10 | assert [string equal $line1 $line2] 11 | } else { 12 | fail "sentinel config file rewrite sequence changed" 13 | } 14 | } 15 | close $fh1 16 | close $fh2 17 | } 18 | } -------------------------------------------------------------------------------- /src/commands/cluster-info.json: -------------------------------------------------------------------------------- 1 | { 2 | "INFO": { 3 | "summary": "Returns information about the state of a node.", 4 | "complexity": "O(1)", 5 | "group": "cluster", 6 | "since": "3.0.0", 7 | "arity": 2, 8 | "container": "CLUSTER", 9 | "function": "clusterCommand", 10 | "command_flags": [ 11 | "STALE" 12 | ], 13 | "command_tips": [ 14 | "NONDETERMINISTIC_OUTPUT" 15 | ], 16 | "reply_schema": { 17 | "description": "A map between named fields and values in the form of : lines separated by newlines composed by the two bytes CRLF", 18 | "type": "string" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/commands/function-kill.json: -------------------------------------------------------------------------------- 1 | { 2 | "KILL": { 3 | "summary": "Terminates a function during execution.", 4 | "complexity": "O(1)", 5 | "group": "scripting", 6 | "since": "7.0.0", 7 | "arity": 2, 8 | "container": "FUNCTION", 9 | "function": "functionKillCommand", 10 | "command_flags": [ 11 | "NOSCRIPT", 12 | "ALLOW_BUSY" 13 | ], 14 | "acl_categories": [ 15 | "SCRIPTING" 16 | ], 17 | "command_tips": [ 18 | "REQUEST_POLICY:ALL_SHARDS", 19 | "RESPONSE_POLICY:ONE_SUCCEEDED" 20 | ], 21 | "reply_schema": { 22 | "const": "OK" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/commands/script-kill.json: -------------------------------------------------------------------------------- 1 | { 2 | "KILL": { 3 | "summary": "Terminates a server-side Lua script during execution.", 4 | "complexity": "O(1)", 5 | "group": "scripting", 6 | "since": "2.6.0", 7 | "arity": 2, 8 | "container": "SCRIPT", 9 | "function": "scriptCommand", 10 | "command_flags": [ 11 | "NOSCRIPT", 12 | "ALLOW_BUSY" 13 | ], 14 | "acl_categories": [ 15 | "SCRIPTING" 16 | ], 17 | "command_tips": [ 18 | "REQUEST_POLICY:ALL_SHARDS", 19 | "RESPONSE_POLICY:ONE_SUCCEEDED" 20 | ], 21 | "reply_schema": { 22 | "const": "OK" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/commands/sentinel-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "sentinel", 6 | "since": "6.2.0", 7 | "arity": 2, 8 | "container": "SENTINEL", 9 | "function": "sentinelCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE", 13 | "SENTINEL", 14 | "ONLY_SENTINEL" 15 | ], 16 | "reply_schema": { 17 | "type": "array", 18 | "description": "Helpful text about subcommands.", 19 | "items": { 20 | "type": "string" 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/commands/xinfo-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "stream", 6 | "since": "5.0.0", 7 | "arity": 2, 8 | "container": "XINFO", 9 | "function": "xinfoCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE" 13 | ], 14 | "acl_categories": [ 15 | "STREAM" 16 | ], 17 | "reply_schema": { 18 | "type": "array", 19 | "description": "Helpful text about subcommands.", 20 | "items": { 21 | "type": "string" 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/commands/object-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "generic", 6 | "since": "6.2.0", 7 | "arity": 2, 8 | "container": "OBJECT", 9 | "function": "objectCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE" 13 | ], 14 | "acl_categories": [ 15 | "KEYSPACE" 16 | ], 17 | "reply_schema": { 18 | "type": "array", 19 | "description": "Helpful text about subcommands.", 20 | "items": { 21 | "type": "string" 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/commands/xgroup-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "stream", 6 | "since": "5.0.0", 7 | "arity": 2, 8 | "container": "XGROUP", 9 | "function": "xgroupCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE" 13 | ], 14 | "acl_categories": [ 15 | "STREAM" 16 | ], 17 | "reply_schema": { 18 | "type": "array", 19 | "description": "Helpful text about subcommands.", 20 | "items": { 21 | "type": "string" 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /deps/hdr_histogram/hdr_tests.h: -------------------------------------------------------------------------------- 1 | #ifndef HDR_TESTS_H 2 | #define HDR_TESTS_H 3 | 4 | /* These are functions used in tests and are not intended for normal usage. */ 5 | 6 | #include "hdr_histogram.h" 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | int32_t counts_index_for(const struct hdr_histogram* h, int64_t value); 13 | int hdr_encode_compressed(struct hdr_histogram* h, uint8_t** compressed_histogram, size_t* compressed_len); 14 | int hdr_decode_compressed(uint8_t* buffer, size_t length, struct hdr_histogram** histogram); 15 | void hdr_base64_decode_block(const char* input, uint8_t* output); 16 | void hdr_base64_encode_block(const uint8_t* input, char* output); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/commands/acl-users.json: -------------------------------------------------------------------------------- 1 | { 2 | "USERS": { 3 | "summary": "Lists all ACL users.", 4 | "complexity": "O(N). Where N is the number of configured users.", 5 | "group": "server", 6 | "since": "6.0.0", 7 | "arity": 2, 8 | "container": "ACL", 9 | "function": "aclCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "NOSCRIPT", 13 | "LOADING", 14 | "STALE", 15 | "SENTINEL" 16 | ], 17 | "reply_schema": { 18 | "type": "array", 19 | "description": "List of existing ACL users", 20 | "items": { 21 | "type": "string" 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/commands/script-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "scripting", 6 | "since": "5.0.0", 7 | "arity": 2, 8 | "container": "SCRIPT", 9 | "function": "scriptCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE" 13 | ], 14 | "acl_categories": [ 15 | "SCRIPTING" 16 | ], 17 | "reply_schema": { 18 | "type": "array", 19 | "description": "Helpful text about subcommands.", 20 | "items": { 21 | "type": "string" 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/unit/moduleapi/mallocsize.tcl: -------------------------------------------------------------------------------- 1 | set testmodule [file normalize tests/modules/mallocsize.so] 2 | 3 | 4 | start_server {tags {"modules"}} { 5 | r module load $testmodule 6 | 7 | test {MallocSize of raw bytes} { 8 | assert_equal [r mallocsize.setraw key 40] {OK} 9 | assert_morethan [r memory usage key] 40 10 | } 11 | 12 | test {MallocSize of string} { 13 | assert_equal [r mallocsize.setstr key abcdefg] {OK} 14 | assert_morethan [r memory usage key] 7 ;# Length of "abcdefg" 15 | } 16 | 17 | test {MallocSize of dict} { 18 | assert_equal [r mallocsize.setdict key f1 v1 f2 v2] {OK} 19 | assert_morethan [r memory usage key] 8 ;# Length of "f1v1f2v2" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/prof_log.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_PROF_LOG_H 2 | #define JEMALLOC_INTERNAL_PROF_LOG_H 3 | 4 | #include "jemalloc/internal/mutex.h" 5 | 6 | extern malloc_mutex_t log_mtx; 7 | 8 | void prof_try_log(tsd_t *tsd, size_t usize, prof_info_t *prof_info); 9 | bool prof_log_init(tsd_t *tsdn); 10 | 11 | /* Used in unit tests. */ 12 | size_t prof_log_bt_count(void); 13 | size_t prof_log_alloc_count(void); 14 | size_t prof_log_thr_count(void); 15 | bool prof_log_is_logging(void); 16 | bool prof_log_rep_check(void); 17 | void prof_log_dummy_set(bool new_value); 18 | 19 | bool prof_log_start(tsdn_t *tsdn, const char *filename); 20 | bool prof_log_stop(tsdn_t *tsdn); 21 | 22 | #endif /* JEMALLOC_INTERNAL_PROF_LOG_H */ 23 | -------------------------------------------------------------------------------- /utils/srandmember/showdist.rb: -------------------------------------------------------------------------------- 1 | require 'redis' 2 | 3 | r = Redis.new 4 | r.select(9) 5 | r.del("myset"); 6 | r.sadd("myset",(0..999).to_a) 7 | freq = {} 8 | 100.times { 9 | res = r.pipelined { 10 | 1000.times { 11 | r.srandmember("myset") 12 | } 13 | } 14 | res.each{|ele| 15 | freq[ele] = 0 if freq[ele] == nil 16 | freq[ele] += 1 17 | } 18 | } 19 | 20 | # Convert into frequency distribution 21 | dist = {} 22 | freq.each{|item,count| 23 | dist[count] = 0 if dist[count] == nil 24 | dist[count] += 1 25 | } 26 | 27 | min = dist.keys.min 28 | max = dist.keys.max 29 | (min..max).each{|x| 30 | count = dist[x] 31 | count = 0 if count == nil 32 | puts "#{x} -> #{"*"*count}" 33 | } 34 | -------------------------------------------------------------------------------- /src/commands/function-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "scripting", 6 | "since": "7.0.0", 7 | "arity": 2, 8 | "container": "FUNCTION", 9 | "function": "functionHelpCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE" 13 | ], 14 | "acl_categories": [ 15 | "SCRIPTING" 16 | ], 17 | "reply_schema": { 18 | "type": "array", 19 | "description": "Helpful text about subcommands.", 20 | "items": { 21 | "type": "string" 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/commands/subscribe.json: -------------------------------------------------------------------------------- 1 | { 2 | "SUBSCRIBE": { 3 | "summary": "Listens for messages published to channels.", 4 | "complexity": "O(N) where N is the number of channels to subscribe to.", 5 | "group": "pubsub", 6 | "since": "2.0.0", 7 | "arity": -2, 8 | "function": "subscribeCommand", 9 | "history": [], 10 | "command_flags": [ 11 | "PUBSUB", 12 | "NOSCRIPT", 13 | "LOADING", 14 | "STALE", 15 | "SENTINEL" 16 | ], 17 | "arguments": [ 18 | { 19 | "name": "channel", 20 | "type": "string", 21 | "multiple": true 22 | } 23 | ] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest a feature for Redis 4 | title: '[NEW]' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **The problem/use-case that the feature addresses** 11 | 12 | A description of the problem that the feature will solve, or the use-case with which the feature will be used. 13 | 14 | **Description of the feature** 15 | 16 | A description of what you want to happen. 17 | 18 | **Alternatives you've considered** 19 | 20 | Any alternative solutions or features you've considered, including references to existing open and closed feature requests in this repository. 21 | 22 | **Additional information** 23 | 24 | Any additional information that is relevant to the feature request. 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | *.o 3 | *.xo 4 | *.so 5 | *.d 6 | *.log 7 | dump.rdb 8 | redis-benchmark 9 | redis-check-aof 10 | redis-check-rdb 11 | redis-check-dump 12 | redis-cli 13 | redis-sentinel 14 | redis-server 15 | doc-tools 16 | release 17 | misc/* 18 | src/release.h 19 | appendonly.aof* 20 | appendonlydir 21 | SHORT_TERM_TODO 22 | release.h 23 | src/transfer.sh 24 | src/configs 25 | redis.ds 26 | src/redis.conf 27 | src/nodes.conf 28 | deps/lua/src/lua 29 | deps/lua/src/luac 30 | deps/lua/src/liblua.a 31 | deps/hdr_histogram/libhdrhistogram.a 32 | deps/fpconv/libfpconv.a 33 | tests/tls/* 34 | .make-* 35 | .prerequisites 36 | *.dSYM 37 | Makefile.dep 38 | .vscode/* 39 | .idea/* 40 | .ccls 41 | .ccls-cache/* 42 | compile_commands.json 43 | redis.code-workspace 44 | -------------------------------------------------------------------------------- /src/commands/echo.json: -------------------------------------------------------------------------------- 1 | { 2 | "ECHO": { 3 | "summary": "Returns the given string.", 4 | "complexity": "O(1)", 5 | "group": "connection", 6 | "since": "1.0.0", 7 | "arity": 2, 8 | "function": "echoCommand", 9 | "command_flags": [ 10 | "LOADING", 11 | "STALE", 12 | "FAST" 13 | ], 14 | "acl_categories": [ 15 | "CONNECTION" 16 | ], 17 | "reply_schema": { 18 | "description": "The given string", 19 | "type": "string" 20 | }, 21 | "arguments": [ 22 | { 23 | "name": "message", 24 | "type": "string" 25 | } 26 | ] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/commands/psubscribe.json: -------------------------------------------------------------------------------- 1 | { 2 | "PSUBSCRIBE": { 3 | "summary": "Listens for messages published to channels that match one or more patterns.", 4 | "complexity": "O(N) where N is the number of patterns to subscribe to.", 5 | "group": "pubsub", 6 | "since": "2.0.0", 7 | "arity": -2, 8 | "function": "psubscribeCommand", 9 | "command_flags": [ 10 | "PUBSUB", 11 | "NOSCRIPT", 12 | "LOADING", 13 | "STALE", 14 | "SENTINEL" 15 | ], 16 | "arguments": [ 17 | { 18 | "name": "pattern", 19 | "type": "pattern", 20 | "multiple": true 21 | } 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/commands/dbsize.json: -------------------------------------------------------------------------------- 1 | { 2 | "DBSIZE": { 3 | "summary": "Returns the number of keys in the database.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "1.0.0", 7 | "arity": 1, 8 | "function": "dbsizeCommand", 9 | "command_flags": [ 10 | "READONLY", 11 | "FAST" 12 | ], 13 | "acl_categories": [ 14 | "KEYSPACE" 15 | ], 16 | "command_tips": [ 17 | "REQUEST_POLICY:ALL_SHARDS", 18 | "RESPONSE_POLICY:AGG_SUM" 19 | ], 20 | "reply_schema": { 21 | "type": "integer", 22 | "description": "The number of keys in the currently-selected database." 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/commands/acl-save.json: -------------------------------------------------------------------------------- 1 | { 2 | "SAVE": { 3 | "summary": "Saves the effective ACL rules in the configured ACL file.", 4 | "complexity": "O(N). Where N is the number of configured users.", 5 | "group": "server", 6 | "since": "6.0.0", 7 | "arity": 2, 8 | "container": "ACL", 9 | "function": "aclCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "NOSCRIPT", 13 | "LOADING", 14 | "STALE", 15 | "SENTINEL" 16 | ], 17 | "command_tips": [ 18 | "REQUEST_POLICY:ALL_NODES", 19 | "RESPONSE_POLICY:ALL_SUCCEEDED" 20 | ], 21 | "reply_schema": { 22 | "const": "OK" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/commands/cluster-countkeysinslot.json: -------------------------------------------------------------------------------- 1 | { 2 | "COUNTKEYSINSLOT": { 3 | "summary": "Returns the number of keys in a hash slot.", 4 | "complexity": "O(1)", 5 | "group": "cluster", 6 | "since": "3.0.0", 7 | "arity": 3, 8 | "container": "CLUSTER", 9 | "function": "clusterCommand", 10 | "command_flags": [ 11 | "STALE" 12 | ], 13 | "arguments": [ 14 | { 15 | "name": "slot", 16 | "type": "integer" 17 | } 18 | ], 19 | "reply_schema": { 20 | "description": "The number of keys in the specified hash slot", 21 | "type": "integer", 22 | "minimum": 0 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/commands/client-help.json: -------------------------------------------------------------------------------- 1 | { 2 | "HELP": { 3 | "summary": "Returns helpful text about the different subcommands.", 4 | "complexity": "O(1)", 5 | "group": "connection", 6 | "since": "5.0.0", 7 | "arity": 2, 8 | "container": "CLIENT", 9 | "function": "clientCommand", 10 | "command_flags": [ 11 | "LOADING", 12 | "STALE", 13 | "SENTINEL" 14 | ], 15 | "acl_categories": [ 16 | "CONNECTION" 17 | ], 18 | "reply_schema": { 19 | "type": "array", 20 | "description": "Helpful text about subcommands.", 21 | "items": { 22 | "type": "string" 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/commands/unsubscribe.json: -------------------------------------------------------------------------------- 1 | { 2 | "UNSUBSCRIBE": { 3 | "summary": "Stops listening to messages posted to channels.", 4 | "complexity": "O(N) where N is the number of channels to unsubscribe.", 5 | "group": "pubsub", 6 | "since": "2.0.0", 7 | "arity": -1, 8 | "function": "unsubscribeCommand", 9 | "command_flags": [ 10 | "PUBSUB", 11 | "NOSCRIPT", 12 | "LOADING", 13 | "STALE", 14 | "SENTINEL" 15 | ], 16 | "arguments": [ 17 | { 18 | "name": "channel", 19 | "type": "string", 20 | "optional": true, 21 | "multiple": true 22 | } 23 | ] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /utils/hyperloglog/hll-err.rb: -------------------------------------------------------------------------------- 1 | # hll-err.rb - Copyright (C) 2014 Salvatore Sanfilippo 2 | # BSD license, See the COPYING file for more information. 3 | # 4 | # Check error of HyperLogLog Redis implementation for different set sizes. 5 | 6 | require 'rubygems' 7 | require 'redis' 8 | require 'digest/sha1' 9 | 10 | r = Redis.new 11 | r.del('hll') 12 | i = 0 13 | while true do 14 | 100.times { 15 | elements = [] 16 | 1000.times { 17 | ele = Digest::SHA1.hexdigest(i.to_s) 18 | elements << ele 19 | i += 1 20 | } 21 | r.pfadd('hll',elements) 22 | } 23 | approx = r.pfcount('hll') 24 | abs_err = (approx-i).abs 25 | rel_err = 100.to_f*abs_err/i 26 | puts "#{i} vs #{approx}: #{rel_err}%" 27 | end 28 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/arena_inlines_a.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_ARENA_INLINES_A_H 2 | #define JEMALLOC_INTERNAL_ARENA_INLINES_A_H 3 | 4 | static inline unsigned 5 | arena_ind_get(const arena_t *arena) { 6 | return arena->ind; 7 | } 8 | 9 | static inline void 10 | arena_internal_add(arena_t *arena, size_t size) { 11 | atomic_fetch_add_zu(&arena->stats.internal, size, ATOMIC_RELAXED); 12 | } 13 | 14 | static inline void 15 | arena_internal_sub(arena_t *arena, size_t size) { 16 | atomic_fetch_sub_zu(&arena->stats.internal, size, ATOMIC_RELAXED); 17 | } 18 | 19 | static inline size_t 20 | arena_internal_get(arena_t *arena) { 21 | return atomic_load_zu(&arena->stats.internal, ATOMIC_RELAXED); 22 | } 23 | 24 | #endif /* JEMALLOC_INTERNAL_ARENA_INLINES_A_H */ 25 | -------------------------------------------------------------------------------- /deps/lua/test/bisect.lua: -------------------------------------------------------------------------------- 1 | -- bisection method for solving non-linear equations 2 | 3 | delta=1e-6 -- tolerance 4 | 5 | function bisect(f,a,b,fa,fb) 6 | local c=(a+b)/2 7 | io.write(n," c=",c," a=",a," b=",b,"\n") 8 | if c==a or c==b or math.abs(a-b) 5 | 6 | class ExampleQt : public QObject { 7 | 8 | Q_OBJECT 9 | 10 | public: 11 | ExampleQt(const char * value, QObject * parent = 0) 12 | : QObject(parent), m_value(value) {} 13 | 14 | signals: 15 | void finished(); 16 | 17 | public slots: 18 | void run(); 19 | 20 | private: 21 | void finish() { emit finished(); } 22 | 23 | private: 24 | const char * m_value; 25 | redisAsyncContext * m_ctx; 26 | RedisQtAdapter m_adapter; 27 | 28 | friend 29 | void getCallback(redisAsyncContext *, void *, void *); 30 | }; 31 | 32 | #endif /* !__HIREDIS_EXAMPLE_QT_H */ 33 | -------------------------------------------------------------------------------- /src/commands/cluster-delslots.json: -------------------------------------------------------------------------------- 1 | { 2 | "DELSLOTS": { 3 | "summary": "Sets hash slots as unbound for a node.", 4 | "complexity": "O(N) where N is the total number of hash slot arguments", 5 | "group": "cluster", 6 | "since": "3.0.0", 7 | "arity": -3, 8 | "container": "CLUSTER", 9 | "function": "clusterCommand", 10 | "command_flags": [ 11 | "NO_ASYNC_LOADING", 12 | "ADMIN", 13 | "STALE" 14 | ], 15 | "arguments": [ 16 | { 17 | "name": "slot", 18 | "type": "integer", 19 | "multiple": true 20 | } 21 | ], 22 | "reply_schema": { 23 | "const": "OK" 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/commands/lastsave.json: -------------------------------------------------------------------------------- 1 | { 2 | "LASTSAVE": { 3 | "summary": "Returns the Unix timestamp of the last successful save to disk.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "1.0.0", 7 | "arity": 1, 8 | "function": "lastsaveCommand", 9 | "command_flags": [ 10 | "LOADING", 11 | "STALE", 12 | "FAST" 13 | ], 14 | "command_tips": [ 15 | "NONDETERMINISTIC_OUTPUT" 16 | ], 17 | "acl_categories": [ 18 | "ADMIN", 19 | "DANGEROUS" 20 | ], 21 | "reply_schema": { 22 | "type": "integer", 23 | "description": "UNIX TIME of the last DB save executed with success." 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /utils/graphs/commits-over-time/README.md: -------------------------------------------------------------------------------- 1 | This Tcl script is what I used in order to generate the graph you 2 | can find at http://antirez.com/news/98. It's really quick & dirty, more 3 | a trow away program than anything else, but probably could be reused or 4 | modified in the future in order to visualize other similar data or an 5 | updated version of the same data. 6 | 7 | The usage is trivial: 8 | 9 | ./genhtml.tcl > output.html 10 | 11 | The generated HTML is quite broken but good enough to grab a screenshot 12 | from the browser. Feel free to improve it if you got time / interest. 13 | 14 | Note that the code filtering the tags, and the hardcoded branch name, does 15 | not make the script, as it is, able to analyze a different repository. 16 | However the changes needed are trivial. 17 | -------------------------------------------------------------------------------- /deps/lua/test/fib.lua: -------------------------------------------------------------------------------- 1 | -- fibonacci function with cache 2 | 3 | -- very inefficient fibonacci function 4 | function fib(n) 5 | N=N+1 6 | if n<2 then 7 | return n 8 | else 9 | return fib(n-1)+fib(n-2) 10 | end 11 | end 12 | 13 | -- a general-purpose value cache 14 | function cache(f) 15 | local c={} 16 | return function (x) 17 | local y=c[x] 18 | if not y then 19 | y=f(x) 20 | c[x]=y 21 | end 22 | return y 23 | end 24 | end 25 | 26 | -- run and time it 27 | function test(s,f) 28 | N=0 29 | local c=os.clock() 30 | local v=f(n) 31 | local t=os.clock()-c 32 | print(s,n,v,t,N) 33 | end 34 | 35 | n=arg[1] or 24 -- for other values, do lua fib.lua XX 36 | n=tonumber(n) 37 | print("","n","value","time","evals") 38 | test("plain",fib) 39 | fib=cache(fib) 40 | test("cached",fib) 41 | -------------------------------------------------------------------------------- /tests/sentinel/tests/includes/utils.tcl: -------------------------------------------------------------------------------- 1 | proc restart_killed_instances {} { 2 | foreach type {redis sentinel} { 3 | foreach_${type}_id id { 4 | if {[get_instance_attrib $type $id pid] == -1} { 5 | puts -nonewline "$type/$id " 6 | flush stdout 7 | restart_instance $type $id 8 | } 9 | } 10 | } 11 | } 12 | 13 | proc verify_sentinel_auto_discovery {} { 14 | set sentinels [llength $::sentinel_instances] 15 | foreach_sentinel_id id { 16 | wait_for_condition 1000 50 { 17 | [dict get [S $id SENTINEL MASTER mymaster] num-other-sentinels] == ($sentinels-1) 18 | } else { 19 | fail "At least some sentinel can't detect some other sentinel" 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /deps/jemalloc/scripts/windows/before_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then 6 | echo "Incorrect \$TRAVIS_OS_NAME: expected windows, got $TRAVIS_OS_NAME" 7 | exit 1 8 | fi 9 | 10 | $build_env autoconf 11 | $build_env ./configure $CONFIGURE_FLAGS 12 | # mingw32-make simply means "make", unrelated to mingw32 vs mingw64. 13 | # Simply disregard the prefix and treat is as "make". 14 | $build_env mingw32-make -j3 15 | # At the moment, it's impossible to make tests in parallel, 16 | # seemingly due to concurrent writes to '.pdb' file. I don't know why 17 | # that happens, because we explicitly supply '/Fs' to the compiler. 18 | # Until we figure out how to fix it, we should build tests sequentially 19 | # on Windows. 20 | $build_env mingw32-make tests 21 | -------------------------------------------------------------------------------- /deps/lua/etc/lua.pc: -------------------------------------------------------------------------------- 1 | # lua.pc -- pkg-config data for Lua 2 | 3 | # vars from install Makefile 4 | 5 | # grep '^V=' ../Makefile 6 | V= 5.1 7 | # grep '^R=' ../Makefile 8 | R= 5.1.5 9 | 10 | # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/' 11 | prefix= /usr/local 12 | INSTALL_BIN= ${prefix}/bin 13 | INSTALL_INC= ${prefix}/include 14 | INSTALL_LIB= ${prefix}/lib 15 | INSTALL_MAN= ${prefix}/man/man1 16 | INSTALL_LMOD= ${prefix}/share/lua/${V} 17 | INSTALL_CMOD= ${prefix}/lib/lua/${V} 18 | 19 | # canonical vars 20 | exec_prefix=${prefix} 21 | libdir=${exec_prefix}/lib 22 | includedir=${prefix}/include 23 | 24 | Name: Lua 25 | Description: An Extensible Extension Language 26 | Version: ${R} 27 | Requires: 28 | Libs: -L${libdir} -llua -lm 29 | Cflags: -I${includedir} 30 | 31 | # (end of lua.pc) 32 | -------------------------------------------------------------------------------- /src/commands/quit.json: -------------------------------------------------------------------------------- 1 | { 2 | "QUIT": { 3 | "summary": "Closes the connection.", 4 | "complexity": "O(1)", 5 | "group": "connection", 6 | "since": "1.0.0", 7 | "arity": -1, 8 | "function": "quitCommand", 9 | "deprecated_since": "7.2.0", 10 | "replaced_by": "just closing the connection", 11 | "doc_flags": [ 12 | "DEPRECATED" 13 | ], 14 | "command_flags": [ 15 | "ALLOW_BUSY", 16 | "NOSCRIPT", 17 | "LOADING", 18 | "STALE", 19 | "FAST", 20 | "NO_AUTH" 21 | ], 22 | "acl_categories": [ 23 | "CONNECTION" 24 | ], 25 | "reply_schema": { 26 | "const": "OK" 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/commands.c: -------------------------------------------------------------------------------- 1 | #include "commands.h" 2 | #include "server.h" 3 | 4 | #define MAKE_CMD(name,summary,complexity,since,doc_flags,replaced,deprecated,group,group_enum,history,num_history,tips,num_tips,function,arity,flags,acl,key_specs,key_specs_num,get_keys,numargs) name,summary,complexity,since,doc_flags,replaced,deprecated,group_enum,history,num_history,tips,num_tips,function,arity,flags,acl,key_specs,key_specs_num,get_keys,numargs 5 | #define MAKE_ARG(name,type,key_spec_index,token,summary,since,flags,numsubargs,deprecated_since) name,type,key_spec_index,token,summary,since,flags,deprecated_since,numsubargs 6 | #define COMMAND_STRUCT redisCommand 7 | #define COMMAND_ARG redisCommandArg 8 | 9 | #ifdef LOG_REQ_RES 10 | #include "commands_with_reply_schema.def" 11 | #else 12 | #include "commands.def" 13 | #endif 14 | -------------------------------------------------------------------------------- /src/commands/sentinel-failover.json: -------------------------------------------------------------------------------- 1 | { 2 | "FAILOVER": { 3 | "summary": "Forces a Redis Sentinel failover.", 4 | "group": "sentinel", 5 | "since": "2.8.4", 6 | "arity": 3, 7 | "container": "SENTINEL", 8 | "function": "sentinelCommand", 9 | "command_flags": [ 10 | "ADMIN", 11 | "SENTINEL", 12 | "ONLY_SENTINEL" 13 | ], 14 | "reply_schema": { 15 | "const": "OK", 16 | "description": "Force a fail over as if the master was not reachable, and without asking for agreement to other Sentinels." 17 | }, 18 | "arguments": [ 19 | { 20 | "name": "master-name", 21 | "type": "string" 22 | } 23 | ] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /utils/whatisdoing.sh: -------------------------------------------------------------------------------- 1 | # This script is from http://poormansprofiler.org/ 2 | # 3 | # NOTE: Instead of using this script, you should use the Redis 4 | # Software Watchdog, which provides a similar functionality but in 5 | # a more reliable / easy to use way. 6 | # 7 | # Check https://redis.io/topics/latency for more information. 8 | 9 | #!/bin/bash 10 | nsamples=1 11 | sleeptime=0 12 | pid=$(ps auxww | grep '[r]edis-server' | awk '{print $2}') 13 | 14 | for x in $(seq 1 $nsamples) 15 | do 16 | gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $pid 17 | sleep $sleeptime 18 | done | \ 19 | awk ' 20 | BEGIN { s = ""; } 21 | /Thread/ { print s; s = ""; } 22 | /^\#/ { if (s != "" ) { s = s "," $4} else { s = $4 } } 23 | END { print s }' | \ 24 | sort | uniq -c | sort -r -n -k 1,1 25 | -------------------------------------------------------------------------------- /src/commands/punsubscribe.json: -------------------------------------------------------------------------------- 1 | { 2 | "PUNSUBSCRIBE": { 3 | "summary": "Stops listening to messages published to channels that match one or more patterns.", 4 | "complexity": "O(N) where N is the number of patterns to unsubscribe.", 5 | "group": "pubsub", 6 | "since": "2.0.0", 7 | "arity": -1, 8 | "function": "punsubscribeCommand", 9 | "command_flags": [ 10 | "PUBSUB", 11 | "NOSCRIPT", 12 | "LOADING", 13 | "STALE", 14 | "SENTINEL" 15 | ], 16 | "arguments": [ 17 | { 18 | "name": "pattern", 19 | "type": "pattern", 20 | "optional": true, 21 | "multiple": true 22 | } 23 | ] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/commands/slowlog-len.json: -------------------------------------------------------------------------------- 1 | { 2 | "LEN": { 3 | "summary": "Returns the number of entries in the slow log.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "2.2.12", 7 | "arity": 2, 8 | "container": "SLOWLOG", 9 | "function": "slowlogCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "LOADING", 13 | "STALE" 14 | ], 15 | "command_tips": [ 16 | "REQUEST_POLICY:ALL_NODES", 17 | "RESPONSE_POLICY:AGG_SUM", 18 | "NONDETERMINISTIC_OUTPUT" 19 | ], 20 | "reply_schema": { 21 | "type": "integer", 22 | "description": "Number of entries in the slow log.", 23 | "minimum": 0 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/commands/latency-doctor.json: -------------------------------------------------------------------------------- 1 | { 2 | "DOCTOR": { 3 | "summary": "Returns a human-readable latency analysis report.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "2.8.13", 7 | "arity": 2, 8 | "container": "LATENCY", 9 | "function": "latencyCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "NOSCRIPT", 13 | "LOADING", 14 | "STALE" 15 | ], 16 | "command_tips": [ 17 | "NONDETERMINISTIC_OUTPUT", 18 | "REQUEST_POLICY:ALL_NODES", 19 | "RESPONSE_POLICY:SPECIAL" 20 | ], 21 | "reply_schema": { 22 | "type": "string", 23 | "description": "A human readable latency analysis report." 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/commands/sentinel-reset.json: -------------------------------------------------------------------------------- 1 | { 2 | "RESET": { 3 | "summary": "Resets Redis masters by name matching a pattern.", 4 | "complexity": "O(N) where N is the number of monitored masters", 5 | "group": "sentinel", 6 | "since": "2.8.4", 7 | "arity": 3, 8 | "container": "SENTINEL", 9 | "function": "sentinelCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "SENTINEL", 13 | "ONLY_SENTINEL" 14 | ], 15 | "reply_schema": { 16 | "type": "integer", 17 | "description": "The number of masters that were reset." 18 | }, 19 | "arguments": [ 20 | { 21 | "name": "pattern", 22 | "type": "pattern" 23 | } 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/spin.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_SPIN_H 2 | #define JEMALLOC_INTERNAL_SPIN_H 3 | 4 | #define SPIN_INITIALIZER {0U} 5 | 6 | typedef struct { 7 | unsigned iteration; 8 | } spin_t; 9 | 10 | static inline void 11 | spin_cpu_spinwait() { 12 | # if HAVE_CPU_SPINWAIT 13 | CPU_SPINWAIT; 14 | # else 15 | volatile int x = 0; 16 | x = x; 17 | # endif 18 | } 19 | 20 | static inline void 21 | spin_adaptive(spin_t *spin) { 22 | volatile uint32_t i; 23 | 24 | if (spin->iteration < 5) { 25 | for (i = 0; i < (1U << spin->iteration); i++) { 26 | spin_cpu_spinwait(); 27 | } 28 | spin->iteration++; 29 | } else { 30 | #ifdef _WIN32 31 | SwitchToThread(); 32 | #else 33 | sched_yield(); 34 | #endif 35 | } 36 | } 37 | 38 | #undef SPIN_INLINE 39 | 40 | #endif /* JEMALLOC_INTERNAL_SPIN_H */ 41 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/div.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #include "jemalloc/internal/div.h" 4 | 5 | TEST_BEGIN(test_div_exhaustive) { 6 | for (size_t divisor = 2; divisor < 1000 * 1000; ++divisor) { 7 | div_info_t div_info; 8 | div_init(&div_info, divisor); 9 | size_t max = 1000 * divisor; 10 | if (max < 1000 * 1000) { 11 | max = 1000 * 1000; 12 | } 13 | for (size_t dividend = 0; dividend < 1000 * divisor; 14 | dividend += divisor) { 15 | size_t quotient = div_compute( 16 | &div_info, dividend); 17 | expect_zu_eq(dividend, quotient * divisor, 18 | "With divisor = %zu, dividend = %zu, " 19 | "got quotient %zu", divisor, dividend, quotient); 20 | } 21 | } 22 | } 23 | TEST_END 24 | 25 | int 26 | main(void) { 27 | return test_no_reentrancy( 28 | test_div_exhaustive); 29 | } 30 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/malloc_conf_2.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | const char *malloc_conf = "dirty_decay_ms:1000"; 4 | const char *malloc_conf_2_conf_harder = "dirty_decay_ms:1234"; 5 | 6 | TEST_BEGIN(test_malloc_conf_2) { 7 | #ifdef _WIN32 8 | bool windows = true; 9 | #else 10 | bool windows = false; 11 | #endif 12 | /* Windows doesn't support weak symbol linker trickery. */ 13 | test_skip_if(windows); 14 | 15 | ssize_t dirty_decay_ms; 16 | size_t sz = sizeof(dirty_decay_ms); 17 | 18 | int err = mallctl("opt.dirty_decay_ms", &dirty_decay_ms, &sz, NULL, 0); 19 | assert_d_eq(err, 0, "Unexpected mallctl failure"); 20 | expect_zd_eq(dirty_decay_ms, 1234, 21 | "malloc_conf_2 setting didn't take effect"); 22 | } 23 | TEST_END 24 | 25 | int 26 | main(void) { 27 | return test( 28 | test_malloc_conf_2); 29 | } 30 | -------------------------------------------------------------------------------- /tests/unit/moduleapi/infra.tcl: -------------------------------------------------------------------------------- 1 | set testmodule [file normalize tests/modules/infotest.so] 2 | 3 | test {modules config rewrite} { 4 | 5 | start_server {tags {"modules"}} { 6 | r module load $testmodule 7 | 8 | set modules [lmap x [r module list] {dict get $x name}] 9 | assert_not_equal [lsearch $modules infotest] -1 10 | 11 | r config rewrite 12 | restart_server 0 true false 13 | 14 | set modules [lmap x [r module list] {dict get $x name}] 15 | assert_not_equal [lsearch $modules infotest] -1 16 | 17 | assert_equal {OK} [r module unload infotest] 18 | 19 | r config rewrite 20 | restart_server 0 true false 21 | 22 | set modules [lmap x [r module list] {dict get $x name}] 23 | assert_equal [lsearch $modules infotest] -1 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/commands/client-info.json: -------------------------------------------------------------------------------- 1 | { 2 | "INFO": { 3 | "summary": "Returns information about the connection.", 4 | "complexity": "O(1)", 5 | "group": "connection", 6 | "since": "6.2.0", 7 | "arity": 2, 8 | "container": "CLIENT", 9 | "function": "clientCommand", 10 | "command_flags": [ 11 | "NOSCRIPT", 12 | "LOADING", 13 | "STALE", 14 | "SENTINEL" 15 | ], 16 | "acl_categories": [ 17 | "CONNECTION" 18 | ], 19 | "command_tips": [ 20 | "NONDETERMINISTIC_OUTPUT" 21 | ], 22 | "reply_schema": { 23 | "description": "a unique string, as described at the CLIENT LIST page, for the current client", 24 | "type": "string" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/unit/moduleapi/eventloop.tcl: -------------------------------------------------------------------------------- 1 | set testmodule [file normalize tests/modules/eventloop.so] 2 | 3 | start_server {tags {"modules"}} { 4 | r module load $testmodule 5 | 6 | test "Module eventloop sendbytes" { 7 | assert_match "OK" [r test.sendbytes 5000000] 8 | assert_match "OK" [r test.sendbytes 2000000] 9 | } 10 | 11 | test "Module eventloop iteration" { 12 | set iteration [r test.iteration] 13 | set next_iteration [r test.iteration] 14 | assert {$next_iteration > $iteration} 15 | } 16 | 17 | test "Module eventloop sanity" { 18 | r test.sanity 19 | } 20 | 21 | test "Module eventloop oneshot" { 22 | r test.oneshot 23 | } 24 | 25 | test "Unload the module - eventloop" { 26 | assert_equal {OK} [r module unload eventloop] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/commands/time.json: -------------------------------------------------------------------------------- 1 | { 2 | "TIME": { 3 | "summary": "Returns the server time.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "2.6.0", 7 | "arity": 1, 8 | "function": "timeCommand", 9 | "command_flags": [ 10 | "LOADING", 11 | "STALE", 12 | "FAST" 13 | ], 14 | "command_tips": [ 15 | "NONDETERMINISTIC_OUTPUT" 16 | ], 17 | "reply_schema": { 18 | "type": "array", 19 | "description": "Array containing two elements: Unix time in seconds and microseconds.", 20 | "minItems": 2, 21 | "maxItems": 2, 22 | "items": { 23 | "type": "string", 24 | "pattern": "[0-9]+" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/prof_hook.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_PROF_HOOK_H 2 | #define JEMALLOC_INTERNAL_PROF_HOOK_H 3 | 4 | /* 5 | * The hooks types of which are declared in this file are experimental and 6 | * undocumented, thus the typedefs are located in an 'internal' header. 7 | */ 8 | 9 | /* 10 | * A hook to mock out backtrace functionality. This can be handy, since it's 11 | * otherwise difficult to guarantee that two allocations are reported as coming 12 | * from the exact same stack trace in the presence of an optimizing compiler. 13 | */ 14 | typedef void (*prof_backtrace_hook_t)(void **, unsigned *, unsigned); 15 | 16 | /* 17 | * A callback hook that notifies about recently dumped heap profile. 18 | */ 19 | typedef void (*prof_dump_hook_t)(const char *filename); 20 | 21 | #endif /* JEMALLOC_INTERNAL_PROF_HOOK_H */ 22 | -------------------------------------------------------------------------------- /utils/lru/README: -------------------------------------------------------------------------------- 1 | The test-lru.rb program can be used in order to check the behavior of the 2 | Redis approximated LRU algorithm against the theoretical output of true 3 | LRU algorithm. 4 | 5 | In order to use the program you need to recompile Redis setting the define 6 | REDIS_LRU_CLOCK_RESOLUTION to 1, by editing the file server.h. 7 | This allows to execute the program in a fast way since the 1 ms resolution 8 | is enough for all the objects to have a different enough time stamp during 9 | the test. 10 | 11 | The program is executed like this: 12 | 13 | ruby test-lru.rb /tmp/lru.html 14 | 15 | You can optionally specify a number of times to run, so that the program 16 | will output averages of different runs, by adding an additional argument. 17 | For instance in order to run the test 10 times use: 18 | 19 | ruby test-lru.rb /tmp/lru.html 10 20 | -------------------------------------------------------------------------------- /deps/lua/etc/all.c: -------------------------------------------------------------------------------- 1 | /* 2 | * all.c -- Lua core, libraries and interpreter in a single file 3 | */ 4 | 5 | #define luaall_c 6 | 7 | #include "lapi.c" 8 | #include "lcode.c" 9 | #include "ldebug.c" 10 | #include "ldo.c" 11 | #include "ldump.c" 12 | #include "lfunc.c" 13 | #include "lgc.c" 14 | #include "llex.c" 15 | #include "lmem.c" 16 | #include "lobject.c" 17 | #include "lopcodes.c" 18 | #include "lparser.c" 19 | #include "lstate.c" 20 | #include "lstring.c" 21 | #include "ltable.c" 22 | #include "ltm.c" 23 | #include "lundump.c" 24 | #include "lvm.c" 25 | #include "lzio.c" 26 | 27 | #include "lauxlib.c" 28 | #include "lbaselib.c" 29 | #include "ldblib.c" 30 | #include "liolib.c" 31 | #include "linit.c" 32 | #include "lmathlib.c" 33 | #include "loadlib.c" 34 | #include "loslib.c" 35 | #include "lstrlib.c" 36 | #include "ltablib.c" 37 | 38 | #include "lua.c" 39 | -------------------------------------------------------------------------------- /deps/hiredis/appveyor.yml: -------------------------------------------------------------------------------- 1 | # Appveyor configuration file for CI build of hiredis on Windows (under Cygwin) 2 | environment: 3 | matrix: 4 | - CYG_BASH: C:\cygwin64\bin\bash 5 | CC: gcc 6 | - CYG_BASH: C:\cygwin\bin\bash 7 | CC: gcc 8 | CFLAGS: -m32 9 | CXXFLAGS: -m32 10 | LDFLAGS: -m32 11 | 12 | clone_depth: 1 13 | 14 | # Attempt to ensure we don't try to convert line endings to Win32 CRLF as this will cause build to fail 15 | init: 16 | - git config --global core.autocrlf input 17 | 18 | # Install needed build dependencies 19 | install: 20 | - '%CYG_BASH% -lc "cygcheck -dc cygwin"' 21 | 22 | build_script: 23 | - 'echo building...' 24 | - '%CYG_BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0 /dev/null; then 11 | CLANG_FORMAT="clang-format" 12 | elif command -v clang-format-8 &> /dev/null; then 13 | CLANG_FORMAT="clang-format-8" 14 | else 15 | echo "Couldn't find clang-format." 16 | fi 17 | 18 | if ! $CLANG_FORMAT -version | grep "version 8\." &> /dev/null; then 19 | echo "clang-format is the wrong version." 20 | exit 1 21 | fi 22 | 23 | for file in ${FILES[@]}; do 24 | if ! cmp --silent $file <($CLANG_FORMAT $file) &> /dev/null; then 25 | echo "Error: $file is not clang-formatted" 26 | exit 1 27 | fi 28 | done 29 | -------------------------------------------------------------------------------- /deps/lua/test/sieve.lua: -------------------------------------------------------------------------------- 1 | -- the sieve of of Eratosthenes programmed with coroutines 2 | -- typical usage: lua -e N=1000 sieve.lua | column 3 | 4 | -- generate all the numbers from 2 to n 5 | function gen (n) 6 | return coroutine.wrap(function () 7 | for i=2,n do coroutine.yield(i) end 8 | end) 9 | end 10 | 11 | -- filter the numbers generated by `g', removing multiples of `p' 12 | function filter (p, g) 13 | return coroutine.wrap(function () 14 | while 1 do 15 | local n = g() 16 | if n == nil then return end 17 | if math.mod(n, p) ~= 0 then coroutine.yield(n) end 18 | end 19 | end) 20 | end 21 | 22 | N=N or 1000 -- from command line 23 | x = gen(N) -- generate primes up to N 24 | while 1 do 25 | local n = x() -- pick a number until done 26 | if n == nil then break end 27 | print(n) -- must be a prime number 28 | x = filter(n, x) -- now remove its multiples 29 | end 30 | -------------------------------------------------------------------------------- /deps/lua/test/trace-calls.lua: -------------------------------------------------------------------------------- 1 | -- trace calls 2 | -- example: lua -ltrace-calls bisect.lua 3 | 4 | local level=0 5 | 6 | local function hook(event) 7 | local t=debug.getinfo(3) 8 | io.write(level," >>> ",string.rep(" ",level)) 9 | if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end 10 | t=debug.getinfo(2) 11 | if event=="call" then 12 | level=level+1 13 | else 14 | level=level-1 if level<0 then level=0 end 15 | end 16 | if t.what=="main" then 17 | if event=="call" then 18 | io.write("begin ",t.short_src) 19 | else 20 | io.write("end ",t.short_src) 21 | end 22 | elseif t.what=="Lua" then 23 | -- table.foreach(t,print) 24 | io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">") 25 | else 26 | io.write(event," ",t.name or "(C)"," [",t.what,"] ") 27 | end 28 | io.write("\n") 29 | end 30 | 31 | debug.sethook(hook,"cr") 32 | level=0 33 | -------------------------------------------------------------------------------- /deps/lua/test/trace-globals.lua: -------------------------------------------------------------------------------- 1 | -- trace assigments to global variables 2 | 3 | do 4 | -- a tostring that quotes strings. note the use of the original tostring. 5 | local _tostring=tostring 6 | local tostring=function(a) 7 | if type(a)=="string" then 8 | return string.format("%q",a) 9 | else 10 | return _tostring(a) 11 | end 12 | end 13 | 14 | local log=function (name,old,new) 15 | local t=debug.getinfo(3,"Sl") 16 | local line=t.currentline 17 | io.write(t.short_src) 18 | if line>=0 then io.write(":",line) end 19 | io.write(": ",name," is now ",tostring(new)," (was ",tostring(old),")","\n") 20 | end 21 | 22 | local g={} 23 | local set=function (t,name,value) 24 | log(name,g[name],value) 25 | g[name]=value 26 | end 27 | setmetatable(getfenv(),{__index=g,__newindex=set}) 28 | end 29 | 30 | -- an example 31 | 32 | a=1 33 | b=2 34 | a=10 35 | b=20 36 | b=nil 37 | b=200 38 | print(a,b,c) 39 | -------------------------------------------------------------------------------- /deps/jemalloc/test/src/thd.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #ifdef _WIN32 4 | void 5 | thd_create(thd_t *thd, void *(*proc)(void *), void *arg) { 6 | LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc; 7 | *thd = CreateThread(NULL, 0, routine, arg, 0, NULL); 8 | if (*thd == NULL) { 9 | test_fail("Error in CreateThread()\n"); 10 | } 11 | } 12 | 13 | void 14 | thd_join(thd_t thd, void **ret) { 15 | if (WaitForSingleObject(thd, INFINITE) == WAIT_OBJECT_0 && ret) { 16 | DWORD exit_code; 17 | GetExitCodeThread(thd, (LPDWORD) &exit_code); 18 | *ret = (void *)(uintptr_t)exit_code; 19 | } 20 | } 21 | 22 | #else 23 | void 24 | thd_create(thd_t *thd, void *(*proc)(void *), void *arg) { 25 | if (pthread_create(thd, NULL, proc, arg) != 0) { 26 | test_fail("Error in pthread_create()\n"); 27 | } 28 | } 29 | 30 | void 31 | thd_join(thd_t thd, void **ret) { 32 | pthread_join(thd, ret); 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/zero_realloc_free.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | static uint64_t 4 | deallocated() { 5 | if (!config_stats) { 6 | return 0; 7 | } 8 | uint64_t deallocated; 9 | size_t sz = sizeof(deallocated); 10 | expect_d_eq(mallctl("thread.deallocated", (void *)&deallocated, &sz, 11 | NULL, 0), 0, "Unexpected mallctl failure"); 12 | return deallocated; 13 | } 14 | 15 | TEST_BEGIN(test_realloc_free) { 16 | void *ptr = mallocx(42, 0); 17 | expect_ptr_not_null(ptr, "Unexpected mallocx error"); 18 | uint64_t deallocated_before = deallocated(); 19 | ptr = realloc(ptr, 0); 20 | uint64_t deallocated_after = deallocated(); 21 | expect_ptr_null(ptr, "Realloc didn't free"); 22 | if (config_stats) { 23 | expect_u64_gt(deallocated_after, deallocated_before, 24 | "Realloc didn't free"); 25 | } 26 | } 27 | TEST_END 28 | 29 | int 30 | main(void) { 31 | return test( 32 | test_realloc_free); 33 | } 34 | -------------------------------------------------------------------------------- /src/commands/client-setname.json: -------------------------------------------------------------------------------- 1 | { 2 | "SETNAME": { 3 | "summary": "Sets the connection name.", 4 | "complexity": "O(1)", 5 | "group": "connection", 6 | "since": "2.6.9", 7 | "arity": 3, 8 | "container": "CLIENT", 9 | "function": "clientCommand", 10 | "command_flags": [ 11 | "NOSCRIPT", 12 | "LOADING", 13 | "STALE", 14 | "SENTINEL" 15 | ], 16 | "command_tips": [ 17 | "REQUEST_POLICY:ALL_NODES", 18 | "RESPONSE_POLICY:ALL_SUCCEEDED" 19 | ], 20 | "acl_categories": [ 21 | "CONNECTION" 22 | ], 23 | "arguments": [ 24 | { 25 | "name": "connection-name", 26 | "type": "string" 27 | } 28 | ], 29 | "reply_schema": { 30 | "const": "OK" 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/commands/latency-graph.json: -------------------------------------------------------------------------------- 1 | { 2 | "GRAPH": { 3 | "summary": "Returns a latency graph for an event.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "2.8.13", 7 | "arity": 3, 8 | "container": "LATENCY", 9 | "function": "latencyCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "NOSCRIPT", 13 | "LOADING", 14 | "STALE" 15 | ], 16 | "command_tips": [ 17 | "NONDETERMINISTIC_OUTPUT", 18 | "REQUEST_POLICY:ALL_NODES", 19 | "RESPONSE_POLICY:SPECIAL" 20 | ], 21 | "arguments": [ 22 | { 23 | "name": "event", 24 | "type": "string" 25 | } 26 | ], 27 | "reply_schema": { 28 | "type": "string", 29 | "description": "Latency graph" 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/cluster/run.tcl: -------------------------------------------------------------------------------- 1 | # Cluster test suite. Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com 2 | # This software is released under the BSD License. See the COPYING file for 3 | # more information. 4 | 5 | cd tests/cluster 6 | source cluster.tcl 7 | source ../instances.tcl 8 | source ../../support/cluster.tcl ; # Redis Cluster client. 9 | 10 | set ::instances_count 20 ; # How many instances we use at max. 11 | set ::tlsdir "../../tls" 12 | 13 | proc main {} { 14 | parse_options 15 | spawn_instance redis $::redis_base_port $::instances_count { 16 | "cluster-enabled yes" 17 | "appendonly yes" 18 | "enable-protected-configs yes" 19 | "enable-debug-command yes" 20 | "save ''" 21 | } 22 | run_tests 23 | cleanup 24 | end_tests 25 | } 26 | 27 | if {[catch main e]} { 28 | puts $::errorInfo 29 | if {$::pause_on_error} pause_on_error 30 | cleanup 31 | exit 1 32 | } 33 | -------------------------------------------------------------------------------- /utils/generate-fmtargs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Outputs the generated part of src/fmtargs.h 4 | MAX_ARGS = 120 5 | 6 | import os 7 | print("/* Everything below this line is automatically generated by") 8 | print(" * %s. Do not manually edit. */\n" % os.path.basename(__file__)) 9 | 10 | print('#define ARG_N(' + ', '.join(['_' + str(i) for i in range(1, MAX_ARGS + 1, 1)]) + ', N, ...) N') 11 | 12 | print('\n#define RSEQ_N() ' + ', '.join([str(i) for i in range(MAX_ARGS, -1, -1)])) 13 | 14 | print('\n#define COMPACT_FMT_2(fmt, value) fmt') 15 | for i in range(4, MAX_ARGS + 1, 2): 16 | print('#define COMPACT_FMT_{}(fmt, value, ...) fmt COMPACT_FMT_{}(__VA_ARGS__)'.format(i, i - 2)) 17 | 18 | print('\n#define COMPACT_VALUES_2(fmt, value) value') 19 | for i in range(4, MAX_ARGS + 1, 2): 20 | print('#define COMPACT_VALUES_{}(fmt, value, ...) value, COMPACT_VALUES_{}(__VA_ARGS__)'.format(i, i - 2)) 21 | 22 | print("\n#endif") 23 | -------------------------------------------------------------------------------- /deps/lua/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Initialization of libraries for lua.c 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | #include "lua.h" 12 | 13 | #include "lualib.h" 14 | #include "lauxlib.h" 15 | 16 | 17 | static const luaL_Reg lualibs[] = { 18 | {"", luaopen_base}, 19 | {LUA_LOADLIBNAME, luaopen_package}, 20 | {LUA_TABLIBNAME, luaopen_table}, 21 | {LUA_IOLIBNAME, luaopen_io}, 22 | {LUA_OSLIBNAME, luaopen_os}, 23 | {LUA_STRLIBNAME, luaopen_string}, 24 | {LUA_MATHLIBNAME, luaopen_math}, 25 | {LUA_DBLIBNAME, luaopen_debug}, 26 | {NULL, NULL} 27 | }; 28 | 29 | 30 | LUALIB_API void luaL_openlibs (lua_State *L) { 31 | const luaL_Reg *lib = lualibs; 32 | for (; lib->func; lib++) { 33 | lua_pushcfunction(L, lib->func); 34 | lua_pushstring(L, lib->name); 35 | lua_call(L, 1, 0); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/sha1.h: -------------------------------------------------------------------------------- 1 | #ifndef SHA1_H 2 | #define SHA1_H 3 | /* ================ sha1.h ================ */ 4 | /* 5 | SHA-1 in C 6 | By Steve Reid 7 | 100% Public Domain 8 | */ 9 | 10 | typedef struct { 11 | uint32_t state[5]; 12 | uint32_t count[2]; 13 | unsigned char buffer[64]; 14 | } SHA1_CTX; 15 | 16 | void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]); 17 | void SHA1Init(SHA1_CTX* context); 18 | /* 'noinline' attribute is intended to prevent the `-Wstringop-overread` warning 19 | * when using gcc-12 later with LTO enabled. It may be removed once the 20 | * bug[https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80922] is fixed. */ 21 | __attribute__((noinline)) void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len); 22 | void SHA1Final(unsigned char digest[20], SHA1_CTX* context); 23 | 24 | #ifdef REDIS_TEST 25 | int sha1Test(int argc, char **argv, int flags); 26 | #endif 27 | #endif 28 | -------------------------------------------------------------------------------- /tests/assets/default.conf: -------------------------------------------------------------------------------- 1 | # Redis configuration for testing. 2 | 3 | always-show-logo yes 4 | notify-keyspace-events KEA 5 | daemonize no 6 | pidfile /var/run/redis.pid 7 | port 6379 8 | timeout 0 9 | bind 127.0.0.1 10 | loglevel verbose 11 | logfile '' 12 | databases 16 13 | latency-monitor-threshold 1 14 | repl-diskless-sync-delay 0 15 | 16 | # Turn off RDB by default (to speedup tests) 17 | # Note the infrastructure in server.tcl uses a dict, we can't provide several save directives 18 | save '' 19 | 20 | rdbcompression yes 21 | dbfilename dump.rdb 22 | dir ./ 23 | 24 | slave-serve-stale-data yes 25 | appendonly no 26 | appendfsync everysec 27 | no-appendfsync-on-rewrite no 28 | activerehashing yes 29 | 30 | enable-protected-configs yes 31 | enable-debug-command yes 32 | enable-module-command yes 33 | 34 | propagation-error-behavior panic 35 | 36 | # Make sure shutdown doesn't fail if there's an initial AOFRW 37 | shutdown-on-sigterm force 38 | -------------------------------------------------------------------------------- /tests/unit/quit.tcl: -------------------------------------------------------------------------------- 1 | start_server {tags {"quit"}} { 2 | 3 | test "QUIT returns OK" { 4 | reconnect 5 | assert_equal OK [r quit] 6 | assert_error * {r ping} 7 | } 8 | 9 | test "Pipelined commands after QUIT must not be executed" { 10 | reconnect 11 | r write [format_command quit] 12 | r write [format_command set foo bar] 13 | r flush 14 | assert_equal OK [r read] 15 | assert_error * {r read} 16 | 17 | reconnect 18 | assert_equal {} [r get foo] 19 | } 20 | 21 | test "Pipelined commands after QUIT that exceed read buffer size" { 22 | reconnect 23 | r write [format_command quit] 24 | r write [format_command set foo [string repeat "x" 1024]] 25 | r flush 26 | assert_equal OK [r read] 27 | assert_error * {r read} 28 | 29 | reconnect 30 | assert_equal {} [r get foo] 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/mkreleasehdr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | GIT_SHA1=`(git show-ref --head --hash=8 2> /dev/null || echo 00000000) | head -n1` 3 | GIT_DIRTY=`git diff --no-ext-diff 2> /dev/null | wc -l` 4 | BUILD_ID=`uname -n`"-"`date +%s` 5 | if [ -n "$SOURCE_DATE_EPOCH" ]; then 6 | BUILD_ID=$(date -u -d "@$SOURCE_DATE_EPOCH" +%s 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" +%s 2>/dev/null || date -u +%s) 7 | fi 8 | test -f release.h || touch release.h 9 | (cat release.h | grep SHA1 | grep $GIT_SHA1) && \ 10 | (cat release.h | grep DIRTY | grep $GIT_DIRTY) && exit 0 # Already up-to-date 11 | echo "#define REDIS_GIT_SHA1 \"$GIT_SHA1\"" > release.h 12 | echo "#define REDIS_GIT_DIRTY \"$GIT_DIRTY\"" >> release.h 13 | echo "#define REDIS_BUILD_ID \"$BUILD_ID\"" >> release.h 14 | echo "#include \"version.h\"" >> release.h 15 | echo "#define REDIS_BUILD_ID_RAW REDIS_VERSION REDIS_BUILD_ID REDIS_GIT_DIRTY REDIS_GIT_SHA1" >> release.h 16 | touch release.c # Force recompile of release.c 17 | -------------------------------------------------------------------------------- /tests/cluster/tests/01-faildet.tcl: -------------------------------------------------------------------------------- 1 | # Check the basic monitoring and failover capabilities. 2 | 3 | source "../tests/includes/init-tests.tcl" 4 | 5 | test "Create a 5 nodes cluster" { 6 | create_cluster 5 5 7 | } 8 | 9 | test "Cluster should start ok" { 10 | assert_cluster_state ok 11 | } 12 | 13 | test "Killing two slave nodes" { 14 | kill_instance redis 5 15 | kill_instance redis 6 16 | } 17 | 18 | test "Cluster should be still up" { 19 | assert_cluster_state ok 20 | } 21 | 22 | test "Killing one master node" { 23 | kill_instance redis 0 24 | } 25 | 26 | # Note: the only slave of instance 0 is already down so no 27 | # failover is possible, that would change the state back to ok. 28 | test "Cluster should be down now" { 29 | assert_cluster_state fail 30 | } 31 | 32 | test "Restarting master node" { 33 | restart_instance redis 0 34 | } 35 | 36 | test "Cluster should be up again" { 37 | assert_cluster_state ok 38 | } 39 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/activity_callback.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_ACTIVITY_CALLBACK_H 2 | #define JEMALLOC_INTERNAL_ACTIVITY_CALLBACK_H 3 | 4 | /* 5 | * The callback to be executed "periodically", in response to some amount of 6 | * allocator activity. 7 | * 8 | * This callback need not be computing any sort of peak (although that's the 9 | * intended first use case), but we drive it from the peak counter, so it's 10 | * keeps things tidy to keep it here. 11 | * 12 | * The calls to this thunk get driven by the peak_event module. 13 | */ 14 | #define ACTIVITY_CALLBACK_THUNK_INITIALIZER {NULL, NULL} 15 | typedef void (*activity_callback_t)(void *uctx, uint64_t allocated, 16 | uint64_t deallocated); 17 | typedef struct activity_callback_thunk_s activity_callback_thunk_t; 18 | struct activity_callback_thunk_s { 19 | activity_callback_t callback; 20 | void *uctx; 21 | }; 22 | 23 | #endif /* JEMALLOC_INTERNAL_ACTIVITY_CALLBACK_H */ 24 | -------------------------------------------------------------------------------- /deps/lua/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | 11 | #include "lgc.h" 12 | #include "lobject.h" 13 | #include "lstate.h" 14 | 15 | 16 | #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) 17 | 18 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) 19 | 20 | #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) 21 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 22 | (sizeof(s)/sizeof(char))-1)) 23 | 24 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) 25 | 26 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 27 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 28 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/commands/cluster-count-failure-reports.json: -------------------------------------------------------------------------------- 1 | { 2 | "COUNT-FAILURE-REPORTS": { 3 | "summary": "Returns the number of active failure reports active for a node.", 4 | "complexity": "O(N) where N is the number of failure reports", 5 | "group": "cluster", 6 | "since": "3.0.0", 7 | "arity": 3, 8 | "container": "CLUSTER", 9 | "function": "clusterCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "STALE" 13 | ], 14 | "command_tips": [ 15 | "NONDETERMINISTIC_OUTPUT" 16 | ], 17 | "arguments": [ 18 | { 19 | "name": "node-id", 20 | "type": "string" 21 | } 22 | ], 23 | "reply_schema": { 24 | "description": "the number of active failure reports for the node", 25 | "type": "integer", 26 | "minimum": 0 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /deps/jemalloc/src/counter.c: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_preamble.h" 2 | #include "jemalloc/internal/jemalloc_internal_includes.h" 3 | 4 | #include "jemalloc/internal/counter.h" 5 | 6 | bool 7 | counter_accum_init(counter_accum_t *counter, uint64_t interval) { 8 | if (LOCKEDINT_MTX_INIT(counter->mtx, "counter_accum", 9 | WITNESS_RANK_COUNTER_ACCUM, malloc_mutex_rank_exclusive)) { 10 | return true; 11 | } 12 | locked_init_u64_unsynchronized(&counter->accumbytes, 0); 13 | counter->interval = interval; 14 | return false; 15 | } 16 | 17 | void 18 | counter_prefork(tsdn_t *tsdn, counter_accum_t *counter) { 19 | LOCKEDINT_MTX_PREFORK(tsdn, counter->mtx); 20 | } 21 | 22 | void 23 | counter_postfork_parent(tsdn_t *tsdn, counter_accum_t *counter) { 24 | LOCKEDINT_MTX_POSTFORK_PARENT(tsdn, counter->mtx); 25 | } 26 | 27 | void 28 | counter_postfork_child(tsdn_t *tsdn, counter_accum_t *counter) { 29 | LOCKEDINT_MTX_POSTFORK_CHILD(tsdn, counter->mtx); 30 | } 31 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/test_hooks.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | static bool hook_called = false; 4 | 5 | static void 6 | hook() { 7 | hook_called = true; 8 | } 9 | 10 | static int 11 | func_to_hook(int arg1, int arg2) { 12 | return arg1 + arg2; 13 | } 14 | 15 | #define func_to_hook JEMALLOC_TEST_HOOK(func_to_hook, test_hooks_libc_hook) 16 | 17 | TEST_BEGIN(unhooked_call) { 18 | test_hooks_libc_hook = NULL; 19 | hook_called = false; 20 | expect_d_eq(3, func_to_hook(1, 2), "Hooking changed return value."); 21 | expect_false(hook_called, "Nulling out hook didn't take."); 22 | } 23 | TEST_END 24 | 25 | TEST_BEGIN(hooked_call) { 26 | test_hooks_libc_hook = &hook; 27 | hook_called = false; 28 | expect_d_eq(3, func_to_hook(1, 2), "Hooking changed return value."); 29 | expect_true(hook_called, "Hook should have executed."); 30 | } 31 | TEST_END 32 | 33 | int 34 | main(void) { 35 | return test( 36 | unhooked_call, 37 | hooked_call); 38 | } 39 | -------------------------------------------------------------------------------- /deps/jemalloc/test/include/test/btalloc.h: -------------------------------------------------------------------------------- 1 | /* btalloc() provides a mechanism for allocating via permuted backtraces. */ 2 | void *btalloc(size_t size, unsigned bits); 3 | 4 | #define btalloc_n_proto(n) \ 5 | void *btalloc_##n(size_t size, unsigned bits); 6 | btalloc_n_proto(0) 7 | btalloc_n_proto(1) 8 | 9 | #define btalloc_n_gen(n) \ 10 | void * \ 11 | btalloc_##n(size_t size, unsigned bits) { \ 12 | void *p; \ 13 | \ 14 | if (bits == 0) { \ 15 | p = mallocx(size, 0); \ 16 | } else { \ 17 | switch (bits & 0x1U) { \ 18 | case 0: \ 19 | p = (btalloc_0(size, bits >> 1)); \ 20 | break; \ 21 | case 1: \ 22 | p = (btalloc_1(size, bits >> 1)); \ 23 | break; \ 24 | default: not_reached(); \ 25 | } \ 26 | } \ 27 | /* Intentionally sabotage tail call optimization. */ \ 28 | expect_ptr_not_null(p, "Unexpected mallocx() failure"); \ 29 | return p; \ 30 | } 31 | -------------------------------------------------------------------------------- /deps/lua/etc/min.c: -------------------------------------------------------------------------------- 1 | /* 2 | * min.c -- a minimal Lua interpreter 3 | * loads stdin only with minimal error handling. 4 | * no interaction, and no standard library, only a "print" function. 5 | */ 6 | 7 | #include 8 | 9 | #include "lua.h" 10 | #include "lauxlib.h" 11 | 12 | static int print(lua_State *L) 13 | { 14 | int n=lua_gettop(L); 15 | int i; 16 | for (i=1; i<=n; i++) 17 | { 18 | if (i>1) printf("\t"); 19 | if (lua_isstring(L,i)) 20 | printf("%s",lua_tostring(L,i)); 21 | else if (lua_isnil(L,i)) 22 | printf("%s","nil"); 23 | else if (lua_isboolean(L,i)) 24 | printf("%s",lua_toboolean(L,i) ? "true" : "false"); 25 | else 26 | printf("%s:%p",luaL_typename(L,i),lua_topointer(L,i)); 27 | } 28 | printf("\n"); 29 | return 0; 30 | } 31 | 32 | int main(void) 33 | { 34 | lua_State *L=lua_open(); 35 | lua_register(L,"print",print); 36 | if (luaL_dofile(L,NULL)!=0) fprintf(stderr,"%s\n",lua_tostring(L,-1)); 37 | lua_close(L); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /src/commands/client-getname.json: -------------------------------------------------------------------------------- 1 | { 2 | "GETNAME": { 3 | "summary": "Returns the name of the connection.", 4 | "complexity": "O(1)", 5 | "group": "connection", 6 | "since": "2.6.9", 7 | "arity": 2, 8 | "container": "CLIENT", 9 | "function": "clientCommand", 10 | "command_flags": [ 11 | "NOSCRIPT", 12 | "LOADING", 13 | "STALE", 14 | "SENTINEL" 15 | ], 16 | "acl_categories": [ 17 | "CONNECTION" 18 | ], 19 | "reply_schema": { 20 | "oneOf": [ 21 | { 22 | "type": "string", 23 | "description": "The connection name of the current connection" 24 | }, 25 | { 26 | "type": "null", 27 | "description": "Connection name was not set" 28 | } 29 | ] 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/peak_event.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_PEAK_EVENT_H 2 | #define JEMALLOC_INTERNAL_PEAK_EVENT_H 3 | 4 | /* 5 | * While peak.h contains the simple helper struct that tracks state, this 6 | * contains the allocator tie-ins (and knows about tsd, the event module, etc.). 7 | */ 8 | 9 | /* Update the peak with current tsd state. */ 10 | void peak_event_update(tsd_t *tsd); 11 | /* Set current state to zero. */ 12 | void peak_event_zero(tsd_t *tsd); 13 | uint64_t peak_event_max(tsd_t *tsd); 14 | 15 | /* Manual hooks. */ 16 | /* The activity-triggered hooks. */ 17 | uint64_t peak_alloc_new_event_wait(tsd_t *tsd); 18 | uint64_t peak_alloc_postponed_event_wait(tsd_t *tsd); 19 | void peak_alloc_event_handler(tsd_t *tsd, uint64_t elapsed); 20 | uint64_t peak_dalloc_new_event_wait(tsd_t *tsd); 21 | uint64_t peak_dalloc_postponed_event_wait(tsd_t *tsd); 22 | void peak_dalloc_event_handler(tsd_t *tsd, uint64_t elapsed); 23 | 24 | #endif /* JEMALLOC_INTERNAL_PEAK_EVENT_H */ 25 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/thread_event.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_next_event_fast) { 4 | tsd_t *tsd = tsd_fetch(); 5 | te_ctx_t ctx; 6 | te_ctx_get(tsd, &ctx, true); 7 | 8 | te_ctx_last_event_set(&ctx, 0); 9 | te_ctx_current_bytes_set(&ctx, TE_NEXT_EVENT_FAST_MAX - 8U); 10 | te_ctx_next_event_set(tsd, &ctx, TE_NEXT_EVENT_FAST_MAX); 11 | #define E(event, condition, is_alloc) \ 12 | if (is_alloc && condition) { \ 13 | event##_event_wait_set(tsd, TE_NEXT_EVENT_FAST_MAX); \ 14 | } 15 | ITERATE_OVER_ALL_EVENTS 16 | #undef E 17 | 18 | /* Test next_event_fast rolling back to 0. */ 19 | void *p = malloc(16U); 20 | assert_ptr_not_null(p, "malloc() failed"); 21 | free(p); 22 | 23 | /* Test next_event_fast resuming to be equal to next_event. */ 24 | void *q = malloc(SC_LOOKUP_MAXCLASS); 25 | assert_ptr_not_null(q, "malloc() failed"); 26 | free(q); 27 | } 28 | TEST_END 29 | 30 | int 31 | main(void) { 32 | return test( 33 | test_next_event_fast); 34 | } 35 | -------------------------------------------------------------------------------- /src/commands/pubsub-numsub.json: -------------------------------------------------------------------------------- 1 | { 2 | "NUMSUB": { 3 | "summary": "Returns a count of subscribers to channels.", 4 | "complexity": "O(N) for the NUMSUB subcommand, where N is the number of requested channels", 5 | "group": "pubsub", 6 | "since": "2.8.0", 7 | "arity": -2, 8 | "container": "PUBSUB", 9 | "function": "pubsubCommand", 10 | "command_flags": [ 11 | "PUBSUB", 12 | "LOADING", 13 | "STALE" 14 | ], 15 | "arguments": [ 16 | { 17 | "name": "channel", 18 | "type": "string", 19 | "optional": true, 20 | "multiple": true 21 | } 22 | ], 23 | "reply_schema": { 24 | "description": "the number of subscribers per channel, each even element (including 0th) is channel name, each odd element is the number of subscribers", 25 | "type": "array" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/commands/latency-reset.json: -------------------------------------------------------------------------------- 1 | { 2 | "RESET": { 3 | "summary": "Resets the latency data for one or more events.", 4 | "complexity": "O(1)", 5 | "group": "server", 6 | "since": "2.8.13", 7 | "arity": -2, 8 | "container": "LATENCY", 9 | "function": "latencyCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "NOSCRIPT", 13 | "LOADING", 14 | "STALE" 15 | ], 16 | "command_tips": [ 17 | "REQUEST_POLICY:ALL_NODES", 18 | "RESPONSE_POLICY:AGG_SUM" 19 | ], 20 | "reply_schema": { 21 | "type": "integer", 22 | "description": "Number of event time series that were reset." 23 | }, 24 | "arguments": [ 25 | { 26 | "name": "event", 27 | "type": "string", 28 | "optional": true, 29 | "multiple": true 30 | } 31 | ] 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /.github/workflows/spell-check.yml: -------------------------------------------------------------------------------- 1 | # A CI action that using codespell to check spell. 2 | # .github/.codespellrc is a config file. 3 | # .github/wordlist.txt is a list of words that will ignore word checks. 4 | # More details please check the following link: 5 | # https://github.com/codespell-project/codespell 6 | name: Spellcheck 7 | 8 | on: 9 | push: 10 | pull_request: 11 | 12 | jobs: 13 | build: 14 | name: Spellcheck 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: Checkout repository 19 | uses: actions/checkout@v3 20 | 21 | - name: pip cache 22 | uses: actions/cache@v3 23 | with: 24 | path: ~/.cache/pip 25 | key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} 26 | restore-keys: ${{ runner.os }}-pip- 27 | 28 | - name: Install prerequisites 29 | run: sudo pip install -r ./.codespell/requirements.txt 30 | 31 | - name: Spell check 32 | run: codespell --config=./.codespell/.codespellrc 33 | -------------------------------------------------------------------------------- /src/commands/sentinel-monitor.json: -------------------------------------------------------------------------------- 1 | { 2 | "MONITOR": { 3 | "summary": "Starts monitoring.", 4 | "complexity": "O(1)", 5 | "group": "sentinel", 6 | "since": "2.8.4", 7 | "arity": 6, 8 | "container": "SENTINEL", 9 | "function": "sentinelCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "SENTINEL", 13 | "ONLY_SENTINEL" 14 | ], 15 | "reply_schema": { 16 | "const": "OK" 17 | }, 18 | "arguments": [ 19 | { 20 | "name": "name", 21 | "type": "string" 22 | }, 23 | { 24 | "name": "ip", 25 | "type": "string" 26 | }, 27 | { 28 | "name": "port", 29 | "type": "integer" 30 | }, 31 | { 32 | "name": "quorum", 33 | "type": "integer" 34 | } 35 | ] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/commands/sentinel-sentinels.json: -------------------------------------------------------------------------------- 1 | { 2 | "SENTINELS": { 3 | "summary": "Returns a list of Sentinel instances.", 4 | "complexity": "O(N) where N is the number of Sentinels", 5 | "group": "sentinel", 6 | "since": "2.8.4", 7 | "arity": 3, 8 | "container": "SENTINEL", 9 | "function": "sentinelCommand", 10 | "command_flags": [ 11 | "ADMIN", 12 | "SENTINEL", 13 | "ONLY_SENTINEL" 14 | ], 15 | "reply_schema": { 16 | "type": "array", 17 | "description": "List of sentinel instances, and their state.", 18 | "items": { 19 | "type": "object", 20 | "additionalProperties": { 21 | "type": "string" 22 | } 23 | } 24 | }, 25 | "arguments": [ 26 | { 27 | "name": "master-name", 28 | "type": "string" 29 | } 30 | ] 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /deps/lua/doc/readme.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Lua documentation 4 | 5 | 6 | 7 | 8 | 9 |
10 |

11 | Lua 12 | Documentation 13 |

14 | 15 | This is the documentation included in the source distribution of Lua 5.1.5. 16 | 17 | 25 | 26 | Lua's 27 | official web site 28 | contains updated documentation, 29 | especially the 30 | reference manual. 31 |

32 | 33 |


34 | 35 | Last update: 36 | Fri Feb 3 09:44:42 BRST 2012 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/commands/script-load.json: -------------------------------------------------------------------------------- 1 | { 2 | "LOAD": { 3 | "summary": "Loads a server-side Lua script to the script cache.", 4 | "complexity": "O(N) with N being the length in bytes of the script body.", 5 | "group": "scripting", 6 | "since": "2.6.0", 7 | "arity": 3, 8 | "container": "SCRIPT", 9 | "function": "scriptCommand", 10 | "command_flags": [ 11 | "NOSCRIPT", 12 | "STALE" 13 | ], 14 | "acl_categories": [ 15 | "SCRIPTING" 16 | ], 17 | "command_tips": [ 18 | "REQUEST_POLICY:ALL_NODES", 19 | "RESPONSE_POLICY:ALL_SUCCEEDED" 20 | ], 21 | "arguments": [ 22 | { 23 | "name": "script", 24 | "type": "string" 25 | } 26 | ], 27 | "reply_schema": { 28 | "description": "The SHA1 digest of the script added into the script cache", 29 | "type": "string" 30 | } 31 | } 32 | } 33 | --------------------------------------------------------------------------------