Page 1
CACHING
Oldie but Goldie
Raluca Breaur
20th of April 2013
Page 6
“There are only two hard things
in Computer Science:
cache invalidation
and naming things.” Phil Karlton
Page 9
Stale data strategy
Time to live
Time to idle
Page 10
Eviction algorithms
LFU – Least Frequently Used
LRU – Least Recently Used
FIFO
…
Page 14
HIT
CACHE SOURCE
OF
DATA
Page 15
MISS
CACHE SOURCE
OF
DATA
Page 18
Cache performance - Statistics
Hits
Misses
Size
Average GetTime
Eviction Count
Page 19
Common Data Patterns
Locality Hot Set Data
changes
Catalog
(Countries)
Low
Low
Low
Inventory
(Stocks)
High
High
High
Conversation
(Shopping Cart)
High
High
Low
Page 20
Caches around us
Browser cache
Use cache control headers: max age, no cache
Page 22
Database
• Persistence Layer – JPA – 2 layers of cache
Page 23
High computation
Service – Spring 3.1 Cache Abstraction
JCache
Page 24
Web Service / 3rd party
Multiple clients - Standalone Cache Server
Service – Spring 3.1 Cache Abstraction/JCache
Page 25
Cache Providers - JCACHE
java.util.Map GUAVA caches