Java Code Examples for redis.clients.jedis.JedisCluster#get()

The following examples show how to use redis.clients.jedis.JedisCluster#get() . 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: SpringRedis.java    From xmanager with Apache License 2.0 6 votes vote down vote up
/**测试redis集群方案*/
@Test
public void testCluster(){

    Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
    //Jedis Cluster will attempt to discover cluster nodes automatically
    jedisClusterNodes.add(new HostAndPort("192.168.12.90", 7001));
    JedisCluster jc = new JedisCluster(jedisClusterNodes);
    jc.set("foo", "bar");
    String value = jc.get("foo");

    System.out.println(value);
    try {
        jc.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 2
Source File: TestJedisCluster.java    From Redis_Learning with Apache License 2.0 6 votes vote down vote up
@Test
public void testJedisCluster() throws Exception {
	// ���ü�Ⱥ�нڵ�
	Set<HostAndPort> nodes = new HashSet<HostAndPort>();
	nodes.add(new HostAndPort(host, 7000));
	nodes.add(new HostAndPort(host, 7001));
	nodes.add(new HostAndPort(host, 7002));
	nodes.add(new HostAndPort(host, 7003));
	nodes.add(new HostAndPort(host, 7004));
	nodes.add(new HostAndPort(host, 7005));
	JedisCluster jc = new JedisCluster(nodes);
	jc.set("jedis", "hello zhangrui!");
	String result = jc.get("jedis");
	System.out.println(result);
	jc.close();// �ر�����
}
 
Example 3
Source File: RedisShardBackplane.java    From bazel-buildfarm with Apache License 2.0 6 votes vote down vote up
private Instant getExpiresAt(JedisCluster jedis, String key, Instant now) {
  String value = jedis.get(key);
  if (value != null) {
    try {
      return Instant.ofEpochMilli(Long.parseLong(value));
    } catch (NumberFormatException e) {
      logger.log(Level.SEVERE, format("invalid expiration %s for %s", value, key));
    }
  }

  Instant expiresAt = now.plusMillis(config.getProcessingTimeoutMillis());
  jedis.setex(
      key,
      /* expire=*/ (config.getProcessingTimeoutMillis() * 2) / 1000,
      String.format("%d", expiresAt.toEpochMilli()));
  return expiresAt;
}
 
Example 4
Source File: DoTestJedisHookProxy.java    From uavstack with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
private static void foo3() {

    System.out.println("TEST JedisCluster ======================================================");

    JedisCluster jc = new JedisCluster(new HostAndPort("127.0.0.1", 6380));
    jc.set("foo", "bar");
    String val = jc.get("foo");
    System.out.println(val);

    jc.set("foo1", "bar");
    jc.set("foo2", "bar");
    jc.set("foo3", "bar");
    jc.set("foo4", "bar");
    jc.set("foo5", "bar");

    jc.del("foo");
    jc.del("foo1");
    jc.del("foo2");
    jc.del("foo3");
    jc.del("foo4");
    jc.del("foo5");

    try {
        jc.close();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 5
Source File: RedisHttpSessionTest.java    From RedisHttpSession with Apache License 2.0 5 votes vote down vote up
public void testCluster(){

        Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
        //Jedis Cluster will attempt to discover cluster nodes automatically
        jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7000));
        JedisCluster jc = new JedisCluster(jedisClusterNodes);
        jc.set("foo", "bar");
        String value = jc.get("foo");
        System.out.println(value);
    }
 
Example 6
Source File: JedisDemo.java    From JavaTutorial with Apache License 2.0 5 votes vote down vote up
/**
 * 集群方式(尚未实现)。
 */
private static void cluster() {
    // 生成集群节点列表
    Set<HostAndPort> clusterNodes = new HashSet<HostAndPort>();
    clusterNodes.add(new HostAndPort("127.0.0.1", 6379));
    clusterNodes.add(new HostAndPort("192168.56.102", 6379));
    
    // 执行指令
    JedisCluster client = new JedisCluster(clusterNodes);
    String result = client.set("key-string", "Hello, Redis!");
    System.out.println( String.format("set指令执行结果:%s", result) );
    String value = client.get("key-string");
    System.out.println( String.format("get指令执行结果:%s", value) );
}
 
Example 7
Source File: RedisShardBackplane.java    From bazel-buildfarm with Apache License 2.0 4 votes vote down vote up
private String getOperation(JedisCluster jedis, String operationName) {
  String json = jedis.get(operationKey(operationName));
  return json;
}