claro.middleware.cache

A middleware to allow caching of resolution results.

ResolvableCache

protocol

Protocol for cache implementations for resolvables.

members

cache-get

(cache-get cache env resolvables)

Lookup cached results for the given resolvables. This should return a map associating resolvables with their value.

cache-put

(cache-put cache env resolvable->result)

Put resolved values into the cache.

wrap-cache

(wrap-cache engine cache)

Wrap the given engine to allow caching and cache lookups of resolvables via the given cache.

(defonce cache
  (redis-cache ...))

(defonce engine
  (-> (engine/engine)
      (wrap-cache cache)))

Note that PureResolvable values will never hit the cache.