本文整理汇总了Java中redis.clients.jedis.JedisPool.returnResourceObject方法的典型用法代码示例。如果您正苦于以下问题:Java JedisPool.returnResourceObject方法的具体用法?Java JedisPool.returnResourceObject怎么用?Java JedisPool.returnResourceObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.JedisPool
的用法示例。
在下文中一共展示了JedisPool.returnResourceObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllKeys
import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
public Set<String> getAllKeys() {
Set<String> keysSet = new HashSet();
Collection<JedisPool> poolCollection = jedisCluster.getClusterNodes().values();
Iterator iterator = poolCollection.iterator();
while(iterator.hasNext()) {
JedisPool jedisPool = (JedisPool)iterator.next();
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
keysSet.addAll(jedis.keys("*"));
} catch (Exception var10) {
throw new RuntimeException(var10);
} finally {
jedisPool.returnResourceObject(jedis);
}
}
return keysSet;
}
示例2: publish
import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
public void publish(String channel, String message) {
Collection<JedisPool> poolCollection = jedisCluster.getClusterNodes().values();
Iterator<JedisPool> iterator = poolCollection.iterator();
if (iterator.hasNext()) {
JedisPool jedisPool = (JedisPool)iterator.next();
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
jedis.publish(channel, message);
} catch (Exception var11) {
throw new RuntimeException(var11);
} finally {
jedisPool.returnResourceObject(jedis);
}
}
}
示例3: subscribe
import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
public void subscribe(JedisPubSub jedisPubSub, String channel) {
Collection<JedisPool> poolCollection = jedisCluster.getClusterNodes().values();
Iterator iterator = poolCollection.iterator();
while(iterator.hasNext()) {
JedisPool jedisPool = (JedisPool)iterator.next();
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
jedis.subscribe(jedisPubSub, new String[]{channel});
} catch (Exception var11) {
throw new RuntimeException(var11);
} finally {
jedisPool.returnResourceObject(jedis);
}
}
}
示例4: returnNullObjectShouldNotFail
import redis.clients.jedis.JedisPool; //导入方法依赖的package包/类
@Test
public void returnNullObjectShouldNotFail() {
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000,
"foobared", 0, "my_shiny_client_name");
pool.returnBrokenResource(null);
pool.returnResource(null);
pool.returnResourceObject(null);
}