Fork me on GitHub
#beginners
<
2016-02-14
>
olegakbarov15:02:05

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

olegakbarov15:02:21

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

olegakbarov15:02:16

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

olegakbarov15:02:50

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

doddenino18:02:40

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?

sveri19:02:26

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

doddenino19:02:31

@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!

sveri19:02:13

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

sveri19:02:09

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.

doddenino19:02:14

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

sveri19:02:23

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