This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def some-file-resources-modified? | |
"Returns true iff any of the files backing given resources have changed | |
since this function was last called." | |
(let [times (atom {})] | |
(fn modified? | |
([resource-name & more] (some modified? (cons resource-name more))) | |
([resource-name] | |
(when-let [^File file (try (->> resource-name io/resource io/file) | |
(catch Exception _ nil))] | |
(let [last-modified (.lastModified file)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def ^:private gc-sm-cache! | |
"Maintains maximum cache size by intelligently pruning less valuable items." | |
(let [gc-running? (atom false)] | |
(fn [cache ttl max-items now] | |
(when-not @gc-running? | |
(reset! gc-running? true) | |
(let [snapshot @cache |
NewerOlder