Fork me on GitHub

What would be the best way to replicate delay using missionary? I'm trying to implement something similar to - 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)]
      (let [this (m/dfv)
            that (cache this)]
        (if (= this that)
          (this (m/? task))
          (m/? that))))))