本文整理匯總了Java中redis.clients.jedis.Jedis.smembers方法的典型用法代碼示例。如果您正苦於以下問題:Java Jedis.smembers方法的具體用法?Java Jedis.smembers怎麽用?Java Jedis.smembers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redis.clients.jedis.Jedis
的用法示例。
在下文中一共展示了Jedis.smembers方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSet
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
* 獲取緩存
*
* @param key 鍵
* @return 值
*/
public static Set<String> getSet(String key) {
Set<String> value = null;
Jedis jedis = null;
try {
jedis = getResource();
if (jedis.exists(key)) {
value = jedis.smembers(key);
logger.debug("getSet {} = {}", key, value);
}
} catch (Exception e) {
logger.warn("getSet {} = {}", key, value, e);
} finally {
returnResource(jedis);
}
return value;
}
示例2: getObjectSet
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
* 獲取緩存
*
* @param key 鍵
* @return 值
*/
public static Set<Object> getObjectSet(String key) {
Set<Object> value = null;
Jedis jedis = null;
try {
jedis = getResource();
if (jedis.exists(getBytesKey(key))) {
value = Sets.newHashSet();
Set<byte[]> set = jedis.smembers(getBytesKey(key));
for (byte[] bs : set) {
value.add(toObject(bs));
}
logger.debug("getObjectSet {} = {}", key, value);
}
} catch (Exception e) {
logger.warn("getObjectSet {} = {}", key, value, e);
} finally {
returnResource(jedis);
}
return value;
}
示例3: smembersString
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public Set<String> smembersString(String key) {
Jedis jedis = null;
boolean success = true;
Set<String> ret = null;
try {
jedis = jedisPool.getResource();
if (jedis == null) {
success = false;
return ret;
}
ret = jedis.smembers(key);
} catch (Exception e) {
success = false;
returnBrokenResource(jedis, "smembersString" + key, e);
} finally {
releaseReidsSource(success, jedis);
}
return ret;
}
示例4: sMembers
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public Set<String> sMembers(String key) {
int tries = 0;
boolean sucess = false;
Set<String> retVal = null;
do {
tries++;
try {
Jedis jedis = pool.getResource();
retVal = jedis.smembers(key);
jedis.close();
sucess = true;
} catch (JedisConnectionException ex) {
log.error(RedisConstants.CONN_FAILED_RETRY_MSG + tries);
if (tries == numRetries)
throw ex;
}
} while (!sucess && tries <= numRetries);
return retVal;
}
示例5: getVByList
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
* 往redis裏取set整個集合
*
* @param <T>
* @param setKey
* @param start
* @param end
* @param requiredType
* @return
*/
@SuppressWarnings("unchecked")
public <T> Set<T> getVByList(String setKey,Class<T> requiredType) throws Exception {
Jedis jds = null;
try {
jds = getJedis();
jds.select(0);
Set<T> set = new TreeSet<T>();
Set<byte[]> xx = jds.smembers(setKey.getBytes());
for (byte[] bs : xx) {
T t = SerializeUtil.deserialize(bs, requiredType);
set.add(t);
}
return set;
} catch (Exception e) {
throw e;
} finally {
if(jds != null)
{
jds.close();
}
}
}
示例6: getSetByKey
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
* 取set
* @param key
* @return
*/
public Set<String> getSetByKey(String key) throws Exception {
Jedis jds = null;
try {
jds = getJedis();
jds.select(0);
Set<String> result = jds.smembers(key);
return result;
} catch (Exception e) {
throw e;
} finally {
if(jds != null)
{
jds.close();
}
}
}
示例7: getSet
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
* 獲取緩存
* @param key 鍵
* @return 值
*/
public static Set<String> getSet(String key) {
Set<String> value = null;
Jedis jedis = null;
try {
jedis = getResource();
if (jedis.exists(key)) {
value = jedis.smembers(key);
logger.debug("getSet {} = {}", key, value);
}
} catch (Exception e) {
logger.warn("getSet {} = {}", key, value, e);
} finally {
returnResource(jedis);
}
return value;
}
示例8: getObjectSet
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
* 獲取緩存
* @param key 鍵
* @return 值
*/
public static Set<Object> getObjectSet(String key) {
Set<Object> value = null;
Jedis jedis = null;
try {
jedis = getResource();
if (jedis.exists(getBytesKey(key))) {
value = Sets.newHashSet();
Set<byte[]> set = jedis.smembers(getBytesKey(key));
for (byte[] bs : set){
value.add(toObject(bs));
}
logger.debug("getObjectSet {} = {}", key, value);
}
} catch (Exception e) {
logger.warn("getObjectSet {} = {}", key, value, e);
} finally {
returnResource(jedis);
}
return value;
}
示例9: loadPlayer
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public void loadPlayer(UUID player)
{
try{
FriendPlayer friendPlayer = new FriendPlayer(player);
Jedis jedis = api.getBungeeResource();
Set<String> smembers = jedis.smembers(key + player);
jedis.close();
for (String friend : smembers)
{
friendPlayer.addFriend(UUID.fromString(friend));
}
cache.put(player, friendPlayer);
}catch (Exception e)
{
e.printStackTrace();
}
}
示例10: ChatHandleListener
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public ChatHandleListener(APIPlugin plugin)
{
super(plugin);
Jedis jedis = api.getBungeeResource();
for (String blacklisted : jedis.smembers("chat:blacklist"))
{
if (blacklisted.contains("="))
blacklist.put(blacklisted.split("=")[0], blacklisted.split("=")[1]);
else
blacklist.put(blacklisted, null);
}
jedis.close();
}
示例11: smembers
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public Set<String> smembers(String key) {
Jedis jedis = null;
Set<String> res = null;
try {
jedis = pool.getResource();
res = jedis.smembers(key);
} catch (Exception e) {
LOGGER.error(e.getMessage());
} finally {
returnResource(pool, jedis);
}
return res;
}
示例12: run
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public void run()
{
Jedis jedis = databaseConnector.getBungeeResource();
Set<String> whiteList = jedis.smembers("proxys");
jedis.close();
plugin.refreshIps(whiteList);
}