DataStore

public protocol DataStore : AnyObject, DataItemExtractor

Generic data storage for storing DataInput and retrieving DataItem objects.

Implementations are not guaranteed to be persistent. For instance, in cases where there may be insufficient storage space on the device, or other reasons such as write permissions etc.

Stored data requires an Expiry to be provided when storing, and expired data will not be included in any retrieval operations; that is, expired data won’t be returned by get or getAll but it will also not be included in any aggregate methods such as keys or count.

  • Returns a DataStoreEditor able to mutate the data in this storage.

    Declaration

    Swift

    func edit() -> DataStoreEditor

    Return Value

    DataStoreEditor to update the stored data.

  • Gets a dictionary containing all data stored.

    Declaration

    Swift

    func getAll() -> DataObject

    Return Value

    A DataObject dictionary with all the data contained in the storage.

  • Returns all keys stored in this DataStore

    Declaration

    Swift

    func keys() -> [String]

    Return Value

    A list of all string keys present in the DataStore

  • Returns the number of entries in this DataStore

    Declaration

    Swift

    func count() -> Int

    Return Value

    the count of all key-value pairs in the DataStore

  • Observable of key-value pairs from this DataStore that have been updated

    Declaration

    Swift

    var onDataUpdated: Observable<DataObject> { get }
  • Observable of keys from this DataStore that have been removed or expired

    Note that expiration may not happen immediately when the value is expired but may happen asynchronously on a later check

    Declaration

    Swift

    var onDataRemoved: Observable<[String]> { get }