RequestCachePolicy
@propertyWrapper
public struct RequestCachePolicy
extension RequestCachePolicy: Encodable
A property wrapper that provides a convenient way to handle request cache policies.
The RequestCachePolicy struct is a property wrapper that allows you to specify the cache policy for a request.
It wraps the URLRequest.CachePolicy type and provides a default value of .useProtocolCachePolicy.
Example usage:
@RequestCachePolicy var cachePolicy: URLRequest.CachePolicy
-
The wrapped value representing the cache policy.
This property holds the
URLRequest.CachePolicyvalue that is managed by this property wrapper.Declaration
Swift
public var wrappedValue: URLRequest.CachePolicy -
Initializes a new instance of
RequestCachePolicywith the specified wrapped value.Example usage:
@RequestCachePolicy var cachePolicy: URLRequest.CachePolicy = .reloadIgnoringLocalCacheDataDeclaration
Swift
public init(wrappedValue: URLRequest.CachePolicy = .useProtocolCachePolicy)Parameters
wrappedValueThe wrapped value representing the cache policy. Defaults to
.useProtocolCachePolicy.
-
Encodes this value into the given encoder.
This method should never be called because
URLRequest.CachePolicydoes not conform toEncodable. If called, it will cause a runtime failure.Throws
A runtime error indicating that this method should not be called.Declaration
Swift
public func encode(to encoder: any Encoder) throwsParameters
encoderThe encoder to write data to.
View on GitHub