KeyValueStore
public protocol KeyValueStore : Store
A type to which all KeyValueStores must conform to provide key-value storage as a service.
-
API to get
Anytyped item for a KeyData, String, Array, Dictionary, Date and Number are allowed as Objects. Custom types are not allowed.
Declaration
Swift
func object(forKey key: String) -> Any?Parameters
keyKeyto identify the item -
API to set
Anyobject for aKeyData, String, Array, Dictionary, Date and Number are allowed as Objects. Custom types are not allowed.
Declaration
Swift
func set(_ value: Any?, forKey key: String)Parameters
valueAnytyped itemkeyKeyto identify the set item -
API to remove item associated with the
KeyData, String, Array, Dictionary, Date and Number are allowed as Objects. Custom types are not allowed.
Declaration
Swift
func removeObject(forKey key: String)Parameters
keyKeyto identify the item -
API to get
Stringtyped item for a KeyDeclaration
Swift
func string(forKey key: String) -> String?Parameters
keyKeyto identify the item -
API to get
Arraytyped item for a KeyDeclaration
Swift
func array(forKey key: String) -> [Any]? -
API to get
Dictionarytyped item for a KeyDeclaration
Swift
func dictionary(forKey key: String) -> [String : Any]?Parameters
keyKeyto identify the item -
API to get
Datatyped item for a KeyDeclaration
Swift
func data(forKey key: String) -> Data?Parameters
keyKeyto identify the item -
API to get Array of Strings for a Key
Declaration
Swift
func stringArray(forKey key: String) -> [String]?Parameters
keyKeyto identify the item -
API to get
Intitem for a Key. In absence of value,Int(0)would be returned.Declaration
Swift
func integer(forKey key: String) -> IntParameters
keyKeyto identify the item -
API to get
Floatitem for a Key. In absence of value,Float(0)would be returned.Declaration
Swift
func float(forKey key: String) -> FloatParameters
keyKeyto identify the item -
API to get
Doubleitem for a Key. In absence of value,Double(0)would be returned.Declaration
Swift
func double(forKey key: String) -> DoubleParameters
keyKeyto identify the item -
API to get
Boolitem for a Key. In absence of value,Bool(false)would be returned.Declaration
Swift
func bool(forKey key: String) -> BoolParameters
keyKeyto identify the item -
API to set
Intitem for aKeyDeclaration
Swift
func set(_ value: Int, forKey key: String)Parameters
valueInttyped itemkeyKeyto identify the set item -
API to set
Floatitem for aKeyDeclaration
Swift
func set(_ value: Float, forKey key: String)Parameters
valueFloattyped itemkeyKeyto identify the set item -
API to set
Doubleitem for aKeyDeclaration
Swift
func set(_ value: Double, forKey key: String)Parameters
valueDoubletyped itemkeyKeyto identify the set item -
API to set
Boolitem for aKeyDeclaration
Swift
func set(_ value: Bool, forKey key: String)Parameters
valueAnytyped itemkeyKeyto identify the set item -
Synchronizes the in memory data with the underlying store. Users are suggested to call
sync()when they cannot afford losing an in-memory data. Ideally, the store should be synced before de-init of the store.Declaration
Swift
func sync() throws -
Clears the data completely. This action cannot be undone.
Declaration
Swift
func clear() throws