blocks.store.cache

Cache stores provide logical block storage backed by two other stores, a primary store and a cache.

Blocks are added to the cache on reads and writes, and evicted with a least-recently-used strategy to keep the cache under a certain total size. Operations on this store will prefer to look up blocks in the cache, and fall back to the primary store when not available.

Because the caching logic runs locally, the backing cache storage should not be shared among multiple concurrent processes.

caching-block-store

(caching-block-store size-limit & {:as opts})

Create a new logical block store which will use one block store to cache up to a certain size of content for another store. This store should have a :primary and a :cache associated with it for backing block storage.

  • :primary Backing store with the primary block data.
  • :cache Store to cache blocks in and prefer for reads.
  • :size-limit Maximum total size of blocks to keep in the cache store.
  • :predicate (optional) A predicate function which should return false for blocks which should not be cached; instead, they will only be written to the primary store.

reap!

(reap! store target-free)

Given a target amount of space to free and a cache store, deletes blocks from the cache to free up the desired amount of space. Returns a deferred which yields a summary of the deleted entries.