Skip to content

Instantly share code, notes, and snippets.

@aaronblenkush
aaronblenkush / cache.clj
Last active July 25, 2019 17:30
clojure.core.cache pattern
;; There is a subtle problem with the official clojure.core.cache
;; example (https://github.com/clojure/core.cache/wiki/Using):
(defn get-data [key]
(cache/lookup (swap! cache-store
#(if (cache/has? % key)
(cache/hit % key)
(cache/miss % key (retrieve-data key))))
key))