Cache
public enum Cache
Get and set structs to the cache directory
-
Get a struct from the cache
Declaration
Swift
public static func get<T: Codable>(key: String, as: T.Type, folder: String? = nil) throws -> TParameters
keyThe name of the item in the cache
asThe struct to use for decoding
folderThe optional subfolder to store the item
Return Value
decoded cache item
-
Save a struct into the cache
Throws
an error if it can’t be savedDeclaration
Swift
public static func set<T: Codable>(key: String, object: T, folder: String? = nil) throwsParameters
keyThe name for the item in the cache
objectTthe strucåt to save
folderThe optional subfolder to store the item
-
Delete a struct from the cache
Throws
an error if it can’t be savedDeclaration
Swift
public static func delete(key: String, folder: String? = nil) throwsParameters
keyThe name for the item in the cache
folderThe optional subfolder to store the item
-
Get the path to the cache directory
Declaration
Swift
static private func path(for key: String, folder: String?) throws -> URLParameters
keyThe name of the cache item
folderThe optional subfolder to store the item
Return Value
A full
URLto the cache direcory
View on GitHub