Skip to content

Instantly share code, notes, and snippets.

@wendal
Created March 14, 2017 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wendal/b2b0678b4aa287ee164d05d155d12a7d to your computer and use it in GitHub Desktop.
Save wendal/b2b0678b4aa287ee164d05d155d12a7d to your computer and use it in GitHub Desktop.
Jedis订阅key过期事件的示例代码
public static void main(String[] args) {
Jedis jedis = new Jedis();
jedis.setex("abc", 15, "hi");
System.out.println("time now = " + System.currentTimeMillis());
jedis.psubscribe(new JedisPubSub() {
@Override
public void onPMessage(String pattern, String channel, String message) {
System.out.println("time now = " + System.currentTimeMillis());
System.out.println(pattern + " " + channel +" " + message);
}
}, "__keyevent@0__:expired");
jedis.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment