Simone Sanfratello
Event based cache invalidation in GraphQL
#1about 2 minutes
Understanding GraphQL resolvers as cacheable functions
GraphQL resolvers can be treated as pure functions, allowing their results to be memoized and cached based on query arguments.
#2about 5 minutes
Comparing time-based and event-based cache invalidation
Time-based invalidation is simple but can serve stale data, whereas event-based invalidation keeps data synced but is more complex to implement.
#3about 4 minutes
Choosing a storage backend and generating cache keys
A cache can use fast in-memory storage for small, frequent data or a shared Redis instance for larger datasets across multiple nodes.
#4about 4 minutes
Using references for targeted cache invalidation
By tagging cache entries with references to the underlying data entities, you can precisely invalidate them when a write event occurs.
#5about 7 minutes
Live demo of setting up a basic GraphQL server
A Fastify server is configured with the Mercurius plugin to serve a GraphQL schema with user and country data from an in-memory database.
#6about 3 minutes
Live demo of implementing a time-based cache policy
The Mercurius Cache plugin is configured with a time-to-live policy for a query, using onHit and onMiss events to verify its effectiveness.
#7about 5 minutes
Live demo of solving stale data with event invalidation
An invalidation function is added to a mutation resolver, which uses references to clear the relevant user data from the cache upon update.
#8about 3 minutes
Exploring advanced features of Mercurius Cache
Mercurius Cache also supports custom key generation, request deduplication, programmatic invalidation with wildcards, and garbage collection for references.
#9about 4 minutes
Q&A on career advice and GraphQL best practices
Common GraphQL pitfalls are discussed, such as neglecting to use DataLoaders to solve the N+1 query problem.
Related jobs
Jobs that call for the skills explored in this talk.
Hubert Burda Media
München, Germany
€80-95K
Intermediate
Senior
JavaScript
Node.js
+1
Matching moments
06:47 MIN
Solving date and time issues with the Temporal API
WeAreDevelopers LIVE – You Don’t Need JavaScript, Modern CSS and More
02:33 MIN
Why you might not need JavaScript for everything
WeAreDevelopers LIVE – You Don’t Need JavaScript, Modern CSS and More
08:07 MIN
Exploring modern JavaScript performance and new CSS features
WeAreDevelopers LIVE – AI, Freelancing, Keeping Up with Tech and More
01:15 MIN
Crypto crime, EU regulation, and working while you sleep
Fake or News: Self-Driving Cars on Subscription, Crypto Attacks Rising and Working While You Sleep - Théodore Lefèvre
07:46 MIN
The challenge of keeping up with modern CSS
WeAreDevelopers LIVE – AI, Freelancing, Keeping Up with Tech and More
11:10 MIN
The only frontend stack that truly matters
WeAreDevelopers LIVE – Frontend Inspirations, Web Standards and more
03:31 MIN
The value of progressive enhancement and semantic HTML
WeAreDevelopers LIVE – You Don’t Need JavaScript, Modern CSS and More
09:00 MIN
Navigating the growing complexity of modern CSS
WeAreDevelopers LIVE – You Don’t Need JavaScript, Modern CSS and More
Featured Partners
Related Videos
GraphQL: Does it replace SQL, REST or Something Else?
Gregor Bauer
Putting the Graph In GraphQL With The Neo4j GraphQL Library
William Lyon
HTTP headers that make your website go faster
Thijs Feryn
Things I learned while writing high-performance JavaScript applications
Michele Riva
Advanced Caching Patterns used by 2000 microservices
Natan Silnitsky
Maximising Cassandra's Potential: Tips on Schema, Queries, Parallel Access, and Reactive Programming
Hartmut Armbruster
GraphQL + Apollo + Next.js: A Lovely Trio
Josh Goldberg
Rapid GraphQL API Development with PostGraphile
Ruwan Xaviour Fernando
Related Articles
View all articles



From learning to earning
Jobs that call for the skills explored in this talk.

Confideck GmbH
Vienna, Austria
Remote
Intermediate
Senior
Node.js
MongoDB
TypeScript

Okeiro
Paris, France
Senior
Node.js
GraphQL
PostgreSQL
TypeScript
Microservices

nono
£75-120K
Intermediate
API
Node.js
Grafana
GraphQL
+9

nono
£75-120K
Intermediate
API
Node.js
Grafana
GraphQL
+9

QuidVista
Clevedon, United Kingdom
Remote
£25-35K
Node.js
GraphQL
JavaScript

SMG Swiss Marketplace Group
Canton de Valbonne, France
Senior

Visonum GmbH
Remote
Junior
Intermediate
React
Redux
TypeScript

SMG Swiss Marketplace Group
Belgrade, Serbia
Senior

OKAPI: Orbits
Barcelona, Spain
Remote
€70-90K
API
React
Node.js
+2