脚本编程
从 Redis2.6 开始支持 Lua 脚本编程
可以用这种方式实现一些简单事务
类似于 RDBMS 中的存储过程
节省流量
例子:
EVAL "local a = redis.call('GET', 'bob:account'); local b = redis.call('GET', 'smith:account'); if not a or not b then return 1 end; a = a - 20; b = b + 20; if not redis.call('MSET', 'bob:account', a, 'smith:account', b) then return 2 end; return 0;" 0
DBA CMD
INFO
DBSIZE
KEYS
CONFIG SET / CONFIG GET
FLUSHDB / FLUSHALL
MONITOR / SLOWLOG GET / SLOWLOG SET
TIME / PING
CLIENT LIST / CLIENT KILL
SAVE / BGSAVE / BGREWRITESAVE / LASTSAVE
SHUTDOWN
Redis 协议
实现简单
解析快速
可读性好
set mykey myvalue
*3\r\n$3\r\nSET\r\n$5\r\nmykey\r\n$7\r\nmyvalue\r\n