Search in sources :

Example 1 with ScanVo

use of info.xiancloud.core.support.cache.vo.ScanVo in project xian by happyyangyuan.

the class ObjectApi method scan.

@Test
public void scan() {
    String pattern = "*";
    int count = 10;
    String cursor = ScanVo.CURSOR_START_END;
    ScanVo scanVo = CacheObjectUtil.scan(pattern, count, cursor);
    while (scanVo != null) {
        List<String> keys = scanVo.getResult();
        System.out.println("游标: " + scanVo.getCursor() + ", 匹配数量: " + keys.size());
        keys.stream().forEach(key -> System.out.println(key));
        if (scanVo.isEndIteration())
            return;
        System.out.println("下一轮起始游标: " + scanVo.getCursor());
        scanVo = CacheObjectUtil.scan(pattern, count, scanVo.getCursor());
    }
}
Also used : ScanVo(info.xiancloud.core.support.cache.vo.ScanVo) Test(org.junit.Test)

Example 2 with ScanVo

use of info.xiancloud.core.support.cache.vo.ScanVo in project xian by happyyangyuan.

the class CacheObjectUtil method scan.

/**
 * @param cacheConfigBean cacheConfigBean
 * @param pattern         pattern
 * @param count           count
 * @param cursor          cursor
 * @return ScanVo
 * @deprecated 不建议使用该 API, 各种不稳定
 */
public static ScanVo scan(CacheConfigBean cacheConfigBean, String pattern, int count, String cursor) {
    UnitResponse unitResponseObject = SyncXian.call(CacheService.CACHE_SERVICE, "cacheScan", new JSONObject() {

        {
            put("cacheConfig", cacheConfigBean);
            put("pattern", pattern);
            put("count", count);
            put("cursor", cursor);
        }
    });
    unitResponseObject.throwExceptionIfNotSuccess();
    JSONObject jsonObject = unitResponseObject.getData();
    return new ScanVo(jsonObject);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) ScanVo(info.xiancloud.core.support.cache.vo.ScanVo) UnitResponse(info.xiancloud.core.message.UnitResponse)

Aggregations

ScanVo (info.xiancloud.core.support.cache.vo.ScanVo)2 JSONObject (com.alibaba.fastjson.JSONObject)1 UnitResponse (info.xiancloud.core.message.UnitResponse)1 Test (org.junit.Test)1