redis启动-windows
redis-server redis.windows.conf

链接redis服务器
redis-cli.exe -h 127.0.0.1 -p 6379 -a 密码(如果密码不存在去掉-a)

开启监听
PSUBSCRIBE __keyevent@0__:expired Reading message...

向redis中插入数据(setex test_key 失效时间 test_value)
setex test_key 3 test_value

从redis中取值(get key 取key对应的值/keys * 取所有值)
get 100000000000000001 / keys *

Redis返回(nil)在lua里是boolean类型而非nil
Redis里执行get或hget不存在的key或field时返回值在终端显式的是”(nil)”
127.0.0.1:6379> get notexist
(nil)
当使用lua脚本执行逻辑时,如果要判断这个值,很容易让人迷惑以为它是nil,从而导致判断不成立,实际它是一个boolean的值
127.0.0.1:6379> eval "local v=redis.call('get',KEYS[1]); return type(v)" 1 notexist
"boolean"
所以在脚本里判断获取的结果不为空,正确的方式还有判断false的情况:
local v=redis.call('hget',KEYS[1], ARGV[1]); if (v ~= nil or (type(v) == 'boolean' and v)) then return 'not-empty'; end