redis

27/03/2018

get databases :

redis-cli INFO | grep ^db

get and set keys

KEYS *
keys *pattern*

get 
set  
setnx   # Set key value only if key does not exist

choisi une base

select 1

do not persist data on disk

start the server with this config

redis-server --save "" --appendonly no --latency-monitor-threshold 100

persist data

    - "redis-server"
    - "--latency-monitor-threshold"
    - "100"
    # when to save db on disk :
    # after 60 seconds if at least 1000 key changed
    - "--save"
    - "60 1000"
    # create a replayable insert log on the disk
    # can be activated simultaneously with the save command
    - "--appendonly"
    - "yes"
    - "--appendfilename"
    - "appendonly.aof"
    - "--appendfsync"
    - "everysec"

test latency

run a big benchmark :

docker exec redis redis-benchmark -q -n 100000

see latency :

docker exec redis redis-cli latency doctor
docker exec redis redis-cli latency latest

manual latency test

docker exec redis -ti redis-cli
127.0.0.1:6379> debug sleep 1
127.0.0.1:6379> debug sleep .25
127.0.0.1:6379> latency latest
1) 1) "command"
2) (integer) 1405067976 # timestamp
3) (integer) 251 # latest latency
4) (integer) 1001 # worse latency

monitor

voir en live toutes les commandes lancées sur le serveur

docker exec -ti redis redis-cli monitor