Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Caching - A Primer
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Ash Christopher
April 15, 2012
2.8k
6
Share
Caching - A Primer
Ash Christopher
April 15, 2012
More Decks by Ash Christopher
See All by Ash Christopher
Database Sharding with Django - DjangoCon 2013
ashchristopher
10
2.2k
Testing at Scale
ashchristopher
1
150
Horizontally Scaling Your Database with Django - PyCon.ca (2012)
ashchristopher
10
1.9k
Scaling with Django
ashchristopher
5
2.4k
Django - Don't Do This!
ashchristopher
18
3.4k
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
77
5.3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Google's AI Overviews - The New Search
badams
0
950
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
780
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
120
How to Talk to Developers About Accessibility
jct
2
170
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
150
The Cost Of JavaScript in 2023
addyosmani
55
9.8k
Code Review Best Practice
trishagee
74
20k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.5k
Transcript
Caching and Django A Primer @ashchristopher
What is a Cache?
Temporary storage of non-complex data
Provides very fast lookups
Django supports simple caching
Django includes support for a number of cache backends out-of-the-box
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
Easy to make your own cache backend
Extend core.cache.backends.base.BaseCache
Simple caching follows the same pattern
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.
Your system works even if your cache is offline
Some cool projects/apps to help you with it
Django Middleware (per-site and per-view)
Cache Machine
Johnny-Cache
None
Low-level Caching (doing it by hand)
Caching is simple...
... except when it isn’t!
Cache invalidation is hard
Cache invalidation is especially hard at scale
What happens when an expensive operation falls out of cache?
Thundering Herd
Fundamental flaw?
I think so!
Caching doesn’t mean what it used to mean
What you want is probably not caching
Denormalized Data
Actively set new data instead of letting things fall out
of cache
Nothing falls out of cache
Set your data via asynchronous processes
None
No Silver Bullet
Optimizing read speed by adding redundant data
Persistent storage
NoSQL
There is a problem with denormalized data at scale
Denormalized data becomes a requirement
What problem?
Embrace denormalized data
@ashchristopher
[email protected]