Skip to content

Instantly share code, notes, and snippets.

@onmyway133
Created June 15, 2018 08:33
Show Gist options
  • Save onmyway133/1f3501d6b5217c47604bdcce09918f16 to your computer and use it in GitHub Desktop.
Save onmyway133/1f3501d6b5217c47604bdcce09918f16 to your computer and use it in GitHub Desktop.
/// A protocol used for saving and loading from storage
public protocol StorageAware {
func object<T: Codable>(ofType type: T.Type, forKey key: String) throws -> T
func entry<T: Codable>(ofType type: T.Type, forKey key: String) throws -> Entry<T>
func removeObject(forKey key: String) throws
func setObject<T: Codable>(_ object: T, forKey key: String, expiry: Expiry?) throws
func existsObject<T: Codable>(ofType type: T.Type, forKey key: String) throws -> Bool
func removeAll() throws
func removeExpiredObjects() throws
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment