redis.clients.jedis.JedisMonitor Java Examples

The following examples show how to use redis.clients.jedis.JedisMonitor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ControlCommandsTest.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
@Test
public void monitor() {
  new Thread(new Runnable() {
    @Override
    public void run() {
      try {
        // sleep 100ms to make sure that monitor thread runs first
        Thread.sleep(100);
      } catch (InterruptedException e) {
      }
      Jedis j = new Jedis("localhost");
      j.auth("foobared");
      for (int i = 0; i < 5; i++) {
        j.incr("foobared");
      }
      j.disconnect();
    }
  }).start();

  jedis.monitor(new JedisMonitor() {
    private int count = 0;

    @Override
    public void onCommand(String command) {
      if (command.contains("INCR")) {
        count++;
      }
      if (count == 5) {
        client.disconnect();
      }
    }
  });
}
 
Example #2
Source File: JedisAdapter.java    From gameserver with Apache License 2.0 5 votes vote down vote up
@Override
public void monitor(JedisMonitor jedisMonitor) {
	redis.clients.jedis.Jedis delegate = pool.getResource();
	try {
		delegate.monitor(jedisMonitor);
	} finally {
		pool.returnResource(delegate);
	}
}
 
Example #3
Source File: DefaultRedis.java    From craft-atom with MIT License 5 votes vote down vote up
private String monitor0(Jedis j, final RedisMonitorHandler handler) {
	JedisMonitor jm = new JedisMonitor() {
		@Override
		public void onCommand(String command) {
			handler.onCommand(command);
		}
		
	};
	j.monitor(jm);
	return OK;
}
 
Example #4
Source File: JedisDummyAdapter.java    From gameserver with Apache License 2.0 4 votes vote down vote up
@Override
public void monitor(JedisMonitor jedisMonitor) {
	super.monitor(jedisMonitor);
}
 
Example #5
Source File: JedisAllCommand.java    From gameserver with Apache License 2.0 2 votes vote down vote up
/**
 * @param jedisMonitor
 * @see redis.clients.jedis.BinaryJedis#monitor(redis.clients.jedis.JedisMonitor)
 */
public abstract void monitor(JedisMonitor jedisMonitor);