I have a notebook where I have (.poll rcvq 500 TimeUnit/MILLISECONDS), which obviously returns a different value each time, but because Clerk caches results, in the notebook, the expression gets the same return value every time. What's the best way to get around that? I read https://book.clerk.vision/#cached-evaluation, but I don't quite understand the #inst bit. I know I could e.g. use a different timeout value each time, but that feels distracting.
Mark it with ^::clerk/no-cache
I think the book means that the inst in the example serves as a cache buster. If you want to run the example uncached, just change the timestamp
but the answer to your question is just the no-cache thing
Hmm, right, I think I understand. That makes things a bit noisy, though. Wonder whether some sort of ^::clerk/cache-buster #inst "..." kinda thing would make sense. π€
every expression is a cache buster, if it changes, the thing is recalculated. inst is just an example here
Yeah, I get that. I guess I'm just not keen on adding things to each expression just to bust a cache.
you can opt out from the cache completely if you want that?
^::clerk/no-cache might work when making a static build, I'll have to try that.
then you can add it to the ns form
Yeah, I get that. I guess I'm just not keen on adding things to each expression just to bust a cache.You may be able to avoid putting lots of cache busters everywhere having only one function that needs ^clerk/no-cache.
For example, if you have a single defonced !state atom, you can ^::clerk/no-cache the deref.
(ns refreshes)
^:nextjournal.clerk/sync
(defonce !state (atom {}))
^:nextjournal.clerk/no-cache
(def state @!state)
(comment
(swap! !state update :refreshes (fnil inc 0))
)Until this point it's still not clear to me if @flowthing wanted to avoid caching altogether in his notebook or not. In that case you can use the ns config
agreed that disabling all cache is easier if that works for him with regards to performance!
can also opt out of clerkβs caching globally by setting the clerk.disable_cache system property to true