本文整理汇总了Java中redis.clients.jedis.ScanParams类的典型用法代码示例。如果您正苦于以下问题:Java ScanParams类的具体用法?Java ScanParams怎么用?Java ScanParams使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScanParams类属于redis.clients.jedis包,在下文中一共展示了ScanParams类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanHSet
import redis.clients.jedis.ScanParams; //导入依赖的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: hscan
import redis.clients.jedis.ScanParams; //导入依赖的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;
}
});
}
示例3: sscan
import redis.clients.jedis.ScanParams; //导入依赖的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;
}
});
}
示例4: listKeys0
import redis.clients.jedis.ScanParams; //导入依赖的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));
});
}
}
}
示例5: removeAll
import redis.clients.jedis.ScanParams; //导入依赖的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()]));
}
});
}
示例6: hscan
import redis.clients.jedis.ScanParams; //导入依赖的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.ScanParams; //导入依赖的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: zscan
import redis.clients.jedis.ScanParams; //导入依赖的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();
}
}
示例9: smembers
import redis.clients.jedis.ScanParams; //导入依赖的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;
}
示例10: scan
import redis.clients.jedis.ScanParams; //导入依赖的package包/类
/**
* 返回指定数量的匹配值
*
* @param cursor
* @param count
* @param patterns
* @return
*/
public ScanResult<String> scan(final String cursor, final Integer count, final String... patterns) {
ScanParams params = new ScanParams();
for (String pattern : patterns) {
params.match(pattern);
}
if (null != count) {
params.count(count);
}
if (RedisConstants.isInUse()) {
return getTemplate().execute(new JedisCallBackHandler<ScanResult<String>>() {
public ScanResult<String> invoke(Jedis jedis) {
return jedis.scan(cursor, params);
}
});
} else {
return null;
}
}
示例11: hscan
import redis.clients.jedis.ScanParams; //导入依赖的package包/类
/**
* 命令用于迭代哈希键中的键值对
*
* @param key
* @param cursor
* @param count
* @param patterns
* @return
*/
public ScanResult<Entry<String, String>> hscan(final String key, final String cursor, final Integer count,
final String... patterns) {
ScanParams params = new ScanParams();
for (String pattern : patterns) {
params.match(pattern);
}
if (null != count) {
params.count(count);
}
if (RedisConstants.isInUse()) {
return getTemplate().execute(new JedisCallBackHandler<ScanResult<Entry<String, String>>>() {
public ScanResult<Entry<String, String>> invoke(Jedis jedis) {
return jedis.hscan(key, cursor, params);
}
});
} else {
return null;
}
}
示例12: scan
import redis.clients.jedis.ScanParams; //导入依赖的package包/类
/**
* 返回指定数量的匹配值
*
* @param cursor
* @param count
* @param patterns
* @return
*/
public ScanResult<String> scan(final String cursor, final Integer count, final String... patterns) {
ScanParams params = new ScanParams();
for (String pattern : patterns) {
params.match(pattern);
}
if (null != count) {
params.count(count);
}
if (RedisConstants.isInUse()) {
return getTemplate().executeRead(new JedisCallBackHandler<ScanResult<String>>() {
public ScanResult<String> invoke(Jedis jedis) {
return jedis.scan(cursor, params);
}
});
} else {
return null;
}
}
示例13: hscan
import redis.clients.jedis.ScanParams; //导入依赖的package包/类
/**
* 命令用于迭代哈希键中的键值对
*
* @param key
* @param cursor
* @param count
* @param patterns
* @return
*/
public ScanResult<Entry<String, String>> hscan(final String key, final String cursor, final Integer count,
final String... patterns) {
ScanParams params = new ScanParams();
for (String pattern : patterns) {
params.match(pattern);
}
if (null != count) {
params.count(count);
}
if (RedisConstants.isInUse()) {
return getTemplate().executeRead(new JedisCallBackHandler<ScanResult<Entry<String, String>>>() {
public ScanResult<Entry<String, String>> invoke(Jedis jedis) {
return jedis.hscan(key, cursor, params);
}
});
} else {
return null;
}
}
示例14: getAll
import redis.clients.jedis.ScanParams; //导入依赖的package包/类
@Override
public Collection<SecurityInfo> getAll() {
try (Jedis j = pool.getResource()) {
ScanParams params = new ScanParams().match(SEC_EP + "*").count(100);
Collection<SecurityInfo> list = new LinkedList<>();
String cursor = "0";
do {
ScanResult<byte[]> res = j.scan(cursor.getBytes(), params);
for (byte[] key : res.getResult()) {
byte[] element = j.get(key);
list.add(deserialize(element));
}
cursor = res.getStringCursor();
} while (!"0".equals(cursor));
return list;
}
}
示例15: run
import redis.clients.jedis.ScanParams; //导入依赖的package包/类
@Override
public void run() {
try (Jedis j = pool.getResource()) {
ScanParams params = new ScanParams().match(REG_EP + "*").count(100);
String cursor = "0";
do {
ScanResult<byte[]> res = j.scan(cursor.getBytes(), params);
for (byte[] key : res.getResult()) {
Registration r = deserializeReg(j.get(key));
if (!r.isAlive(gracePeriod)) {
Deregistration dereg = removeRegistration(j, r.getId(), true);
if (dereg != null)
expirationListener.registrationExpired(dereg.getRegistration(),
dereg.getObservations());
}
}
cursor = res.getStringCursor();
} while (!"0".equals(cursor));
} catch (Exception e) {
LOG.warn("Unexpected Exception while registration cleaning", e);
}
}