| 
                         3、Set删除: sscan + srem 
- public void delBigSet(String host, int port, String password, String bigSetKey) {  
 -     Jedis jedis = new Jedis(host, port);  
 -     if (password != null && !"".equals(password)) {  
 -         jedis.auth(password);  
 -     }  
 -     ScanParams scanParams = new ScanParams().count(100);  
 -     String cursor = "0";  
 -     do {  
 -         ScanResult<String> scanResult = jedis.sscan(bigSetKey, cursor, scanParams);  
 -         List<String> memberList = scanResult.getResult();  
 -         if (memberList != null && !memberList.isEmpty()) {  
 -             for (String member : memberList) {  
 -                 jedis.srem(bigSetKey, member);  
 -             }  
 -         }  
 -         cursor = scanResult.getStringCursor();  
 -     } while (!"0".equals(cursor));  
 -     //删除bigkey  
 -     jedis.del(bigSetKey);  
 - } 
 
  
4、SortedSet删除: zscan + zrem 
- public void delBigZset(String host, int port, String password, String bigZsetKey) {  
 -     Jedis jedis = new Jedis(host, port);  
 -     if (password != null && !"".equals(password)) {  
 -         jedis.auth(password);  
 -     }  
 -     ScanParams scanParams = new ScanParams().count(100);  
 -     String cursor = "0";  
 -     do {  
 -         ScanResult<Tuple> scanResult = jedis.zscan(bigZsetKey, cursor, scanParams);  
 -         List<Tuple> tupleList = scanResult.getResult();  
 -         if (tupleList != null && !tupleList.isEmpty()) {  
 -             for (Tuple tuple : tupleList) {  
 -                 jedis.zrem(bigZsetKey, tuple.getElement());  
 -             }  
 -         }  
 -         cursor = scanResult.getStringCursor();  
 -     } while (!"0".equals(cursor));  
 -     //删除bigkey  
 -     jedis.del(bigZsetKey);  
 - } 
 
  
                        (编辑:滁州站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |