MILAN november 28th/29th 2014 
Mathilde Lemee 
Advanced Concept of Caching 
@MathildeLemee - Aetys
HIT 
#codemotion @MathildeLemee
MISS 
#codemotion @MathildeLemee
TTI 
TTL 
#codemotion @MathildeLemee
Tom wants to 
improve data 
access 
#codemotion @MathildeLemee
CACHE ASIDE 
Application 
Cache 
PGuett BB PHUITT ! ! 
GGeett AB HMIITS S! ! 
DAO 
Databas 
e 
Read B 
#codemotion @MathildeLemee
Tom wants that the 
cache always have 
updated 
datas. 
#codemotion @MathildeLemee
System of 
Record 
#codemotion @MathildeLemee
Cache as a s-o-r : Read through 
Application 
Persistence 
layer 
Ehcache 
Database 
Get A 
HIT ! 
#codemotion @MathildeLemee
Cache as a s-o-r : Read through 
Application 
Persistence 
layer 
Get A MISS! 
Ehcache 
Database 
#codemotion @MathildeLemee
Cache as a s-o-r : Write through 
Application 
Persistence 
layer 
Ehcache 
Database 
PUT ! 
#codemotion @MathildeLemee
Tom works on a e-commerce 
website and 
want to have the faster 
data access. 
#codemotion @MathildeLemee
Cache as a s-o-r : Write Behind 
Database 
Application 
Ehcache 
Persistence 
layer 
A Write-behind 
thread 
A 
Put B PUT ! 
B 
C C 
D D 
Get A B C D 
Write A B C D 
#codemotion @MathildeLemee
Access 
Time 
#codemotion @MathildeLemee
Write Through Response times 
#codemotion @MathildeLemee
Write Behind Response Times 
#codemotion @MathildeLemee
Database 
#codemotion @MathildeLemee
Write Through – Database load 
#codemotion @MathildeLemee
Write Behind – Database load 
#codemotion @MathildeLemee
Tom doesn't 
control the 
datas 
#codemotion @MathildeLemee
REFRESH 
AHEAD 
#codemotion @MathildeLemee
0 TTR TTL 
#codemotion @MathildeLemee
Paul work in a 
bank where at a 
fixed time datas 
are updated 
#codemotion @MathildeLemee
SCHEDULED 
REFRESH 
AHEAD 
#codemotion @MathildeLemee
Choose 
#codemotion @MathildeLemee
CACHE ASIDE 
VS 
READ/WRITE 
THROUGH 
#codemotion @MathildeLemee
Refresh 
Ahead/Scheduled 
Refresh 
VS 
The world #codemotion @MathildeLemee
Refresh Ahead 
VS 
Scheduled Refresh 
Ahead 
#codemotion @MathildeLemee
Write Behind 
VS 
Write Through 
#codemotion @MathildeLemee
KNOW 
YOUR 
DATAS 
#codemotion @MathildeLemee
CACHE 
#codemotion @MathildeLemee
CACHE 
#codemotion @MathildeLemee
CAC 
#codemotion @MathildeLemee
La scalabilité est la 
capacité qu’a 
l’architecture Wikipedia 
pour 
évoluer en cas 
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
La scalabilité 
d’une 
application est 
égale à la 
#codemotion @MathildeLemee
#codemotion @MathildeLemee
DISTRIB 
U#codemotioTn IO@NMathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
ET 
SI … #codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
5 
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
ET 
SI … #codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
ET 
QUA 
ND
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
ET 
SI … #codemotion @MathildeLemee
Consistence 
• Julie / 32 ans / 2 enfants / Paris 
• Paul / 27 ans / 4 enfants / Marseille 
• Thomas / 40 ans / 1 enfant / Paris 
– Déménagement de Thomas sur Marseille 
Qui habite sur Paris ? 
#codemotion @MathildeLemee
Two Phase Commit
ONE 
ANY 
EACH QUORUM 
THRE 
E QUORUM 
LOCAL 
QUORUM 
TWO 
#codemotion @MathildeLemee
CAP 
• Consistency : 
• Availability : 
• Partionning 
#codemotion @MathildeLemee
• Consistency + Available = RDBMS 
• Consistency + Partionning = BigTable / Hbase / 
MongoDB / Redis 
• Available + Partionning = 
Riak/Cassandra/CouchDB 
#codemotion @MathildeLemee
Data Grid
Big
For who ?
Key Value store
IMDG 
vs 
Relational Database
IMDG 
vs 
NoSQL
And after ?

Advanced Concept of Caching - Mathilde Lemee - Codemotion Milan 2014