本文整理汇总了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();
}