Caching with Spring: Advanced Topics and Best Practices
summary
Practical guidance on using Spring’s cache abstraction plus JCache (JSR‑107) with live demos: use existing providers (EHCache, Hazelcast, Infinispan, Guava), never roll your own, prefer distributed or near‑cache topologies over full replication to avoid massive network churn, watch heap sizes (32 GB JVMs and tiny 100‑entry caches both fail), and secure cached data. Shows @Cacheable/@CachePut/@CacheEvict, custom key generators, CompositeCacheManager, and a production case where disabling replication saved an overloaded system — caching configurations and TTLs remain provider‑specific.
AI-written summary · about
chapters (17)
- 0:00Intro
- 4:47Local In-Memory
- 7:23Clustered - with sync
- 8:39Invalidation - Option 1
- 9:52Replication
- 15:10Distributed Caches
- 24:20Tying your code to a cache provider is bad practice
- 25:02Try switching from EHCache to Hazelcast
- 26:35You can't switch cache providers between environments
- 27:13You mess up your business logic with infrastructure
- 27:52Introducing Spring's cache abstraction
- 29:39Spring's Caching Annotations
- 33:36Default Key Generation Strategy
- 35:28You need a custom default Key Generator?
- 36:14SPEL in Caching Annotations
- 40:27Working with Cache Resolvers
- 43:44Spring vs JCache Annotations
related talks
46mCaching in an Asynchronous Spring Application
53mLeveraging Caching For Cloud Native Applications
19mCaching with Cache2K
44mHow to speed up your application using JCache
50mLet's talk about the cache!
01h 02mJava Caching with JSR107 and tCache
42mCache, But Cache Wisely!
45mWhere is my cache? Architectural patterns for caching microservices by example
