clerk

flowthing 2025-10-03T11:42:59.476709Z

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.

borkdude 2025-10-03T11:51:34.535529Z

Mark it with ^::clerk/no-cache

☝️ 1
borkdude 2025-10-03T11:54:15.428309Z

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

🎯 1
borkdude 2025-10-03T11:55:06.456529Z

but the answer to your question is just the no-cache thing

flowthing 2025-10-03T11:55:46.958719Z

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. πŸ€”

borkdude 2025-10-03T11:56:52.334909Z

every expression is a cache buster, if it changes, the thing is recalculated. inst is just an example here

flowthing 2025-10-03T11:58:18.700939Z

Yeah, I get that. I guess I'm just not keen on adding things to each expression just to bust a cache.

borkdude 2025-10-03T11:58:36.524019Z

you can opt out from the cache completely if you want that?

flowthing 2025-10-03T11:58:41.905899Z

^::clerk/no-cache might work when making a static build, I'll have to try that.

borkdude 2025-10-03T11:58:42.480709Z

then you can add it to the ns form

πŸ‘ 1
teodorlu 2025-10-03T13:47:17.156839Z

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))
  )

borkdude 2025-10-03T13:48:51.394099Z

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

teodorlu 2025-10-03T13:49:30.325219Z

agreed that disabling all cache is easier if that works for him with regards to performance!

mkvlr 2025-10-04T02:30:18.280819Z

can also opt out of clerk’s caching globally by setting the clerk.disable_cache system property to true

πŸ‘ 2