Caching in Scala using Cats Ref
Session Abstract
Modern distributed systems depend on caching for performance, yet implementing caching correctly and safely remains a persistent challenge. This talk explores how Cats Ref from the Typelevel ecosystem enables developers to build thread-safe, testable cache while maintaining functional purity.
Session Description
Through hands-on exploration of Cats Ref and a realistic API caching scenario, this talk exposes the subtle pitfalls that commonly catch developers off guard when implementing Ref. Rather than learning these lessons painfully through production incidents, the talk provides practical strategies to recognise, prevent, and test them from the start.
The talk will aim to establish foundational knowledge; what Ref is, why it represents the ideal abstraction for concurrent cache implementations, and how it maintains both safety and purity in the presence of mutability. Building on this foundation, the talk examines core caching principles, exploring when caching is appropriate and how to choose strategically between in-memory and cloud-based solutions. By the end attendees should gain confidence implementing Ref with a clear understanding of its behaviour and implications beyond that of caching.
The talk has been previously presented at London Scala User Group (LSUG) to a diverse audience, including those unfamiliar with the Typelevel stack. As the speaker I bring three years of production Scala experience, whereby I have used Ref for caching large scale business data models for quick retrievals and dynamic configuration updates without server restarts. I aim to bring fresh perspectives on Ref with direct takeaways from my experiences with Typelevel stack.