通过 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); }