Пример #1
0
  public void init() {
    topic = redisson.getTopic(Contants.TOPIC_PREFIX_KEY + name);
    topic.addListener(
        new MessageListener<OperateObject>() {

          public void onMessage(String channel, OperateObject message) {

            Object key = message.getKey();
            Cache cache = getEhCache();

            if (null != cache) {

              if (message.getOperateType().equals(OperateType.PUT)) {
                cache.remove(key);
              } else if (message.getOperateType().equals(OperateType.DELETE)) {
                cache.remove(key);
              } else if (message.getOperateType().equals(OperateType.CLEAR)) {
                cache.removeAll();
              } else {
                logger.error("ERROR OPERATE TYPE !!!");
              }
            }
          }
        });
  }
Пример #2
0
 public Map<String, Object> getRedisCache() {
   return redisson.getMap(name);
 }