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>(key: String, as: T.Type, root: Bool = false) -> T? where T : Decodable, T : Encodable
Parameters
key
The name of the item in the cache
as
The struct to use for decoding
root
Get it from the root folder; if false, it will get it from the Host IP folder
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>(key: String, object: T, root: Bool = false) throws where T : Decodable, T : Encodable
Parameters
key
The name for the item in the cache
object
Tthe struct to save
root
Store it in the root folder; if false, it will store it in the Host IP folder
-
Delete a struct from the cache
Throws
an error if it can’t be savedDeclaration
Swift
public static func delete(key: String, root: Bool = false) throws
Parameters
key
The name for the item in the cache
root
Delete it in the root folder; if false, it will delete it from the Host IP folder