本文整理匯總了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);
}