SQLiteKeyValueStore
final class SQLiteKeyValueStore
Basic SQLite Key/Value store with Keys as TEXT
and Values stored as BLOB
-
Declaration
Swift
init(with directoryURL: URL, key: String) throws
Parameters
url
URL on disk where the FMDB should be initialized If any part of the init fails no Datbase will be created If the Database can’t be accessed with the key the currentFile will be reset
-
Undocumented
Declaration
Swift
deinit
-
Removes all key/value pairs from the Store and creates a new database with a given key
Declaration
Swift
func clearAll(key: String?) throws
-
Removes most key/value pairs.
Keys whose values are not removed:
developerSubmissionBaseURLOverride
developerDistributionBaseURLOverride
developerVerificationBaseURLOverride
Declaration
Swift
func flush() throws
-
Declaration
Swift
subscript(key: String) -> Data? { get set }
Parameters
key
key index to look in the DB for
Return Value
Data
if the key/value pair is found (even if the value BLOB is empty), or nil if no value exists for the given key. -
Convenience subscript to use with
Codable
types, uses JSON encoder/decoder with no additional configuration.Attention
Errors encountered during encoding with
JSONEncoder
silently fail (but are logged)! If encoding fails, fetching the value for that key will result in emptyData
Declaration
Swift
subscript<Model>(key: String) -> Model? where Model : Decodable, Model : Encodable { get set }
Return Value
Model decoded with a
JSONDecoder
, ornil
if decoding fails.