Package redis.clients.jedis

Examples of redis.clients.jedis.BinaryJedis


  assertEquals("OK", jedis.quit());
    }

    @Test
    public void binary_quit() {
  BinaryJedis bj = new BinaryJedis(hnp.getHost());
  assertEquals("OK", bj.quit());
    }
View Full Code Here


  List<byte[]> args = new ArrayList<byte[]>();
  args.add("first".getBytes());
  args.add("second".getBytes());
  args.add("third".getBytes());

  BinaryJedis binaryJedis = new BinaryJedis(hnp.getHost(), hnp.getPort(),
    500);
  binaryJedis.connect();
  binaryJedis.auth("foobared");

  List<byte[]> responses = (List<byte[]>) binaryJedis.eval(
    script.getBytes(), keys, args);
  assertEquals(5, responses.size());
  assertEquals("key1", new String(responses.get(0)));
  assertEquals("key2", new String(responses.get(1)));
  assertEquals("first", new String(responses.get(2)));
View Full Code Here

    }

    @Test
    public void checkCloseable() {
  jedis.close();
  BinaryJedis bj = new BinaryJedis("localhost");
  bj.connect();
  bj.close();
    }
View Full Code Here

  @Test
  public void testMulti() throws Exception {
    byte[] key = "key".getBytes();
    byte[] value = "value".getBytes();

    BinaryJedis jedis = (BinaryJedis) connection.getNativeConnection();
    Transaction multi = jedis.multi();
    //connection.set(key, value);
    multi.set(value, key);
    System.out.println(multi.exec());

    connection.multi();
View Full Code Here

    this.clientName = clientName;
  }

  @Override
  public void activateObject(PooledObject<Jedis> pooledJedis) throws Exception {
    final BinaryJedis jedis = pooledJedis.getObject();
    if (jedis.getDB() != database) {
      jedis.select(database);
    }

  }
View Full Code Here

  }

  @Override
  public void destroyObject(PooledObject<Jedis> pooledJedis) throws Exception {
    final BinaryJedis jedis = pooledJedis.getObject();
    if (jedis.isConnected()) {
      try {
        try {
          jedis.quit();
        } catch (Exception e) {
        }
        jedis.disconnect();
      } catch (Exception e) {

      }
    }
View Full Code Here

    // TODO maybe should select db 0? Not sure right now.
  }

  @Override
  public boolean validateObject(PooledObject<Jedis> pooledJedis) {
    final BinaryJedis jedis = pooledJedis.getObject();
    try {
      return jedis.isConnected() && jedis.ping().equals("PONG");
    } catch (final Exception e) {
      return false;
    }
  }
View Full Code Here

TOP

Related Classes of redis.clients.jedis.BinaryJedis

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.