本文整理汇总了Java中redis.clients.jedis.ScanResult.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java ScanResult.getResult方法的具体用法?Java ScanResult.getResult怎么用?Java ScanResult.getResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.ScanResult
的用法示例。
在下文中一共展示了ScanResult.getResult方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: hgetAll
import redis.clients.jedis.ScanResult; //导入方法依赖的package包/类
public Map<String, String> hgetAll(String key) {
Map<String, String> m = new HashMap<>();
JedisCommands dyno = dynoClient;
int cursor = 0;
do {
ScanResult<Entry<String, String>> sr = dyno.hscan(key, "" + cursor);
cursor = Integer.parseInt(sr.getStringCursor());
for (Entry<String, String> r : sr.getResult()) {
m.put(r.getKey(), r.getValue());
}
} while (cursor > 0);
return m;
}
示例4: processElement
import redis.clients.jedis.ScanResult; //导入方法依赖的package包/类
@ProcessElement
public void processElement(ProcessContext processContext) throws Exception {
ScanParams scanParams = new ScanParams();
scanParams.match(processContext.element());
String cursor = ScanParams.SCAN_POINTER_START;
boolean finished = false;
while (!finished) {
ScanResult<String> scanResult = jedis.scan(cursor, scanParams);
List<String> keys = scanResult.getResult();
Pipeline pipeline = jedis.pipelined();
if (keys != null) {
for (String key : keys) {
pipeline.get(key);
}
List<Object> values = pipeline.syncAndReturnAll();
for (int i = 0; i < values.size(); i++) {
processContext.output(KV.of(keys.get(i), (String) values.get(i)));
}
}
cursor = scanResult.getStringCursor();
if (cursor.equals("0")) {
finished = true;
}
}
}
示例5: migrateDel
import redis.clients.jedis.ScanResult; //导入方法依赖的package包/类
/** current redis is del state */
private void migrateDel(RedisClient curr_client) {
String flag = this.getClassName() + ".migrateDel";
try {
ScanResult<String> keys = this.listKeys(curr_client, 0);
if (null == keys || keys.getCursor() == 0) {
return;
}
while (0 != keys.getCursor()) {
for (String key : keys.getResult()) {
RedisClient next_cli = ClusterAlgo.getNextRedis(logIndex, key);
if (null == next_cli)
continue;
if (KEY_LOCK.equals(key))
continue;
String ret = curr_client.migrate(logIndex, key, next_cli);
FRCLogger.getInstance().info(logIndex, flag, "ret:{} source:{} dest:{}", null,
ret, JSONProvider.toJSONString(logIndex, curr_client),
JSONProvider.toJSONString(logIndex, next_cli));
}
keys = this.listKeys(curr_client, keys.getCursor());
}
} catch (Exception e) {
FRCLogger.getInstance().warn(logIndex, flag, "exception", e);
}
}
示例6: migrateAdd
import redis.clients.jedis.ScanResult; //导入方法依赖的package包/类
/** current redis is added state */
private void migrateAdd(RedisClient curr_client) {
String flag = this.getClassName() + ".migrateAdd";
try {
List<Long> nextList = ClusterAlgo.getInstanceNext(logIndex,
curr_client.getRedis_name());
if (null == nextList || nextList.isEmpty())
return;
for (Long next_hash : nextList) {
RedisClient target_client = ClusterAlgo.getMapRedis().get(next_hash);
if (null == target_client) {
FRCLogger.getInstance().warn(logIndex, flag, "redis_hash: {}", null, next_hash);
continue;
}
ScanResult<String> keys = this.listKeys(target_client, 0);
if (null == keys || keys.getCursor() == 0)
continue;
while (0 != keys.getCursor()) {
for (String key : keys.getResult()) {
RedisClient revert_cli = ClusterAlgo.getCurrentRedis(logIndex, key);
if (null == revert_cli)
continue;
if (revert_cli.getRedis_name().equals(curr_client.getRedis_name())) {
if (KEY_LOCK.equals(key))
continue;
String ret = target_client.migrate(logIndex, key, curr_client);
FRCLogger.getInstance().info(logIndex, flag,
"ret:{} source:{} dest:{}", null, ret,
JSONProvider.toJSONString(logIndex, target_client),
JSONProvider.toJSONString(logIndex, curr_client));
}
}
keys = this.listKeys(target_client, keys.getCursor());
}
}
} catch (Exception e) {
FRCLogger.getInstance().warn(logIndex, flag, "exception", e);
}
}