Django
includes support for a number of
cache
backends out-of-the-box
Slide 7
Slide 7 text
Memcache
cluster of Memcache servers
Database cache
uses database table for cache
Filesystem cache
file on the local filesystem
Local memory cache
only good for local development
Slide 8
Slide 8 text
Easy to make your own
cache backend
Slide 9
Slide 9 text
Extend
core.cache.backends.base.BaseCache
Slide 10
Slide 10 text
Simple caching follows the
same pattern
Slide 11
Slide 11 text
1.
Check the cache for data and if found,
return it
2. If data is not in cache -
get data from the
database,
put data in cache then return the
data
3.
Invalidate cache on data change.
Slide 12
Slide 12 text
Your system
works
even if your cache is
offline
Slide 13
Slide 13 text
Some cool projects/apps to
help you with it
Slide 14
Slide 14 text
Django Middleware
(per-site and per-view)
Slide 15
Slide 15 text
Cache Machine
Slide 16
Slide 16 text
Johnny-Cache
Slide 17
Slide 17 text
No content
Slide 18
Slide 18 text
Low-level Caching
(doing it by hand)
Slide 19
Slide 19 text
Caching is simple...
Slide 20
Slide 20 text
... except when it isn’t!
Slide 21
Slide 21 text
Cache invalidation is hard
Slide 22
Slide 22 text
Cache invalidation is especially
hard at scale
Slide 23
Slide 23 text
What happens when an
expensive
operation falls out of cache?
Slide 24
Slide 24 text
Thundering Herd
Slide 25
Slide 25 text
Fundamental
flaw?
Slide 26
Slide 26 text
I think so!
Slide 27
Slide 27 text
Caching doesn’t mean what it
used to mean
Slide 28
Slide 28 text
What you want is
probably not caching
Slide 29
Slide 29 text
Denormalized Data
Slide 30
Slide 30 text
Actively
set new data instead of letting things fall
out of cache
Slide 31
Slide 31 text
Nothing falls out of cache
Slide 32
Slide 32 text
Set your data via
asynchronous processes
Slide 33
Slide 33 text
No content
Slide 34
Slide 34 text
No Silver Bullet
Slide 35
Slide 35 text
Optimizing read
speed by adding
redundant data
Slide 36
Slide 36 text
Persistent storage
Slide 37
Slide 37 text
NoSQL
Slide 38
Slide 38 text
There is a
problem with denormalized data at
scale