SessionCache

@dynamicMemberLookup
public final class SessionCache

Undocumented

Retrieval

  • Queries an object with specified type for the given request.

    Returns: (Optional) A cached object.

    Declaration

    Swift

    public func query<T>(_ dataType: T.Type, for request: URLRequest) -> T? where T : Decodable, T : Encodable

    Parameters

    dataType

    The data type of the cached data.

    request

    The URL request whose cached URL response is desired.

  • Queries a URL of existing resource item loaded from the given request.

    Returns: (Optional) A URL of resource item.

    Declaration

    Swift

    public func queryResourceItemURL(for request: URLRequest) -> URL?

    Parameters

    request

    The URL request whose cached URL response is desired.

  • Queries a CachedURLResponse object for the given request.

    Returns: (Optional) A cached URL response

    Declaration

    Swift

    public func queryCachedResponse(for request: URLRequest) -> CachedURLResponse?

    Parameters

    request

    The URL request whose cached URL response is desired.

Store

  • Stores an object for a specified request included in the given task.

    Declaration

    Swift

    public func store<T>(_ object: T, from task: URLSessionTask) where T : Decodable, T : Encodable

    Parameters

    object

    An object to be cached.

    task

    The session task whose response is to be cached.

  • Stores an object from a response for a specified request.

    Declaration

    Swift

    public func store<T>(_ object: T, from response: URLResponse, for request: URLRequest) where T : Decodable, T : Encodable

    Parameters

    object

    An object to be cached.

    response

    A response to a URL request.

    request

    The request for which the cached URL response is being stored.

Removal

  • Removes cached object corresponding a specified request if any.

    Declaration

    Swift

    public func removeObject(for request: URLRequest)
  • Removes all cached responses from current storage.

    Declaration

    Swift

    public func reset()