本文整理汇总了Java中redis.clients.jedis.ScanResult类的典型用法代码示例。如果您正苦于以下问题:Java ScanResult类的具体用法?Java ScanResult怎么用?Java ScanResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScanResult类属于redis.clients.jedis包,在下文中一共展示了ScanResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanHSet
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
/**
* 全局扫描hset
*
* @param match field匹配模式
*/
public List<Map.Entry<String, String>> scanHSet(String domain, String match) {
try (ShardedJedis shardedJedis = shardedJedisPool.getResource()) {
int cursor = 0;
ScanParams scanParams = new ScanParams();
scanParams.match(match);
Jedis jedis = shardedJedis.getShard(domain);
ScanResult<Map.Entry<String, String>> scanResult;
List<Map.Entry<String, String>> list = new ArrayList<Map.Entry<String, String>>();
do {
scanResult = jedis.hscan(domain, String.valueOf(cursor), scanParams);
list.addAll(scanResult.getResult());
cursor = Integer.parseInt(scanResult.getStringCursor());
} while (cursor > 0);
return list;
}
}
示例2: zscan
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
@Test
public void zscan() {
jedis.zadd("foo", 1, "a");
jedis.zadd("foo", 2, "b");
ScanResult<Tuple> result = jedis.zscan("foo", SCAN_POINTER_START);
assertEquals(SCAN_POINTER_START, result.getStringCursor());
assertFalse(result.getResult().isEmpty());
// binary
jedis.zadd(bfoo, 1, ba);
jedis.zadd(bfoo, 1, bb);
ScanResult<Tuple> bResult = jedis.zscan(bfoo, SCAN_POINTER_START_BINARY);
assertArrayEquals(SCAN_POINTER_START_BINARY, bResult.getCursorAsBytes());
assertFalse(bResult.getResult().isEmpty());
}
示例3: sscan
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
@Test
public void sscan() {
jedis.sadd("foo", "a", "b");
ScanResult<String> result = jedis.sscan("foo", SCAN_POINTER_START);
assertEquals(SCAN_POINTER_START, result.getStringCursor());
assertFalse(result.getResult().isEmpty());
// binary
jedis.sadd(bfoo, ba, bb);
ScanResult<byte[]> bResult = jedis.sscan(bfoo, SCAN_POINTER_START_BINARY);
assertArrayEquals(SCAN_POINTER_START_BINARY, bResult.getCursorAsBytes());
assertFalse(bResult.getResult().isEmpty());
}
示例4: scan
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
@Test
public void scan() {
jedis.set("b", "b");
jedis.set("a", "a");
ScanResult<String> result = jedis.scan(SCAN_POINTER_START);
assertEquals(SCAN_POINTER_START, result.getStringCursor());
assertFalse(result.getResult().isEmpty());
// binary
ScanResult<byte[]> bResult = jedis.scan(SCAN_POINTER_START_BINARY);
assertArrayEquals(SCAN_POINTER_START_BINARY, bResult.getCursorAsBytes());
assertFalse(bResult.getResult().isEmpty());
}
示例5: hscan
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
@Test
public void hscan() {
jedis.hset("foo", "b", "b");
jedis.hset("foo", "a", "a");
ScanResult<Map.Entry<String, String>> result = jedis.hscan("foo", SCAN_POINTER_START);
assertEquals(SCAN_POINTER_START, result.getStringCursor());
assertFalse(result.getResult().isEmpty());
// binary
jedis.hset(bfoo, bbar, bcar);
ScanResult<Map.Entry<byte[], byte[]>> bResult = jedis.hscan(bfoo, SCAN_POINTER_START_BINARY);
assertArrayEquals(SCAN_POINTER_START_BINARY, bResult.getCursorAsBytes());
assertFalse(bResult.getResult().isEmpty());
}
示例6: hscan
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
@Override
public List<Map.Entry<String, String>> hscan(final String bizkey,
final String nameSpace, final String match) {
final String key = CacheUtils.getKeyByNamespace(bizkey,nameSpace);
return this.performFunction(key, new CallBack<List<Map.Entry<String, String>>>() {
public List<Map.Entry<String, String>> invoke(Jedis jedis) {
try{
int cursor = 0;
ScanParams scanParams = new ScanParams();
scanParams.match(match);
ScanResult<Map.Entry<String,String>> scanResult;
List<Map.Entry<String, String>> res = new ArrayList<Map.Entry<String, String>>();
do {
scanResult = jedis.hscan(key, String.valueOf(cursor), scanParams);
res.addAll(scanResult.getResult());
cursor = Integer.parseInt(scanResult.getStringCursor());
} while (cursor > 0);
return res;
} catch (Exception ex) {
logger.error("hscan key:"+key+",match:"+match+",error:", ex);
}
return null;
}
});
}
示例7: sscan
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
@Override
public Set<String> sscan(final String bizkey,final String nameSpace,
final String match) {
final String key = CacheUtils.getKeyByNamespace(bizkey,nameSpace);
return this.performFunction(key, new CallBack<Set<String>>() {
public Set<String> invoke(Jedis jedis) {
try{
int cursor = 0;
ScanParams scanParams = new ScanParams();
scanParams.match(match);
ScanResult<String> scanResult;
Set<String> res = new HashSet<String>();
do {
scanResult = jedis.sscan(key, String.valueOf(cursor), scanParams);
res.addAll(scanResult.getResult());
cursor = Integer.parseInt(scanResult.getStringCursor());
} while (cursor > 0);
return res;
} catch (Exception ex) {
logger.error("sscan key:"+key+",match:"+match+",error:", ex);
}
return null;
}
});
}
示例8: listKeys0
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
private void listKeys0() {
if (StringUtils.isBlank(this.txtKeyPattern.getText())) {
this.txtKeyPattern.setText("*");
}
String pattern = this.txtKeyPattern.getText();
int limit = Integer.parseInt(String.valueOf(cmbLimit.getValue()));
ObservableList<KeyItem> items = this.tblKeys.getItems();
items.clear();
if (pattern.trim().length() > 0) {
try (Jedis jedis = JedisManager.getJedis()) {
ScanParams scanParams = new ScanParams().match(pattern).count(limit);
ScanResult<String> result = jedis.scan(ScanParams.SCAN_POINTER_START, scanParams);
result.getResult().forEach(key -> {
String type = jedis.type(key);
items.add(new KeyItem(key, type));
});
}
}
}
示例9: removeAll
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
@Override
public Completable removeAll() {
return Completable.fromAction(() -> {
Set<String> matchingKeys = new HashSet<>();
ScanParams params = new ScanParams();
params.match(prefixAndDelim + "*");
try(Jedis jedis = pool.getResource()) {
String nextCursor = "0";
do {
ScanResult<String> scanResult = jedis.scan(nextCursor, params);
List<String> keys = scanResult.getResult();
nextCursor = scanResult.getStringCursor();
matchingKeys.addAll(keys);
} while(!nextCursor.equals("0"));
jedis.del(matchingKeys.toArray(new String[matchingKeys.size()]));
}
});
}
示例10: hscan
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
@Override
public List<Map.Entry<String, String>> hscan(final String bizkey, final String nameSpace, final String match) {
final String key = CacheUtils.getKeyByNamespace(bizkey, nameSpace);
return this.performFunction(key, new CallBack<List<Map.Entry<String, String>>>() {
public List<Map.Entry<String, String>> invoke(Jedis jedis) {
try {
int cursor = 0;
ScanParams scanParams = new ScanParams();
scanParams.match(match);
ScanResult<Map.Entry<String, String>> scanResult;
List<Map.Entry<String, String>> res = new ArrayList<Map.Entry<String, String>>();
do {
scanResult = jedis.hscan(key, String.valueOf(cursor), scanParams);
res.addAll(scanResult.getResult());
cursor = Integer.parseInt(scanResult.getStringCursor());
} while (cursor > 0);
return res;
} catch (Exception ex) {
logger.error("hscan key:" + key + ",match:" + match + ",error:", ex);
}
return null;
}
});
}
示例11: sscan
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
@Override
public Set<String> sscan(final String bizkey, final String nameSpace, final String match) {
final String key = CacheUtils.getKeyByNamespace(bizkey, nameSpace);
return this.performFunction(key, new CallBack<Set<String>>() {
public Set<String> invoke(Jedis jedis) {
try {
int cursor = 0;
ScanParams scanParams = new ScanParams();
scanParams.match(match);
ScanResult<String> scanResult;
Set<String> res = new HashSet<String>();
do {
scanResult = jedis.sscan(key, String.valueOf(cursor), scanParams);
res.addAll(scanResult.getResult());
cursor = Integer.parseInt(scanResult.getStringCursor());
} while (cursor > 0);
return res;
} catch (Exception ex) {
logger.error("sscan key:" + key + ",match:" + match + ",error:", ex);
}
return null;
}
});
}
示例12: zscan
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
@Override
public ScanResult<Tuple> zscan(String key, String cursor, ScanParams params) {
Span span = helper.buildSpan("zscan", key);
span.setTag("cursor", cursor);
span.setTag("params", TracingHelper.toString(params.getParams()));
try {
return super.zscan(key, cursor, params);
} catch (Exception e) {
onError(e, span);
throw e;
} finally {
span.finish();
}
}
示例13: hscan
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
public Map<String, String> hscan(String key, int count) {
Map<String, String> m = new HashMap<>();
int cursor = 0;
do {
ScanResult<Entry<String, String>> sr = dynoClient.hscan(key, "" + cursor);
cursor = Integer.parseInt(sr.getStringCursor());
for (Entry<String, String> r : sr.getResult()) {
m.put(r.getKey(), r.getValue());
}
if(m.size() > count) {
break;
}
} while (cursor > 0);
return m;
}
示例14: hkeys
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
public Set<String> hkeys(String key) {
logger.trace("hkeys {}", key);
JedisCommands client = dynoClient;
Set<String> keys = new HashSet<>();
int cursor = 0;
do {
ScanResult<Entry<String, String>> sr = client.hscan(key, "" + cursor);
cursor = Integer.parseInt(sr.getStringCursor());
List<Entry<String, String>> result = sr.getResult();
for (Entry<String, String> e : result) {
keys.add(e.getKey());
}
} while (cursor > 0);
return keys;
}
示例15: smembers
import redis.clients.jedis.ScanResult; //导入依赖的package包/类
public Set<String> smembers(String key) {
logger.trace("smembers {}", key);
JedisCommands client = dynoClient;
Set<String> r = new HashSet<>();
int cursor = 0;
ScanParams sp = new ScanParams();
sp.count(50);
do {
ScanResult<String> sr = client.sscan(key, "" + cursor, sp);
cursor = Integer.parseInt(sr.getStringCursor());
r.addAll(sr.getResult());
} while (cursor > 0);
return r;
}