Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
170
Horizontally Scaling Your Database with Django - PyCon.ca (2012)
ashchristopher
10
1.9k
Scaling with Django
ashchristopher
5
2.5k
Django - Don't Do This!
ashchristopher
18
3.4k
Featured
See All Featured
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
240
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
320
Leo the Paperboy
mayatellez
9
2.3k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Speed Design
sergeychernyshev
33
2.1k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
420
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
420
We Have a Design System, Now What?
morganepeng
55
8.3k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
202
76k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
370
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]