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