mirror of https://github.com/status-im/timbre.git
Housekeeping
This commit is contained in:
parent
a29879d1f9
commit
de9d1b001e
|
@ -174,7 +174,7 @@
|
|||
(let [timers (atom {})] ; {:hash last-appended-time-msecs ...}
|
||||
(fn [{ns :ns [x1 & _] :args :as apfn-args}]
|
||||
(let [now (System/currentTimeMillis)
|
||||
hash (str ns "/" x1)
|
||||
hash (str ns "/" x1) ; TODO Alternatives?
|
||||
limit? (fn [last-msecs]
|
||||
(and last-msecs (<= (- now last-msecs)
|
||||
limit-per-msecs)))]
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
(let [[subject & body] args]
|
||||
(postal/send-message
|
||||
(assoc postal-config
|
||||
;; TODO Better to just use trunc'd message as subject?
|
||||
:subject (str prefix " - " (or subject throwable))
|
||||
:body (str (str/join \space body)
|
||||
(timbre/stacktrace throwable "\n")))))))})
|
|
@ -13,13 +13,13 @@
|
|||
(defn memoize-ttl
|
||||
"Like `memoize` but invalidates the cache for a set of arguments after TTL
|
||||
msecs has elapsed."
|
||||
[ttl f]
|
||||
[ttl-ms f]
|
||||
(let [cache (atom {})]
|
||||
(fn [& args]
|
||||
(let [{:keys [time-cached d-result]} (@cache args)
|
||||
now (System/currentTimeMillis)]
|
||||
|
||||
(if (and time-cached (< (- now time-cached) ttl))
|
||||
(if (and time-cached (< (- now time-cached) ttl-ms))
|
||||
@d-result
|
||||
(let [d-result (delay (apply f args))]
|
||||
(swap! cache assoc args {:time-cached now :d-result d-result})
|
||||
|
|
Loading…
Reference in New Issue