Cache

public class Cache

Undocumented

  • PodAPI object

    Declaration

    Swift

    var podAPI: PodAPI
  • Object that schedules with the POD

    Declaration

    Swift

    var sync: Sync
  • Undocumented

    Declaration

    Swift

    public var scheduleUIUpdate: ((((_ context: MemriContext) -> Bool)?) -> Void)?
  • Starts the local realm database, which is created if it does not exist, sets the api and initializes the sync from them.

    Declaration

    Swift

    public init(_ api: PodAPI) throws

    Parameters

    api

    api object

  • gets default item from database, and adds them to realm

    Declaration

    Swift

    public func install(_ dbName: String, _ callback: @escaping (Error?) -> Void) throws
  • Undocumented

    Declaration

    Swift

    public func query(_ datasource: Datasource) throws -> [Item]
  • This function does two things 1) executes a query on the local realm database with given querOptions, and executes callback on the result. 2) calls the syncer with the same datasource to execute the query on the pod.

    Declaration

    Swift

    public func query(
        _ datasource: Datasource,
        syncWithRemote: Bool = true,
        _ callback: @escaping (_ error: Error?, _ items: [Item]?) throws -> Void
    ) throws
  • Parses the query string, which whould be of format <type><space><filter-text>

    Declaration

    Swift

    public func parseQuery(_ query: String) -> (type: String, filter: String?)

    Parameters

    query

    query string

    Return Value

    (type to query, filter to apply)

  • Undocumented

    Declaration

    Swift

    public func getResultSet(_ datasource: Datasource) -> ResultSet
  • Adds an item to the local database

    Throws

    Sync conflict exception

    Declaration

    Swift

    public class func addToCache(_ item: Item) throws -> Item

    Parameters

    item

    Item to be added

    Return Value

    cached dataItem

  • marks an item to be deleted

    Remark

    All methods and properties must throw when deleted = true;

    Declaration

    Swift

    public func delete(_ item: Item) throws

    Parameters

    item

    item to be deleted

  • marks a set of items to be deleted

    Declaration

    Swift

    public func delete(_ items: [Item]) throws

    Parameters

    items

    items to be deleted

  • Remark

    Remark:Does not copy the id property

    Declaration

    Swift

    public func duplicate(_ item: Item) throws -> Item

    Parameters

    item

    item to be duplicated

    Return Value

    copied item

  • Undocumented

    Declaration

    Swift

    public class func getDeviceID() throws -> Int
  • Undocumented

    Declaration

    Swift

    static var cacheUIDCounter: Int
  • Undocumented

    Declaration

    Swift

    public class func incrementUID() throws -> Int
  • Undocumented

    Declaration

    Swift

    public class func createItem<T: Item>(
        _ type: T.Type,
        values: [String: Any?] = [:],
        unique: String? = nil
    ) throws -> T
  • Undocumented

    Declaration

    Swift

    public class func createEdge(
        source: Item,
        target: Object,
        type edgeType: String,
        label: String? = nil,
        sequence: Int? = nil
    ) throws -> Edge
  • Undocumented

    Declaration

    Swift

    public class func createEdge(
        source: Item,
        target: (String, Int),
        type edgeType: String,
        label: String? = nil,
        sequence: Int? = nil
    ) throws -> Edge
  • Undocumented

    See more

    Declaration

    Swift

    enum ItemChange
  • Undocumented

    Declaration

    Swift

    func isOnRemote(_ item: Item, _ retries: Int = 0, _ callback: @escaping (Error?) -> Void)
  • Undocumented

    Declaration

    Swift

    func subscribe(
        query: String,
        on events: ItemChange = .all,
        wait: Double = 0.5
    ) -> QueryPublisher
  • Undocumented

    Declaration

    Swift

    func subscribe(
        to item: Item,
        on events: ItemChange = .all,
        wait: Double = 0.5
    ) -> ItemPublisher<Item>