Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 1.7 KB

Store.md

File metadata and controls

18 lines (12 loc) · 1.7 KB

Lucid - Store

In a way, Stores can be seen as drivers to read and write data to different physical places. Every Store imlements a unified protocol and are meant to be modular and composable.

A Store can be one of three types:

  • .memory: Data is ephemeral. Expected to be very fast and reliable.
  • .disk: Data is persisted to disk. Expected to be relatively fast and very reliable.
  • .remote: Data is fully handled by a remote server. Relying on the network's connectivity, it isn't expected to be fast nor reliable.

All types of stores are expected to be operating asynchronously and on a background thread.

It is encouraged to implement your own stores in order to best fit your needs. However, Lucid comes with a few implementations which are meant to fit most scenarios.

  • RemoteStore: Transforms queries into valid APIClientRequests to forward them to a APIClientQueue instance and transforms the response into entities.
  • CoreDataStore: Transforms queries into NSPredicates to forward them to a CoreData stack and transforms the response into entities.
  • InMemoryStore: Transforms queries into a series of entity identifiers to retrieve their corresponding entities from a dictionary. Compatible with queries only using identifiers. (A memory cache that frees up space from time to time can never be trusted to contain a full abstract set).
  • LRUStore: Used as a firewall in front of a disk and a memory Store to make sure frequently used entities aren't repeatedly fetched from disk. Compatible with queries only using identifiers.