(fifo-cache-factory base & {threshold :threshold, :or {threshold 32}})
Returns a FIFO cache with the cache and FIFO queue initialized to `base` --
the queue is filled as the values are pulled out of `base`. If the associative
structure can guarantee ordering, then the said ordering will define the
eventual eviction order. Otherwise, there are no guarantees for the eventual
eviction ordering.
This function takes an optional `:threshold` argument that defines the maximum number
of elements in the cache before the FIFO semantics apply (default is 32).
If the number of elements in `base` is greater than the limit then some items
in `base` will be dropped from the resulting cache. If the associative
structure used as `base` can guarantee sorting, then the last `limit` elements
will be used as the cache seed values. Otherwise, there are no guarantees about
the elements in the resulting cache.
Source
(defn fifo-cache-factory
"Returns a FIFO cache with the cache and FIFO queue initialized to `base` --
the queue is filled as the values are pulled out of `base`. If the associative
structure can guarantee ordering, then the said ordering will define the
eventual eviction order. Otherwise, there are no guarantees for the eventual
eviction ordering.
This function takes an optional `:threshold` argument that defines the maximum number
of elements in the cache before the FIFO semantics apply (default is 32).
If the number of elements in `base` is greater than the limit then some items
in `base` will be dropped from the resulting cache. If the associative
structure used as `base` can guarantee sorting, then the last `limit` elements
will be used as the cache seed values. Otherwise, there are no guarantees about
the elements in the resulting cache."
[base & {threshold :threshold :or {threshold 32}}]
{:pre [(number? threshold) (< 0 threshold)
(map? base)]
:post [(== threshold (count (.q ^FIFOCache %)))]}
(clojure.core.cache/seed (FIFOCache. {} clojure.lang.PersistentQueue/EMPTY threshold) base))