Redis - MRLIVING/Becca GitHub Wiki
Redis-cli
-
installation under Ubuntu
apt-get install redis-tools
-
connect to redis
redis-cli -h ${HOST} -p 6379
Data type and commands
-
Strings - Redis Strings are binary safe.
-
- EXPIRE key seconds
- TTL key
- SCAN cursor [MATCH pattern] [COUNT count]
- list of keys
redis-cli -h $HOST --scan --pattern '*-11*'
- count the number of keys with the specific pattern, e.g.
redis-cli -h {$HOST} --scan --pattern '*_mod/breadcrumb*' | wc -l
- list of keys
- KEYS pattern
- notice that you should always consider
scan
instead ofkeys
to prevent block redis server.
- notice that you should always consider
- DEL key [key ...]
- del keys by specific pattern
redis-cli -h ${HOST} --scan --pattern '*_mod*' | xargs redis-cli -h ${HOST} del
redis-cli -h ${HOST} --scan --pattern '*_mod*' | xargs redis-cli -h ${HOST} unlink
redis-cli -h ${HOST} --scan --pattern '*_opp*' | sed 's/""|/|/g' | xargs redis-cli -h ${HOST} del
- del keys by specific pattern
- FLUSHALL
-
- ZADD key score member [score member ...]
- ZRANGE key start stop [WITHSCORES], lowest to the highest
- ZREVRANGE key start stop [WITHSCORES], highest to the lowest
- ZREMRANGEBYRANK key start stop
zremrangebyrank key 0 -4
, keep top 3 hightest scoring members.