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


Java JedisPoolConfig.setMaxTotal方法代码示例

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


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

示例1: createJedisPool

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
private void createJedisPool() {

        JedisPoolConfig config = new JedisPoolConfig();

        // 设置最大连接数
        config.setMaxTotal(500);

        // 设置最大阻塞时间(毫秒)
        config.setMaxWaitMillis(1000);

        // 设置空闲连接数
        config.setMaxIdle(20);
        config.setMinIdle(10);

        // 创建连接池
        pool = new JedisPool(config, appConfig.get(CONFIG_KEY_REDIS_HOST, DEFAULT_REDIS_HOST), appConfig.getInt(CONFIG_KEY_REDIS_PORT, DEFAULT_REDIS_PORT), Protocol.DEFAULT_TIMEOUT, appConfig.get(CONFIG_KEY_REDIS_PASS, ""));
    }
 
开发者ID:thundernet8,项目名称:Elune,代码行数:18,代码来源:RedisManager.java

示例2: getInstance

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
public static JedisConnector_Persistence getInstance() {
	if (instance == null) {
		instance = new JedisConnector_Persistence();
		JedisPoolConfig config = new JedisPoolConfig();
		config.setMaxTotal(Configs.getIntValue("x7.redis.max"));
		config.setMaxIdle(Configs.getIntValue("x7.redis.idle"));
		config.setJmxEnabled(true);
		config.setJmxNamePrefix("redis-persistence");
		config.setTestOnBorrow(true);

		System.out.println("x7.redis.ip.persistence = " + Configs.getString("x7.redis.ip.persistence"));
		System.out.println("x7.redis.port.persistence = " + Configs.getString("x7.redis.port.persistence"));

		pool = new JedisPool(config, Configs.getString("x7.redis.ip.persistence"),
				Configs.getIntValue("x7.redis.port.persistence")); // 6379
	}
	return instance;
}
 
开发者ID:x7-framework,项目名称:x7,代码行数:19,代码来源:JedisConnector_Persistence.java

示例3: connect

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
private void connect()
{
    JedisPoolConfig config = new JedisPoolConfig();
    config.setMaxTotal(-1);
    config.setJmxEnabled(false);

    try
    {
        this.cachePool = new JedisPool(config, this.bungee.getIp(), this.bungee.getPort(), 0, this.bungee.getPassword());
        this.cachePool.getResource().close();

        this.plugin.log(Level.INFO, "Connected to database.");
    }
    catch (Exception e)
    {
        plugin.getLogger().log(Level.SEVERE, "Can't connect to the database!", e);
        Bukkit.shutdown();
    }
}
 
开发者ID:SamaGames,项目名称:SamaGamesCore,代码行数:20,代码来源:DatabaseConnector.java

示例4: ApiService

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
public ApiService(final Properties properties) throws URISyntaxException {
    this.properties = properties;
    this.requestLog = new RequestLogFactory(LOGGER).create();
    EmbeddedJettyFactory factory = new EmbeddedJettyFactoryConstructor(requestLog).create();
    EmbeddedServers.add(EmbeddedServers.Identifiers.JETTY, factory);
    final JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(128); // maximum active connections
    poolConfig.setMaxIdle(32);  // maximum idle connections

    this.jedisPool = new JedisPool(poolConfig, new URI(properties.getProperty("caching.redis_host")));
    this.supersetCredential = new Credential(
            properties.getProperty("superset.user"),
            properties.getProperty("superset.password")
    );

    this.dafApiCredential = new Credential(
            properties.getProperty("daf_api.user"),
            properties.getProperty("daf_api.password")
    );

}
 
开发者ID:italia,项目名称:daf-cacher,代码行数:22,代码来源:ApiService.java

示例5: getJedisCluster

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
@Bean
public JedisCluster getJedisCluster() {
    List<String> serverArray = redisProperties.getNodes();
    Set<HostAndPort> nodes = new HashSet<>();

    for (String ipPort : serverArray) {
        String[] ipPortPair = ipPort.split(":");
        nodes.add(new HostAndPort(ipPortPair[0].trim(), Integer.valueOf(ipPortPair[1].trim())));
    }
    JedisPoolConfig config = new JedisPoolConfig();
    config.setMaxTotal(500);
    config.setMaxIdle(1000 * 60);
    config.setMaxWaitMillis(1000 * 10);
    config.setTestOnBorrow(true);
    return new JedisCluster(nodes, config);
}
 
开发者ID:Evan1120,项目名称:springboot-sample,代码行数:17,代码来源:JedisClusterConfig.java

示例6: createJedisConnectionFactory

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
private RedisConnectionFactory createJedisConnectionFactory(final LocalRedisProperties redisProperties) {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(redisProperties.getMinActive());
    poolConfig.setMinIdle(redisProperties.getMaxActive());
    poolConfig.setMaxWaitMillis(redisProperties.getMaxWaitTime());
    poolConfig.setTestOnBorrow(false);

    JedisConnectionFactory connFactory = new JedisConnectionFactory(poolConfig);
    connFactory.setUsePool(false);
    connFactory.setTimeout(redisProperties.getSoTimeout());
    connFactory.setHostName(redisProperties.getRedisHost());
    connFactory.setPort(redisProperties.getRedisPort());
    return connFactory;
}
 
开发者ID:eclipse,项目名称:keti,代码行数:15,代码来源:LocalRedisConnectionFactoryConfig.java

示例7: jedisPoolConfig

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
@Bean
public JedisPoolConfig jedisPoolConfig(){
    JedisPoolConfig jpc=new JedisPoolConfig();
    jpc.setMaxIdle(this.configMaxIdle);
    jpc.setTestOnBorrow(this.configTestOnBorrow);
    jpc.setMaxWaitMillis(this.configMaxWaitMillis);
    jpc.setMaxTotal(this.configMaxTotal);
    return jpc;
}
 
开发者ID:tomoncle,项目名称:JavaStudy,代码行数:10,代码来源:RedisClusterBeans.java

示例8: initRedisProvider

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
public static void initRedisProvider() {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxIdle(1);
    poolConfig.setMinEvictableIdleTimeMillis(60 * 1000);
    poolConfig.setMaxTotal(5);
    poolConfig.setMaxWaitMillis(30 * 1000);
    String[] servers = "127.0.0.1:6379".split(",");
    int timeout = 3000;
    String password = null;
    int database = 0;
    JedisProvider<Jedis, BinaryJedis> provider = new JedisStandaloneProvider("default", poolConfig, servers, timeout, password,
            database, null);
    JedisProviderFactory.setDefaultJedisProvider(provider);
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:15,代码来源:RedisDistributeLockTest.java

示例9: createJedisPoolConfig

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
public static JedisPoolConfig createJedisPoolConfig() {
	final JedisPoolConfig config = new JedisPoolConfig();
	config.setMaxWaitMillis(maxWait());
	config.setMaxIdle(1);
	config.setMaxTotal(maxActive());
	return config;
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:8,代码来源:JedisPoolConfigFactory.java

示例10: defaultPoolConfig

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
public static JedisPoolConfig defaultPoolConfig() {
    JedisPoolConfig config = new JedisPoolConfig();
    config.setMaxTotal(maxCount);
    config.setMaxIdle(maxIdle);
    config.setMaxWaitMillis(MaxWait);
    config.setTestOnBorrow(false);
    config.setTestOnReturn(false);
    return config;
}
 
开发者ID:jiumao-org,项目名称:wechat-mall,代码行数:10,代码来源:PoolUtil.java

示例11: foo2

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
private static void foo2() {

        System.out.println("TEST JedisPool ======================================================");
        JedisPoolConfig cfg = new JedisPoolConfig();
        cfg.setMaxTotal(5);
        cfg.setMaxIdle(1);
        cfg.setMaxWaitMillis(10000L);

        JedisPool jp = new JedisPool(cfg, ip, port);
        Jedis jedis = jp.getResource();

        jedis.set("foo", "bar");
        // jedis.close();
        jedis = jp.getResource();

        jedis.get("foo");
        // jedis.close();
        jedis = jp.getResource();

        jedis.lpush("lll", "a");
        jedis.lpush("lll", "b");
        jedis.lpush("lll", "c");
        jedis.lpop("lll");
        jedis.lpop("lll");
        jedis.lpop("lll");
        // jedis.close();
        jedis = jp.getResource();

        jedis.hset("mmm", "abc", "123");
        jedis.hset("mmm", "def", "456");
        jedis.hgetAll("mmm");

        jp.close();
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:35,代码来源:DoTestJedisHookProxy.java

示例12: initialPool

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
/**
 * 初始化Redis连接池
 */
private static void initialPool() {
	try {
		JedisPoolConfig config = new JedisPoolConfig();
		config.setMaxTotal(MAX_ACTIVE);
		config.setMaxIdle(MAX_IDLE);
		config.setMaxWaitMillis(MAX_WAIT);
		config.setTestOnBorrow(TEST_ON_BORROW);
		jedisPool = new JedisPool(config, IP, PORT, TIMEOUT);
	} catch (Exception e) {
		_log.error("First create JedisPool error : " + e);
	}
}
 
开发者ID:sunzhen086,项目名称:lambo,代码行数:16,代码来源:RedisUtil.java

示例13: testInvalidStartNodeNotAdded

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
@Test
public void testInvalidStartNodeNotAdded() {
  HostAndPort invalidHost = new HostAndPort("not-a-real-host", 7379);
  Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
  jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
  jedisClusterNode.add(invalidHost);
  JedisPoolConfig config = DEFAULT_CONFIG;
  config.setMaxTotal(1);
  JedisCluster jc = new JedisCluster(jedisClusterNode,  0, 2, DEFAULT_REDIRECTIONS, "cluster", config);
  Map<String, JedisPool> clusterNodes = jc.getClusterNodes();
  assertEquals(3, clusterNodes.size());
  assertFalse(clusterNodes.containsKey(JedisClusterInfoCache.getNodeKey(invalidHost)));
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:14,代码来源:JedisClusterTest.java

示例14: jedispolltest

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
@GET
@Path("jedispooltest")
@Produces(MediaType.TEXT_HTML + ";charset=utf-8")
public String jedispolltest() {

    System.out.println("TEST JedisPool ======================================================");
    JedisPoolConfig cfg = new JedisPoolConfig();
    cfg.setMaxTotal(5);
    cfg.setMaxIdle(1);
    cfg.setMaxWaitMillis(10000L);

    JedisPool jp = new JedisPool(cfg, "localhost", 6379);
    Jedis jedis = jp.getResource();

    jedis.set("foo", "bar");
    // jedis.close();
    jedis = jp.getResource();

    jedis.get("foo");
    // jedis.close();
    jedis = jp.getResource();

    jedis.lpush("lll", "a");
    jedis.lpush("lll", "b");
    jedis.lpush("lll", "c");
    jedis.lpop("lll");
    jedis.lpop("lll");
    jedis.lpop("lll");
    // jedis.close();
    jedis = jp.getResource();

    jedis.hset("mmm", "abc", "123");
    jedis.hset("mmm", "def", "456");
    jedis.hgetAll("mmm");

    jp.close();
    return "jedispooltest";
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:39,代码来源:RedisService.java

示例15: main

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
public static void main(String[] args) {
    JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    jedisPoolConfig.setMaxTotal(50000);
    jedisPoolConfig.setMaxIdle(20000);
    jedisPoolConfig.setMaxWaitMillis(3000);
    jedisPoolConfig.setTestOnBorrow(true);
    jedisPoolConfig.setTestOnReturn(true);

    List<JedisShardInfo> shards = new ArrayList<>();
    shards.add(new JedisShardInfo("127.0.0.1", 6379, 300));
    ShardedJedisPool shardedJedisPool = new ShardedJedisPool(jedisPoolConfig, shards);
    RedisService redisService = new RedisService(shardedJedisPool);
    new Thread(new HallTcpService(redisService)).start();
    new Thread(new HallNoticeService(redisService)).start();
}
 
开发者ID:peng9627,项目名称:hall,代码行数:16,代码来源:StartGame.java


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