zoukankan      html  css  js  c++  java
  • 哨兵模式java实例

     1 /**
     2  * 测试Redis哨兵模式
     3  * @author liu
     4  */
     5 public class TestSentinels {
     6     @SuppressWarnings("resource")
     7     @Test
     8     public void testSentinel() {
     9         JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    10         jedisPoolConfig.setMaxTotal(10);
    11         jedisPoolConfig.setMaxIdle(5);
    12         jedisPoolConfig.setMinIdle(5);
    13         // 哨兵信息
    14         Set<String> sentinels = new HashSet<>(Arrays.asList("192.168.11.128:26379",
    15                 "192.168.11.129:26379","192.168.11.130:26379"));
    16         // 创建连接池
    17         JedisSentinelPool pool = new JedisSentinelPool("mymaster", sentinels,jedisPoolConfig,"123456");
    18         // 获取客户端
    19         Jedis jedis = pool.getResource();
    20         // 执行两个命令
    21         jedis.set("mykey", "myvalue");
    22         String value = jedis.get("mykey");
    23         System.out.println(value);
    24     }
    25 }
  • 相关阅读:
    标签,css,排版
    浏览器的内核
    焦点事件
    cookie
    浏览器的行为
    百叶窗分析
    水仙花数
    递归函数
    拖拽的问题解决
    正则的具体
  • 原文地址:https://www.cnblogs.com/cowshed/p/11397707.html
Copyright © 2011-2022 走看看