Skip to content
Snippets Groups Projects
Commit 4eea6a12 authored by Uladzimir Havenchyk's avatar Uladzimir Havenchyk
Browse files

Revert "Adding cache stats to metabase.lib.cache"

This reverts commit dc32be74.
parent dc32be74
No related branches found
No related tags found
No related merge requests found
......@@ -17,21 +17,12 @@
(do
(when-not (.-__mbcache ^js x)
(set! (.-__mbcache ^js x) (atom {})))
(when-not js/window.__mbcache_stats
(set! js/window.__mbcache_stats (js-obj)))
(if-let [cache (.-__mbcache ^js x)]
(if-let [cached (get @cache subkey)]
(do
(if-let [^js stats (aget js/window.__mbcache_stats subkey)]
(set! (.-hits stats) (inc (.-hits stats)))
(aset js/window.__mbcache_stats subkey (js-obj "hits" 1 "misses" 0)))
cached)
cached
;; Cache miss - generate the value and cache it.
(let [value (f x)]
(swap! cache assoc subkey value)
(if-let [^js stats (aget js/window.__mbcache_stats subkey)]
(set! (.-misses stats) (inc (.-misses stats)))
(aset js/window.__mbcache_stats subkey (js-obj "hits" 0 "misses" 1)))
value))
(f x)))
(f x))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment