通过 RedisConnection 删除 redis 中的 key

 RedisConnection connection = redisTemplate.getConnectionFactory().getConnection();
 Cursor<byte[]> cursor = connection.scan(new ScanOptions.ScanOptionsBuilder().match("qiyihao-message-notice-list*").count(1000).build());
 List<byte[]> bytes = new ArrayList<>();
 while (cursor.hasNext()) {
     //  keys.add(new String(cursor.next()));
     bytes.add(cursor.next());
 }
 for (byte[] key : bytes) {
       log.info(key);
     //  redisTemplate.delete(key);
     connection.del(key);
 }

 

posted @ 2019-08-21 16:51  我的小时代  阅读(1296)  评论(0编辑  收藏  举报