云数据库 GaussDB NoSQL-通过Jedis连接实例:使用JedisCluster访问

时间:2023-11-01 16:25:44

使用JedisCluster访问

样例代码

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;import redis.clients.jedis.HostAndPort;import redis.clients.jedis.JedisCluster;public class ClusterTests {  private static void testCluster() {    String pwd = "a";        JedisCluster cluster = new JedisCluster(new HostAndPort("172.xx.xx.xx", 8635),        200, 2000, 5, pwd, new GenericObjectPoolConfig());    System.out.println(cluster.hgetAll("676296"));    System.out.println(cluster.set("key1", "value1"));  }  public static void main(String[] args) {    testCluster();  }}
support.huaweicloud.com/redisug-nosql/nosql_09_0103.html