我有一把30秒后就过期的 keys .
redisTemplate.expire(sessionId , 30, TimeUnit.SECONDS);
这是我的听众:
@Service
public class RedisController implements MessageListener {
@Override
public void onMessage(Message message, byte[] pattern) {
// Get every expired key from below the code.
String key = new String(message.getBody());
System.out.println("expired key is: " + key);
}
}
我也设置了CONFIG SET notify-keyspace-events KEA
,但我没有收到任何回调.