Instantly share code, notes, and snippets.

View gist:8713684
wc -l *.[ch] | grep -v total | sort -rn > /tmp/loc.txt
3696 cluster.c
3560 sentinel.c
3166 redis.c
2219 t_zset.c
1826 replication.c
1819 config.c
1633 redis-cli.c
1557 networking.c
View gist:8738422
$ lsof -p 96144
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
tclsh8.5 96144 antirez 10u IPv4 0xee68e5eeb7bbc4d3 0t0 TCP localhost:53651->localhost:21212 (SYN_SENT)
View gist:9191513
Starting sentinel #0 at port 20000
Starting sentinel #1 at port 20001
Starting sentinel #2 at port 20002
Starting sentinel #3 at port 20003
Starting sentinel #4 at port 20004
Starting redis #0 at port 30000
Starting redis #1 at port 30001
Starting redis #2 at port 30002
Starting redis #3 at port 30003
Starting redis #4 at port 30004
View gist:9267914
UNESCAPES = {
'a' => "\x07", 'b' => "\x08", 't' => "\x09",
'n' => "\x0a", 'v' => "\x0b", 'f' => "\x0c",
'r' => "\x0d", 'e' => "\x1b", "\\\\" => "\x5c",
"\"" => "\x22", "'" => "\x27"
}
puts UNESCAPES.keys.join
#exit
View gist:9486205
./redis-trib.rb call 192.168.1.11:7000 info | grep memory_human
used_memory_human:11.42M
used_memory_human:9.78M
used_memory_human:9.12M
used_memory_human:12.43M
used_memory_human:11.45M
used_memory_human:11.42M
used_memory_human:12.44M
used_memory_human:10.99M
used_memory_human:12.43M
View gist:9489416
redis-cli -c -p 7000 :3.0:
redis 192.168.1.10:7000> set foo bar
-> Redirected to slot [12182] located at 192.168.1.11:7001
OK
redis 192.168.1.11:7001>
View test-lru.rb
require 'rubygems'
require 'redis'
r = Redis.new
r.config("SET","maxmemory","2000000")
r.config("SET","maxmemory-policy","allkeys-lru")
r.config("SET","maxmemory-samples",1000)
r.config("RESETSTAT")
r.flushall
View gist:9992506
127.0.0.1:6379> zrangebylex words [anter + LIMIT 0 10
1) "anterior"
2) "anteriorly"
3) "anteroom"
4) "anterooms"
5) "antes"
6) "anthem"
7) "anthemed"
8) "anthems"
9) "anther"
View gist:10018556
cardinality 1 uses 5 bytes (0.00244140625 bits per register})
cardinality 10 uses 31 bytes (0.01513671875 bits per register})
cardinality 100 uses 271 bytes (0.13232421875 bits per register})
cardinality 1000 uses 1906 bytes (0.9306640625 bits per register})
cardinality 2000 uses 3517 bytes (1.71728515625 bits per register})
cardinality 3000 uses 4918 bytes (2.4013671875 bits per register})
cardinality 4000 uses 6129 bytes (2.99267578125 bits per register})
cardinality 5000 uses 7206 bytes (3.5185546875 bits per register})
cardinality 6000 uses 8099 bytes (3.95458984375 bits per register})
cardinality 7000 uses 8868 bytes (4.330078125 bits per register})
View gist:10625511
127.0.0.1:6379> pfadd hll 1 2 3 4 5 6
(integer) 1
127.0.0.1:6379> pfdebug decode hll
"Z:495 v:2,1 Z:2084 v:1,1 Z:4946 v:1,1 Z:3445 v:1,1 Z:4397 v:4,1 Z:208 v:2,1 Z:803"