Cache

enum Cache

Get and set structs to the cache directory

Note

This is used to get and save the application settings
  • Get a struct from the cache

    Declaration

    Swift

    static func get<T: Codable>(key: String, struct: T.Type) throws -> T

    Parameters

    key

    The name of the item in the cache

    struct

    The struct to use for decoding

    Return Value

    decoded cache item

  • Save a struct into the cache

    Throws

    an error if it can’t be saved

    Declaration

    Swift

    static func set<T: Codable>(key: String, object: T) throws

    Parameters

    key

    The name for the item in the cache

    object

    The struct to save

  • Delete a struct from the cache

    Throws

    an error if it can’t be saved

    Declaration

    Swift

    static func delete(key: String) throws

    Parameters

    key

    The name for the item in the cache

  • Get the path to the cache directory

    Declaration

    Swift

    static private func path(for key: String) throws -> URL

    Parameters

    key

    The name of the cache item

    Return Value

    A full URL to the cache directory