KeyValueStore

public protocol KeyValueStore : Store

A type to which all KeyValueStores must conform to provide key-value storage as a service.

  • API to get Any typed item for a Key

    Data, String, Array, Dictionary, Date and Number are allowed as Objects. Custom types are not allowed.

    Declaration

    Swift

    func object(forKey key: String) -> Any?

    Parameters

    key

    Key to identify the item

  • API to set Any object for a Key

    Data, 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

    value

    Any typed item

    key

    Key to identify the set item

  • API to remove item associated with the Key

    Data, String, Array, Dictionary, Date and Number are allowed as Objects. Custom types are not allowed.

    Declaration

    Swift

    func removeObject(forKey key: String)

    Parameters

    key

    Key to identify the item

  • API to get String typed item for a Key

    Declaration

    Swift

    func string(forKey key: String) -> String?

    Parameters

    key

    Key to identify the item

  • API to get Array typed item for a Key

    Declaration

    Swift

    func array(forKey key: String) -> [Any]?
  • API to get Dictionary typed item for a Key

    Declaration

    Swift

    func dictionary(forKey key: String) -> [String : Any]?

    Parameters

    key

    Key to identify the item

  • API to get Data typed item for a Key

    Declaration

    Swift

    func data(forKey key: String) -> Data?

    Parameters

    key

    Key to identify the item

  • API to get Array of Strings for a Key

    Declaration

    Swift

    func stringArray(forKey key: String) -> [String]?

    Parameters

    key

    Key to identify the item

  • API to get Int item for a Key. In absence of value, Int(0) would be returned.

    Declaration

    Swift

    func integer(forKey key: String) -> Int

    Parameters

    key

    Key to identify the item

  • API to get Float item for a Key. In absence of value, Float(0) would be returned.

    Declaration

    Swift

    func float(forKey key: String) -> Float

    Parameters

    key

    Key to identify the item

  • API to get Double item for a Key. In absence of value, Double(0) would be returned.

    Declaration

    Swift

    func double(forKey key: String) -> Double

    Parameters

    key

    Key to identify the item

  • API to get Bool item for a Key. In absence of value, Bool(false) would be returned.

    Declaration

    Swift

    func bool(forKey key: String) -> Bool

    Parameters

    key

    Key to identify the item

  • API to set Int item for a Key

    Declaration

    Swift

    func set(_ value: Int, forKey key: String)

    Parameters

    value

    Int typed item

    key

    Key to identify the set item

  • API to set Float item for a Key

    Declaration

    Swift

    func set(_ value: Float, forKey key: String)

    Parameters

    value

    Float typed item

    key

    Key to identify the set item

  • API to set Double item for a Key

    Declaration

    Swift

    func set(_ value: Double, forKey key: String)

    Parameters

    value

    Double typed item

    key

    Key to identify the set item

  • API to set Bool item for a Key

    Declaration

    Swift

    func set(_ value: Bool, forKey key: String)

    Parameters

    value

    Any typed item

    key

    Key to 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