This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-10
Channels
- # announcements (1)
- # asami (44)
- # babashka (62)
- # beginners (84)
- # calva (42)
- # cider (5)
- # clj-kondo (32)
- # cljs-dev (8)
- # clojure (61)
- # clojure-australia (3)
- # clojure-berlin (1)
- # clojure-europe (12)
- # clojure-japan (3)
- # clojure-nl (4)
- # clojure-serbia (5)
- # clojure-spec (1)
- # clojure-uk (9)
- # clojurescript (31)
- # community-development (21)
- # conjure (5)
- # cursive (17)
- # datomic (14)
- # emacs (10)
- # etaoin (1)
- # figwheel-main (1)
- # fulcro (9)
- # garden (5)
- # graalvm (16)
- # helix (7)
- # honeysql (13)
- # jackdaw (25)
- # jobs (2)
- # lsp (21)
- # malli (25)
- # missionary (2)
- # mount (3)
- # off-topic (12)
- # practicalli (3)
- # re-frame (43)
- # reagent (45)
- # reitit (36)
- # releases (6)
- # remote-jobs (2)
- # reveal (28)
- # rewrite-clj (7)
- # shadow-cljs (45)
- # slack-help (4)
- # spacemacs (5)
- # sql (23)
- # startup-in-a-month (7)
- # tools-deps (59)
- # vim (26)
What would be the best way to replicate delay
using missionary? I'm trying to implement something similar to https://github.com/clojure/core.cache/blob/ee699021b984df182359648312042b79d05cc506/src/main/clojure/clojure/core/cache/wrapped.clj#L38 - cache the results of a task, but also prevent "cache stampeding", ie prevent the task from re-running while the first one is being calculated.
@mjmeintjes Here's a valid approach, you may need to adapt it to your error handling policy (this one doesn't memoize failures)
(defn lazy-memo [task]
(let [cache (m/dfv)]
(m/sp
(let [this (m/dfv)
that (cache this)]
(if (= this that)
(this (m/? task))
(m/? that))))))