赞
踩
- val jedisCluster = new JedisCluster(hostPorts)
-
- val clusterNodes = jedisCluster.getClusterNodes.values()
- for (clusterNode: JedisPool <- clusterNodes) {
- var scanCursor = "0"
- val resource: Jedis = clusterNode.getResource
- for (clusterNode: JedisPool <- clusterNodes) {
- var scanCursor = "0"
- var scanResult: util.List[String] = new util.ArrayList[String]()
- do {
- val resource: Jedis = clusterNode.getResource
- val scan: ScanResult[String] = resource.scan(scanCursor, new ScanParams().`match`(“xxx*"))
- scanCursor = scan.getStringCursor
- scanResult = scan.getResult
- for (key: String <- scanResult) {
- //xxx
- }
- resource.close()
- } while (!scanCursor.equals("0") && !scanResult.isEmpty)
- }
- val keys = new mutable.HashSet[String]()
- for (clusterNode: JedisPool <- clusterNodes) {
- var scanCursor = "0"
- var scanResult: util.List[String] = new util.ArrayList[String]()
- do {
- val resource: Jedis = clusterNode.getResource
- val scan: ScanResult[String] = resource.scan(scanCursor, new ScanParams().`match`(PROD_SKU_PRICE + "*"))
- scanCursor = scan.getStringCursor
- scanResult = scan.getResult
- for (key: String <- scanResult) {
- keys.add(key)
- }
- resource.close()
- } while (!scanCursor.equals("0") && !scanResult.isEmpty)
- }
- print (keys.size)
- public ScanResult<String> scan(final String hashTag, final String cursor, final ScanParams params) {
- ZhenQueryContextHolder.getInstance().setQueryContext(new ZhenQueryContext(OperationType.READ));
- return new ZhenJedisClusterCommand<ScanResult<String>>(connectionHandler, maxRedirections) {
-
- @Override
- public ScanResult<String> execute(Jedis connection) {
- return connection.scan(cursor, params);
- }
- }.run(hashTag);
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。