当前位置: 首页>>代码示例>>Java>>正文


Java Protocol.DEFAULT_HOST属性代码示例

本文整理汇总了Java中redis.clients.jedis.Protocol.DEFAULT_HOST属性的典型用法代码示例。如果您正苦于以下问题:Java Protocol.DEFAULT_HOST属性的具体用法?Java Protocol.DEFAULT_HOST怎么用?Java Protocol.DEFAULT_HOST使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在redis.clients.jedis.Protocol的用法示例。


在下文中一共展示了Protocol.DEFAULT_HOST属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newJedisPool

/**
 * Creates a new {@link JedisPool}.
 * 
 * @param hostAndPort
 * @param password
 * @param db
 * @param timeoutMs
 * @return
 */
public static JedisPool newJedisPool(String hostAndPort, String password, int db,
        long timeoutMs) {
    final int maxTotal = Runtime.getRuntime().availableProcessors();
    final int maxIdle = maxTotal / 2;

    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(maxTotal);
    poolConfig.setMinIdle(1);
    poolConfig.setMaxIdle(maxIdle > 0 ? maxIdle : 1);
    poolConfig.setMaxWaitMillis(timeoutMs + 1000);
    // poolConfig.setTestOnBorrow(true);
    poolConfig.setTestWhileIdle(true);

    String[] tokens = hostAndPort.split(":");
    String host = tokens.length > 0 ? tokens[0] : Protocol.DEFAULT_HOST;
    int port = tokens.length > 1 ? Integer.parseInt(tokens[1]) : Protocol.DEFAULT_PORT;
    JedisPool jedisPool = new JedisPool(poolConfig, host, port, (int) timeoutMs, password, db);
    return jedisPool;
}
 
开发者ID:DDTH,项目名称:ddth-cache-adapter,代码行数:28,代码来源:RedisCacheFactory.java

示例2: newJedisPool

/**
 * Creates a new {@link JedisPool}.
 * 
 * @param hostAndPort
 * @param password
 * @param db
 * @param timeoutMs
 * @return
 * @since 0.5.0
 */
public static JedisPool newJedisPool(String hostAndPort, String password, int db,
        long timeoutMs) {
    final int maxTotal = Runtime.getRuntime().availableProcessors();
    final int maxIdle = maxTotal / 2;

    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(maxTotal);
    poolConfig.setMinIdle(1);
    poolConfig.setMaxIdle(maxIdle > 0 ? maxIdle : 1);
    poolConfig.setMaxWaitMillis(timeoutMs);
    // poolConfig.setTestOnBorrow(true);
    poolConfig.setTestWhileIdle(true);

    String[] tokens = hostAndPort.split(":");
    String host = tokens.length > 0 ? tokens[0] : Protocol.DEFAULT_HOST;
    int port = tokens.length > 1 ? Integer.parseInt(tokens[1]) : Protocol.DEFAULT_PORT;
    JedisPool jedisPool = new JedisPool(poolConfig, host, port, Protocol.DEFAULT_TIMEOUT,
            password, db);
    return jedisPool;
}
 
开发者ID:DDTH,项目名称:ddth-id,代码行数:30,代码来源:RedisIdGenerator.java

示例3: newShardedJedisPool

/**
 * Create a new {@link ShardedJedisPool}.
 * 
 * @param poolConfig
 *            format {@code host1:port1,host2:port2,...}, default Redis port is used if not
 *            specified
 * @param password
 * @param timeoutMs
 * @return
 */
public static ShardedJedisPool newShardedJedisPool(JedisPoolConfig poolConfig,
        String hostsAndPorts, String password, int timeoutMs) {
    List<JedisShardInfo> shards = new ArrayList<>();
    String[] hapList = hostsAndPorts.split("[,;\\s]+");
    for (String hostAndPort : hapList) {
        String[] tokens = hostAndPort.split(":");
        String host = tokens.length > 0 ? tokens[0] : Protocol.DEFAULT_HOST;
        int port = tokens.length > 1 ? Integer.parseInt(tokens[1]) : Protocol.DEFAULT_PORT;
        JedisShardInfo shardInfo = new JedisShardInfo(host, port, timeoutMs);
        shardInfo.setPassword(password);
        shards.add(shardInfo);
    }
    ShardedJedisPool jedisPool = new ShardedJedisPool(poolConfig, shards);
    return jedisPool;
}
 
开发者ID:DDTH,项目名称:ddth-commons,代码行数:25,代码来源:JedisUtils.java

示例4: setupPool

@BeforeClass
public static void setupPool() {
    POOL = new JedisPool(new GenericObjectPoolConfig(), 
            Protocol.DEFAULT_HOST, 
            Protocol.DEFAULT_PORT, 
            Protocol.DEFAULT_TIMEOUT, 
            null, 
            5);
}
 
开发者ID:andrepnh,项目名称:jedis-utils,代码行数:9,代码来源:CommandBlockTest.java

示例5: newJedisCluster

/**
 * Creates a new {@link JedisCluster}.
 * 
 * @param hostsAndPorts
 *            format {@code host1:port1,host2:port2...}
 * @param password
 * @param timeoutMs
 * @return
 */
public static JedisCluster newJedisCluster(String hostsAndPorts, String password,
        long timeoutMs) {
    final int maxTotal = Runtime.getRuntime().availableProcessors();
    final int maxIdle = maxTotal / 2;

    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(maxTotal);
    poolConfig.setMinIdle(1);
    poolConfig.setMaxIdle(maxIdle > 0 ? maxIdle : 1);
    poolConfig.setMaxWaitMillis(timeoutMs + 1000);
    // poolConfig.setTestOnBorrow(true);
    poolConfig.setTestWhileIdle(true);

    Set<HostAndPort> clusterNodes = new HashSet<>();
    String[] hapList = hostsAndPorts.split("[,;\\s]+");
    for (String hostAndPort : hapList) {
        String[] tokens = hostAndPort.split(":");
        String host = tokens.length > 0 ? tokens[0] : Protocol.DEFAULT_HOST;
        int port = tokens.length > 1 ? Integer.parseInt(tokens[1]) : Protocol.DEFAULT_PORT;
        clusterNodes.add(new HostAndPort(host, port));
    }

    JedisCluster jedisCluster = new JedisCluster(clusterNodes, (int) timeoutMs, (int) timeoutMs,
            DEFAULT_MAX_ATTEMPTS, password, poolConfig);
    return jedisCluster;
}
 
开发者ID:DDTH,项目名称:ddth-cache-adapter,代码行数:35,代码来源:ClusteredRedisCacheFactory.java

示例6: newJedisPool

/**
 * Creates a new {@link ShardedJedisPool}.
 * 
 * @param hostsAndPorts
 *            format {@code host1:port1,host2:port2...}
 * @param password
 * @param timeoutMs
 * @return
 */
public static ShardedJedisPool newJedisPool(String hostsAndPorts, String password,
        long timeoutMs) {
    final int maxTotal = Runtime.getRuntime().availableProcessors();
    final int maxIdle = maxTotal / 2;

    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(maxTotal);
    poolConfig.setMinIdle(1);
    poolConfig.setMaxIdle(maxIdle > 0 ? maxIdle : 1);
    poolConfig.setMaxWaitMillis(timeoutMs + 1000);
    // poolConfig.setTestOnBorrow(true);
    poolConfig.setTestWhileIdle(true);

    List<JedisShardInfo> shards = new ArrayList<>();
    String[] hapList = hostsAndPorts.split("[,;\\s]+");
    for (String hostAndPort : hapList) {
        String[] tokens = hostAndPort.split(":");
        String host = tokens.length > 0 ? tokens[0] : Protocol.DEFAULT_HOST;
        int port = tokens.length > 1 ? Integer.parseInt(tokens[1]) : Protocol.DEFAULT_PORT;
        JedisShardInfo shardInfo = new JedisShardInfo(host, port, (int) timeoutMs);
        shardInfo.setPassword(password);
        shards.add(shardInfo);
    }
    ShardedJedisPool jedisPool = new ShardedJedisPool(poolConfig, shards);
    return jedisPool;
}
 
开发者ID:DDTH,项目名称:ddth-cache-adapter,代码行数:35,代码来源:ShardedRedisCacheFactory.java

示例7: newJedisCluster

/**
 * Create a new {@link JedisCluster}.
 * 
 * @param poolConfig
 *            format {@code host1:port1,host2:port2,...}, default Redis port is used if not
 *            specified
 * @param password
 * @param timeoutMs
 * @param maxAttempts
 * @return
 */
public static JedisCluster newJedisCluster(JedisPoolConfig poolConfig, String hostsAndPorts,
        String password, int timeoutMs, int maxAttempts) {
    Set<HostAndPort> clusterNodes = new HashSet<>();
    String[] hapList = hostsAndPorts.split("[,;\\s]+");
    for (String hostAndPort : hapList) {
        String[] tokens = hostAndPort.split(":");
        String host = tokens.length > 0 ? tokens[0] : Protocol.DEFAULT_HOST;
        int port = tokens.length > 1 ? Integer.parseInt(tokens[1]) : Protocol.DEFAULT_PORT;
        clusterNodes.add(new HostAndPort(host, port));
    }
    JedisCluster jedisCluster = new JedisCluster(clusterNodes, timeoutMs, timeoutMs,
            maxAttempts, password, poolConfig);
    return jedisCluster;
}
 
开发者ID:DDTH,项目名称:ddth-commons,代码行数:25,代码来源:JedisUtils.java

示例8: JaRedisPool

public JaRedisPool() {
    this(Protocol.DEFAULT_HOST, Protocol.DEFAULT_PORT);
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:3,代码来源:JaRedisPool.java

示例9: setHost

public void setHost(String host) {
  if (host == null || "".equals(host)) {
    host = Protocol.DEFAULT_HOST;
  }
  this.host = host;
}
 
开发者ID:mybatis,项目名称:redis-cache,代码行数:6,代码来源:RedisConfig.java

示例10: newJedisPool

/**
 * Create a new {@link JedisPool}.
 *
 * @param poolConfig
 * @param hostAndPort
 *            format {@code host:port} or {@code host}, default Redis port is used if not
 *            specified
 * @param password
 * @param db
 * @param timeoutMs
 * @return
 */
public static JedisPool newJedisPool(JedisPoolConfig poolConfig, String hostAndPort,
        String password, int db, int timeoutMs) {
    String[] tokens = hostAndPort.split(":");
    String host = tokens.length > 0 ? tokens[0] : Protocol.DEFAULT_HOST;
    int port = tokens.length > 1 ? Integer.parseInt(tokens[1]) : Protocol.DEFAULT_PORT;
    JedisPool jedisPool = new JedisPool(
            poolConfig != null ? poolConfig : defaultJedisPoolConfig(), host, port, timeoutMs,
            password, db);
    return jedisPool;
}
 
开发者ID:DDTH,项目名称:ddth-commons,代码行数:22,代码来源:JedisUtils.java


注:本文中的redis.clients.jedis.Protocol.DEFAULT_HOST属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。