talk is cheap, show me the code. 一.开启Redis key过期提醒 方式二:修改配置文件 redis.conf # 默认 notify-keyspace-events "" notify-keyspace-events Ex 方式二:命令行开启 CONFIG SET notify-keyspace-events Ex CONFIG GET notify-keyspace-events 二.notify-keyspace-events notify-ke
文档: https://redis.io/topics/rediscli help命令: The command can be used in two forms: . help @<category> shows all the commands about a given category. The categories are: @generic, @list, @set, @sorted_set, @hash, @pubsub, @transactions, @connection,
过期事件通过Redis的订阅与发布功能(pub/sub)来进行分发. 而对超时的监听呢,并不需要自己发布,只有修改配置文件redis.conf中的:notify-keyspace-events Ex,默认为notify-keyspace-events "" # K 键空间通知,以__keyspace@<db>__为前缀 # E 键事件通知,以__keysevent@<db>__为前缀 # g del , expipre , rename 等类型无关的通用命令的通