---
title: "metadataClear(_:withDelayedWrites:)"
framework: fskit
role: symbol
role_heading: Instance Method
path: "fskit/fsblockdeviceresource/metadataclear(_:withdelayedwrites:)"
---

# metadataClear(_:withDelayedWrites:)

Clears the given ranges within the buffer cache.

## Declaration

```swift
func metadataClear(_ rangesToClear: [FSMetadataRange], withDelayedWrites: Bool) throws
```

## Parameters

- `rangesToClear`: The metadata ranges to clear.
- `withDelayedWrites`: A Boolean value that determines whether to perform the clear operation with delayed writes. The delay works in the same manner as doc://FSKit/documentation/FSKit/FSBlockDeviceResource/delayedMetadataWriteFrom:startingAt:length:error:. When using delayed writes, the client can flush the metadata with doc://FSKit/documentation/FSKit/FSBlockDeviceResource/metadataFlush() or doc://FSKit/documentation/FSKit/FSBlockDeviceResource/asynchronousMetadataFlush(). The system also flushes stale data in the buffer cache periodically.

## Discussion

Discussion This method clears the specified ranges in the resource’s buffer cache by writing zeroes into them.

## See Also

### Reading and writing data with kernel buffer cache

- [metadataRead(into:startingAt:length:)](fskit/fsblockdeviceresource/metadataread(into:startingat:length:).md)
- [metadataWrite(from:startingAt:length:)](fskit/fsblockdeviceresource/metadatawrite(from:startingat:length:).md)
- [delayedMetadataWrite(from:startingAt:length:)](fskit/fsblockdeviceresource/delayedmetadatawrite(from:startingat:length:).md)
- [metadataFlush()](fskit/fsblockdeviceresource/metadataflush().md)
- [asynchronousMetadataFlush()](fskit/fsblockdeviceresource/asynchronousmetadataflush().md)
- [metadataPurge(_:)](fskit/fsblockdeviceresource/metadatapurge(_:).md)
- [FSMetadataRange](fskit/fsmetadatarange.md)
