Fork me on GitHub

guys what’s the proper way to memoize a http call?


i end up with clojure.core$memoize$fn__5479@3ba3c81c result


i’d like to get some param via http and later use it as param for all further network calls


this (defn memoized-timestamp [] (memoize get-timestamp)) doesn’t return me a proper timestamp 😞


So, I have macro that clears a cache atom. What I'd like is for it to be able to empty the whole atom if no arg is passed, or clear the passed key if there's an arg. What would be the most idiomatic way to do this? Multi arity? A cond?


@doddenino: Why a macro? Apart from that a simple if else should be enough, or am I missing something?


@sveri I'm creating a small library to understand how macros work simple_smile I wanted to find a clever solution, but I ended up using multi arity. It seems to work!


@doddenino: no need to make things harder than they are, for a simple if else I would prefer to stick with if / else


Also it sounds like it would be better to have an explicit clear-cache function and another function that updates an atom. Having one function doing both is hard to read and therefore hard to understand.


@sveri: I agree. But I'm doing this to learn new things, so I guess it's fine!


@doddenino: Of course, you were just asking for the idiomatic way simple_smile