Clojure cache with cap and TTL

I am using clojure.core.memoize

(which is using clojure.core.cache

). I want to use TTL cache , but also want to have a limit on the total size of the cache (as I could provide for a FIFO cache).

I know there are all sorts of flavors of cache that combine queues, TTL, etc. I don't necessarily want something exotic, just an easy way to limit the size of the collection?


source to share

1 answer

All of memoize's functions clojure.core.memoize

seem to take on an additional underlying cache that can be used to combine different caching strategies:

(require '[clojure.core [memoize :as memo] [cache :as cache]])
(def memoized-identity
    (cache/ttl-cache-factory {} :ttl 5000)
    :fifo/threshold 32))


See core.cache

wiki entry for composition for details .



All Articles