當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。