本文整理了Java中redis.clients.jedis.Jedis.smembers()
方法的一些代码示例,展示了Jedis.smembers()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.smembers()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:smembers
[英]Return all the members (elements) of the set value stored at key. This is just syntax glue for #sinter(String...).
Time complexity O(N)
[中]返回键中存储的集合值的所有成员(元素)。这只是#sinter(String…)的语法胶水。
时间复杂度O(N)
代码示例来源:origin: sohutv/cachecloud
@Override
public Set<String> execute(Jedis connection) {
return connection.smembers(key);
}
}.run(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public Set<byte[]> execute(Jedis connection) {
return connection.smembers(key);
}
}.runBinary(key);
代码示例来源:origin: sohutv/cachecloud
public Set<byte[]> execute(Jedis connection) {
return connection.smembers(keyByte);
}
}.runBinary(keyByte);
代码示例来源:origin: sohutv/cachecloud
@Override
public Set<String> smembers(String key) {
Jedis j = getShard(key);
return j.smembers(key);
}
代码示例来源:origin: sohutv/cachecloud
@Override
public Set<byte[]> smembers(byte[] key) {
Jedis j = getShard(key);
return j.smembers(key);
}
代码示例来源:origin: caoxinyu/RedisClient
@Override
protected void command() {
jedis.select(db);
values = jedis.smembers(key);
}
代码示例来源:origin: Netflix/conductor
@Override
public Set<String> smembers(String key) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.smembers(key);
} finally {
if (jedis != null)
jedis.close();
}
}
代码示例来源:origin: jfinal/jfinal
/**
* 返回集合 key 中的所有成员。
* 不存在的 key 被视为空集合。
*/
@SuppressWarnings("rawtypes")
public Set smembers(Object key) {
Jedis jedis = getJedis();
try {
Set<byte[]> data = jedis.smembers(keyToBytes(key));
Set<Object> result = new HashSet<Object>();
valueSetFromBytesSet(data, result);
return result;
}
finally {close(jedis);}
}
代码示例来源:origin: shuzheng/zheng
Set<String> clientSessionIds = jedis.smembers(ZHENG_UPMS_CLIENT_SESSION_IDS + "_" + code);
for (String clientSessionId : clientSessionIds) {
jedis.del(ZHENG_UPMS_CLIENT_SESSION_ID + "_" + clientSessionId);
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Set<byte[]> sDiff(byte[]... keys) {
Assert.notNull(keys, "Keys must not be null!");
Assert.noNullElements(keys, "Keys must not contain null elements!");
if (ClusterSlotHashUtil.isSameSlotForAllKeys(keys)) {
try {
return connection.getCluster().sdiff(keys);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
byte[] source = keys[0];
byte[][] others = Arrays.copyOfRange(keys, 1, keys.length);
ByteArraySet values = new ByteArraySet(sMembers(source));
Collection<Set<byte[]>> resultList = connection.getClusterCommandExecutor()
.executeMultiKeyCommand(
(JedisMultiKeyClusterCommandCallback<Set<byte[]>>) (client, key) -> client.smembers(key),
Arrays.asList(others))
.resultsAsList();
if (values.isEmpty()) {
return Collections.emptySet();
}
for (Set<byte[]> singleNodeValue : resultList) {
values.removeAll(singleNodeValue);
}
return values.asRawSet();
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Set<byte[]> sUnion(byte[]... keys) {
Assert.notNull(keys, "Keys must not be null!");
Assert.noNullElements(keys, "Keys must not contain null elements!");
if (ClusterSlotHashUtil.isSameSlotForAllKeys(keys)) {
try {
return connection.getCluster().sunion(keys);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
Collection<Set<byte[]>> resultList = connection.getClusterCommandExecutor()
.executeMultiKeyCommand(
(JedisMultiKeyClusterCommandCallback<Set<byte[]>>) (client, key) -> client.smembers(key),
Arrays.asList(keys))
.resultsAsList();
ByteArraySet result = new ByteArraySet();
for (Set<byte[]> entry : resultList) {
result.addAll(entry);
}
if (result.isEmpty()) {
return Collections.emptySet();
}
return result.asRawSet();
}
代码示例来源:origin: spring-projects/spring-data-redis
(JedisMultiKeyClusterCommandCallback<Set<byte[]>>) (client, key) -> client.smembers(key),
Arrays.asList(keys))
.resultsAsList();
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Set<byte[]> sMembers(byte[] key) {
Assert.notNull(key, "Key must not be null!");
try {
if (isPipelined()) {
pipeline(connection.newJedisResult(connection.getRequiredPipeline().smembers(key)));
return null;
}
if (isQueueing()) {
transaction(connection.newJedisResult(connection.getRequiredTransaction().smembers(key)));
return null;
}
return connection.getJedis().smembers(key);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: foxinmy/weixin4j
@Override
public void clear() {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
Set<String> cacheKeys = jedis.smembers(ALLKEY);
if (!cacheKeys.isEmpty()) {
cacheKeys.add(ALLKEY);
jedis.del(cacheKeys.toArray(new String[cacheKeys.size()]));
}
} finally {
if (jedis != null) {
jedis.close();
}
}
}
}
代码示例来源:origin: GoogleCloudPlatform/java-docs-samples
/**
* Looks up the set of documents containing each word. Returns the intersection of these.
*/
public ImmutableSet<String> lookup(Iterable<String> words) {
HashSet<String> documents = null;
try (Jedis jedis = pool.getResource()) {
jedis.select(TOKEN_DB);
for (String word : words) {
word = stemmer.stem(word.toLowerCase()).toString();
if (documents == null) {
documents = new HashSet();
documents.addAll(jedis.smembers(word));
} else {
documents.retainAll(jedis.smembers(word));
}
}
}
if (documents == null) {
return ImmutableSet.<String>of();
}
return ImmutableSet.<String>copyOf(documents);
}
代码示例来源:origin: jwpttcg66/NettyGameServer
public Set<String> smembersString(String key){
Jedis jedis = null;
boolean sucess = true;
Set<String> rt = null;
try {
jedis = jedisPool.getResource();
rt = jedis.smembers(key);
} catch (Exception e) {
sucess = false;
returnBrokenResource(jedis, "smembersString"+key, e);
} finally {
if (sucess && jedis != null) {
returnResource(jedis);
}
}
return rt;
}
/**
代码示例来源:origin: gresrun/jesque
/**
* {@inheritDoc}
*/
@Override
public List<String> doWork(final Jedis jedis) throws Exception {
final List<String> queueNames = new ArrayList<String>(jedis.smembers(key(QUEUES)));
Collections.sort(queueNames);
return queueNames;
}
});
代码示例来源:origin: gresrun/jesque
/**
* {@inheritDoc}
*/
@Override
public Set<String> doWork(final Jedis jedis) {
return jedis.smembers(key(QUEUES));
}
}));
代码示例来源:origin: xetorthio/johm
public Set<String> smembers() {
Jedis jedis = getResource();
Set<String> members = jedis.smembers(key());
returnResource(jedis);
return members;
}
代码示例来源:origin: gresrun/jesque
/**
* {@inheritDoc}
*/
@Override
public void setQueues(final Collection<String> queues) {
checkQueues(queues);
this.queueNames.clear();
this.queueNames.addAll((queues == ALL_QUEUES) // Using object equality on purpose
? this.jedis.smembers(key(QUEUES)) // Like '*' in other clients
: queues);
}
内容来源于网络,如有侵权,请联系作者删除!