Contents

setCacheState(for:cacheMode:coherencyType:action:)

Sends a synchronous cache state update request from the module to the kernel.

Declaration

func setCacheState(for item: FSItem, cacheMode: FSVolume.DataCacheMode, coherencyType: FSVolume.KernelCacheCoherencyType, action: FSVolume.KernelCacheCoherencyAction) -> (any Error)?

Parameters

  • item:

    The item for which to update the cache state.

  • cacheMode:

    The new cache mode to apply.

  • coherencyType:

    The new coherency type to apply.

  • action:

    The action for the kernel to perform on cached data (push, invalidate, update, or revoke).

Return Value

An error if the kernel was unable to complete the requested cache state change, or nil on success.

Discussion

Volumes conforming to FSVolume.DataCacheHandler call this method to proactively notify the kernel about cache policy changes that need to be applied immediately. This allows module-initiated updates outside the normal open/close/upgrade/downgrade flow.

When downgrading coherency type, the action must be FSVolume.KernelCacheCoherencyAction.push, FSVolume.KernelCacheCoherencyAction.pushInvalidate, or FSVolume.KernelCacheCoherencyAction.invalidate to instruct the kernel how to handle cached data. If the action fails, the cache state remains unchanged and the method returns an error.

See Also

Managing caching behavior