利用Jedis實現redis服務監控反饋
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisMonitor;
public class JedisMointor implements Runnable{
private Jedis jedis;
public mointor(Jedis jedis) {
this.jedis = jedis;
}
public void run() {
jedis.monitor(new JedisMonitor() {
@Override
public void onCommand(String s) {
System.out.println(s);
}
});
}
public static void main(String[] args){
JedisMointor m = new JedisMointor(new Jedis("127.0.0.1", 6379));
new Thread(m).start();
}
}
1568874769.460224 [2 127.0.0.1:56417] "select" "1"
1568874774.181213 [1 127.0.0.1:56417] "get" "a"
1568874780.320832 [1 127.0.0.1:56417] "set" "a" "b"