本文整理汇总了Java中redis.clients.jedis.JedisPoolConfig.setFairness方法的典型用法代码示例。如果您正苦于以下问题:Java JedisPoolConfig.setFairness方法的具体用法?Java JedisPoolConfig.setFairness怎么用?Java JedisPoolConfig.setFairness使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.JedisPoolConfig
的用法示例。
在下文中一共展示了JedisPoolConfig.setFairness方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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;
}
示例3: init
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
@Before
public void init() {
String ip = "192.168.2.160";
Set<HostAndPort> nodes = new HashSet<>();
nodes.add(new HostAndPort(ip, 7701));
nodes.add(new HostAndPort(ip, 7702));
nodes.add(new HostAndPort(ip, 7703));
nodes.add(new HostAndPort(ip, 7704));
nodes.add(new HostAndPort(ip, 7705));
nodes.add(new HostAndPort(ip, 7706));
JedisPoolConfig pool = new JedisPoolConfig();
pool.setMaxTotal(100);
pool.setFairness(false);
pool.setNumTestsPerEvictionRun(100);
pool.setMaxWaitMillis(5000);
pool.setTestOnBorrow(true);
jedisCluster = new JedisCluster(nodes, 1000, 1000, 100, null, pool); // maxAttempt必须调大
jedisCluster.set("test", "test");
queue = new RedisDelayQueue("com.meipian", "delayqueue", jedisCluster, 60 * 1000,
new DelayQueueProcessListener() {
@Override
public void pushCallback(Message message) {
}
@Override
public void peekCallback(Message message) {
System.out.println("message----->" + message);
queue.ack(message.getId());//确认操作。将会删除消息
}
@Override
public void ackCallback(Message message) {
}
});
}