Created
March 14, 2017 02:25
-
-
Save wendal/b2b0678b4aa287ee164d05d155d12a7d to your computer and use it in GitHub Desktop.
Jedis订阅key过期事件的示例代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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