本文整理匯總了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, ""));
}
示例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;
}
示例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();
}
}
示例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")
);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
示例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)));
}
示例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";
}
示例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();
}