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


Java JedisPoolConfig类代码示例

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


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

示例1: checkJedisIsReusedWhenReturned

import redis.clients.jedis.JedisPoolConfig; //导入依赖的package包/类
@Test
public void checkJedisIsReusedWhenReturned() {

  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort());
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "0");
  pool.returnResource(jedis);

  jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.incr("foo");
  pool.returnResource(jedis);
  pool.destroy();
  assertTrue(pool.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:17,代码来源:JedisPoolTest.java

示例2: jedisConnConfig

import redis.clients.jedis.JedisPoolConfig; //导入依赖的package包/类
private void jedisConnConfig(final JedisConnectionFactory jedisConnectionFactory) {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    try {
        poolConfig.setMaxTotal(Integer.parseInt(REDIS_MAXTOTAL.getValue()));
        poolConfig.setMaxIdle(Integer.parseInt(REDIS_MAXIDLE.getValue()));
        poolConfig.setBlockWhenExhausted(true);
        if (!"".equals(REDIS_PASSWORD.getValue())) {
            jedisConnectionFactory.setPassword(REDIS_PASSWORD.getValue());
        }
        if (!"".equals(REDIS_DATABASE.getValue())) {
            jedisConnectionFactory.setDatabase(Integer.parseInt(REDIS_DATABASE.getValue()));
        }
        jedisConnectionFactory.setPoolConfig(poolConfig);
        jedisConnectionFactory.setUsePool(true);
        jedisConnectionFactory.setTimeout(Integer.parseInt(REDIS_TIMEOUT.getValue()));
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}
 
开发者ID:globocom,项目名称:groot,代码行数:20,代码来源:RedisConfiguration.java

示例3: configure

import redis.clients.jedis.JedisPoolConfig; //导入依赖的package包/类
@Override
protected void configure() {
	bind(HealthCheckHandler.class).toInstance(new HealthcheckResource());
	
	bind(RequrestAdapter.class).to(RxNettyServiceAdapter.class);
	
	bind(MeetupResource.class).asEagerSingleton();
	bind(MeetupService.class).to(MeetupServiceImpl.class);
	bind(MeetupDAO.class).to(MeetupDAOImpl.class);

	bind(JedisPool.class).toInstance(
			new JedisPool(
					new JedisPoolConfig(), 
					 ConfigurationManager.getConfigInstance().getString("redis_ip","localhost")));
	
}
 
开发者ID:diegopacheco,项目名称:Building_Effective_Microservices,代码行数:17,代码来源:GuiceBindings.java

示例4: test_jedis_tracer

import redis.clients.jedis.JedisPoolConfig; //导入依赖的package包/类
@Test
public void test_jedis_tracer() throws Exception {
    Brave.Builder builder = new Brave.Builder("jedis-interceptor-test");
    builder.spanCollector(HttpSpanCollector.create("http://192.168.150.132:9411", new EmptySpanCollectorMetricsHandler()));
    builder.traceSampler(Sampler.ALWAYS_SAMPLE);
    Brave brave = builder.build();
    JaRedisInterceptor.setClientTracer(brave.clientTracer());

    JedisPoolConfig config = new JedisPoolConfig();
    JaRedisPool proxyPool = new JaRedisPool(config, "127.0.0.1", 6379);
    Jedis jedis = proxyPool.getResource();
    jedis.set("hello", "world");
    Assert.assertEquals(jedis.get("hello"), "world");
    jedis.hgetAll("hello-map");
    jedis.close();
    // sleep 3s in case spanCollector not flushed
    Thread.sleep(3000);
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:19,代码来源:TestJedisProxyPool.java

示例5: Client

import redis.clients.jedis.JedisPoolConfig; //导入依赖的package包/类
/**
 * Create a new client to a RediSearch index
 * @param indexName the name of the index we are connecting to or creating
 * @param host the redis host
 * @param port the redis pot
 */
public Client(String indexName, String host, int port, int timeout, int poolSize) {
    JedisPoolConfig conf = new JedisPoolConfig();
    conf.setMaxTotal(poolSize);
    conf.setTestOnBorrow(false);
    conf.setTestOnReturn(false);
    conf.setTestOnCreate(false);
    conf.setTestWhileIdle(false);
    conf.setMinEvictableIdleTimeMillis(60000);
    conf.setTimeBetweenEvictionRunsMillis(30000);
    conf.setNumTestsPerEvictionRun(-1);
    conf.setFairness(true);

    pool = new JedisPool(conf, host, port, timeout);

    this.indexName = indexName;
    this.commands = new Commands.SingleNodeCommands();
}
 
开发者ID:RedisLabs,项目名称:JRediSearch,代码行数:24,代码来源:Client.java

示例6: connect

import redis.clients.jedis.JedisPoolConfig; //导入依赖的package包/类
@Override
public void connect(NURL nurl) {
	super.connect(nurl);
	this.retryPeriod = nurl.getParameter("retryPeriod", retryPeriod);

	JedisPoolConfig config = new JedisPoolConfig();
	Map<String, String> parameters = nurl.getParameters();
	if (parameters != null) {
		if (!parameters.isEmpty()) {
			try {
				Beans.copyProperties(config, nurl.getParameters());
			} catch (Exception e) {
				logger.error("The copy properties exception.", e);
			}
		}
	}

	jedisPool = new JedisPool(config, nurl.getHost(), nurl.getPort());
}
 
开发者ID:yu120,项目名称:coon,代码行数:20,代码来源:RedisMconf.java

示例7: 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

示例8: createJedisPoolConfig

import redis.clients.jedis.JedisPoolConfig; //导入依赖的package包/类
private static JedisPoolConfig createJedisPoolConfig(Builder builder) {
    JedisPoolConfig config = new JedisPoolConfig();
    config.setMaxTotal(builder.maxTotal);
    config.setMaxIdle(builder.maxIdle);
    config.setMinIdle(builder.minIdle);
    config.setLifo(builder.lifo);
    config.setFairness(builder.fairness);
    config.setMaxWaitMillis(builder.maxWaitMillis);
    config.setMinEvictableIdleTimeMillis(builder.minEvictableIdleTimeMillis);
    config.setSoftMinEvictableIdleTimeMillis(builder.softMinEvictableIdleTimeMillis);
    config.setNumTestsPerEvictionRun(builder.numTestsPerEvictionRun);
    config.setTestOnCreate(builder.testOnCreate);
    config.setTestOnBorrow(builder.testOnBorrow);
    config.setTestOnReturn(builder.testOnReturn);
    config.setTestWhileIdle(builder.testWhileIdle);
    config.setTimeBetweenEvictionRunsMillis(builder.timeBetweenEvictionRunsMillis);
    config.setEvictionPolicyClassName(builder.evictionPolicyClassName);
    config.setBlockWhenExhausted(builder.blockWhenExhausted);
    config.setJmxEnabled(builder.jmxEnabled);
    config.setJmxNameBase(builder.jmxNameBase);
    config.setJmxNamePrefix(builder.jmxNamePrefix);
    return config;
}
 
开发者ID:vy,项目名称:log4j2-redis-appender,代码行数:24,代码来源:RedisConnectionPoolConfig.java

示例9: redisConnectionFactory

import redis.clients.jedis.JedisPoolConfig; //导入依赖的package包/类
@Bean
public RedisConnectionFactory redisConnectionFactory() {
    String default_host = "localhost";
    int port = 6379;
    String host = null;
    { // setup the host using the env vars
        host = System.getenv().get(SELDON_CLUSTER_MANAGER_REDIS_HOST_KEY);
        if (host == null) {
            logger.error(String.format("FAILED to find env var [%s]", SELDON_CLUSTER_MANAGER_REDIS_HOST_KEY));
            host = default_host;
        }
    }

    logger.info(String.format("setting up connection factory, host[%s] port[%d]", host, port));
    JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
    jedisConnectionFactory.setHostName(host);
    jedisConnectionFactory.setPort(port);
    jedisConnectionFactory.setPassword("");
    jedisConnectionFactory.setUsePool(true);
    jedisConnectionFactory.setPoolConfig(new JedisPoolConfig());
    return jedisConnectionFactory;
}
 
开发者ID:SeldonIO,项目名称:seldon-core,代码行数:23,代码来源:RedisConfig.java

示例10: nonDefaultDatabase

import redis.clients.jedis.JedisPoolConfig; //导入依赖的package包/类
@Test
public void nonDefaultDatabase() {
  JedisPool pool0 = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000,
      "foobared");
  Jedis jedis0 = pool0.getResource();
  jedis0.set("foo", "bar");
  assertEquals("bar", jedis0.get("foo"));
  pool0.returnResource(jedis0);
  pool0.destroy();
  assertTrue(pool0.isClosed());

  JedisPool pool1 = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000,
      "foobared", 1);
  Jedis jedis1 = pool1.getResource();
  assertNull(jedis1.get("foo"));
  pool1.returnResource(jedis1);
  pool1.destroy();
  assertTrue(pool1.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:20,代码来源:JedisPoolTest.java

示例11: selectDatabaseOnActivation

import redis.clients.jedis.JedisPoolConfig; //导入依赖的package包/类
@Test
public void selectDatabaseOnActivation() {
  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000,
      "foobared");

  Jedis jedis0 = pool.getResource();
  assertEquals(0L, jedis0.getDB().longValue());

  jedis0.select(1);
  assertEquals(1L, jedis0.getDB().longValue());

  pool.returnResource(jedis0);

  Jedis jedis1 = pool.getResource();
  assertTrue("Jedis instance was not reused", jedis1 == jedis0);
  assertEquals(0L, jedis1.getDB().longValue());

  pool.returnResource(jedis1);
  pool.destroy();
  assertTrue(pool.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:22,代码来源:JedisPoolTest.java

示例12: getNumActiveReturnsTheCorrectNumber

import redis.clients.jedis.JedisPoolConfig; //导入依赖的package包/类
@Test
public void getNumActiveReturnsTheCorrectNumber() {
  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000);
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "bar");
  assertEquals("bar", jedis.get("foo"));

  assertEquals(1, pool.getNumActive());

  Jedis jedis2 = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "bar");

  assertEquals(2, pool.getNumActive());

  pool.returnResource(jedis);
  assertEquals(1, pool.getNumActive());

  pool.returnResource(jedis2);

  assertEquals(0, pool.getNumActive());

  pool.destroy();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:26,代码来源:JedisPoolTest.java

示例13: testAddObject

import redis.clients.jedis.JedisPoolConfig; //导入依赖的package包/类
@Test
public void testAddObject() {
  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000);
  pool.addObjects(1);
  assertEquals(pool.getNumIdle(), 1);
  pool.destroy();

}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:9,代码来源:JedisPoolTest.java

示例14: testCloseConnectionOnMakeObject

import redis.clients.jedis.JedisPoolConfig; //导入依赖的package包/类
@Test
public void testCloseConnectionOnMakeObject() {
  JedisPoolConfig config = new JedisPoolConfig();
  config.setTestOnBorrow(true);
  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000,
      "wrong pass");
  Jedis jedis = new Jedis("redis://:[email protected]:6379/");
  int currentClientCount = getClientCount(jedis.clientList());
  try {
    pool.getResource();
    fail("Should throw exception as password is incorrect.");
  } catch (Exception e) {
    assertEquals(currentClientCount, getClientCount(jedis.clientList()));
  }

}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:17,代码来源:JedisPoolTest.java

示例15: 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


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