~/talk

Caching in Scala using Cats Ref

Talkat Scala Days 2026 · 2026-10-12..10-13· [scala, functional-programming]
links:none on file
slides:none on file

Shows a production cache built with Cats Ref and the concrete problems that appear: a naive get then update with Ref.unsafe causes test state bleed and flaky parallel requests where two fibers race and last write wins, TTL checks are hard to test, and cold starts matter. Fixes are specific: inject a controllable nano clock, use Ref.of not Ref.unsafe, perform atomic changes with modify for atomic read-write, apply memoize to dedupe concurrent computes, and run periodic update-based eviction in the background so tests become deterministic.

AI-written summary · about

  1. 0:00Introduction to talk
  2. 1:56Caching principles overview
  3. 3:24Trade-offs in caching
  4. 7:23Naive cache implementation
  5. 12:05Pitfalls in naive approach
  6. 15:17Testing time-dependent behavior
  7. 17:46Refactoring with Cats Ref
  8. 21:47Memoization benefits
  9. 23:32Eviction policies
  10. 24:58Why Cats Ref matters
  11. 26:24Function signatures summary
  12. 27:29Q&A
~/search
type to search 6,518 conferences, 143,918 speakers and 192,133 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.