Created
June 15, 2018 10:00
-
-
Save onmyway133/c3bb8c23509322484c18286f1fea51dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension TypeWrapperStorage: StorageAware { | |
public func entry<T: Codable>(forKey key: String) throws -> Entry<T> { | |
let wrapperEntry = try internalStorage.entry(forKey: key) as Entry<TypeWrapper<T>> | |
return Entry(object: wrapperEntry.object.object, expiry: wrapperEntry.expiry) | |
} | |
public func setObject<T: Codable>(_ object: T, forKey key: String, | |
expiry: Expiry? = nil) throws { | |
let wrapper = TypeWrapper<T>(object: object) | |
try internalStorage.setObject(wrapper, forKey: key, expiry: expiry) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment