• Overview delle strutture dati.
  • Persistenza: fork() e copy on write.
  • Implementazione di EXPIRE con sampling a approssimazione dell'algoritmo LRU.
  • Indici secondari usando i sorted set (inclusi i comandi LEX).
  • Geoindexing rappresentato da sorted set.
  • Mass import di dati tramite redis-cli.
  • Protocollo REPL.
  • Lua scripting.
  • Implementazione low level delle strutture dati: 1) Implementazione dual-ported dei sorted set (hash table + skiplist). 2) Hash table con rehashing incementale. 3) Quicklists: ovvero le liste di Redis sono implementate come delle liste linkate di mega-blob che contengono N oggetti.
  • Maxmemory e policy di eviction al raggiungimento della memoria. LRU e LFU.
View rax_iterator_api.c
void somefunc(rax *mytree) {
raxIterator iter;
/* As seek operator you can use >, <, >=, <=, == */
raxSeek(&iter,(unsigned char*)"chromo",6,"<="); /* Seek key <= "chromo" */
while(raxNext(&iter,NULL,0,NULL)) { /* or raxPrev() */
printf("Current key: %.*s, val %p\n",
(int)iter.key_len, (char*)iter.key,;
View prng_bleagh.c
/* MacOS libc PRNG is garbage!
* Test this on MacOS 10.12.3 (may be the same with other versions)
* You'll see three times the same output.
* Cheers by @antirez. */
#include <stdio.h>
#include <stdlib.h>
int main(void) {
/* Note, 1000000, 1000001, 1000002 are not special.

Radix tree ASCII printing.

[r] -> [ou]
           `-(o) [m] -> [au]
                         `-(a) [n] -> [eu]
                                       `-(e) []=0x0
                                       `-(u) [s] -> []=0x1
                         `-(u) "lus" -> []=0x2
           `-(u) [b] -> [ei]
View patch.diff
diff --git a/src/evict.c b/src/evict.c
index 802997c..24fb283 100644
--- a/src/evict.c
+++ b/src/evict.c
@@ -336,11 +336,34 @@ unsigned long LFUDecrAndReturn(robj *o) {
* server when there is data to add in order to make space if needed.
* --------------------------------------------------------------------------*/
+/* We don't want to count AOF buffers and slaves output buffers as
+ * used memory: the eviction should use mostly data size. This function

Redis 4.2 roadmap

  1. Redis Cluster
  • Speed up key -> hashslot association. Now makes RBB loading 4x slower when there are many small keys.
  • Better multi data center story
  • redis-trib C coded and moved into redis-cli
  • Backup / Restore of Cluster
  • Non blocking MIGRATE (also consider not using 2X memory)
  • Faster resharding
  • Bug fixing and stress testing to bring it to next level of maturity

Listpack specification

Version 1.0, 1 Feb 2017: Intial specification.

Version 1.1, 2 Feb 2017: Integer encoding simplified. Appendix A added.

Version 1.2, 3 Feb 2017: Better specify the meaning of the num-elements
                         field with value of 65535. The two 12 bits
                         positive/negative integers encodings were
View stresstest.rb
require 'redis'
def g(prefix)
choice = rand(9)
if (choice == 0)
# Values around this size stress the cascading update.
len = [252,250].shuffle.first
prefix += rand(1000000).to_s
string = prefix + ("A"*(len-prefix.length))
View stresstest.c
/* gcc ziplist-stresstest.c zmalloc.c ziplist.c util.c sha1.c sds.c -Wall -W -O2 -o zl-test -ggdb -g; ./zl-test.
* To run with gcov use -Wall on OSX use -fprofile-arcs -ftest-coverage. */
#include "ziplist.h"
#include "util.h"
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
View gist:779a83400dc5a4835a954123948629a4