3 ms·
whenever you do a write to your database, you have to think what caches might be depending on your write and you'll have to remember to fire events accordingly.
by yummyfajitas 13y ago
whenever you do a write to your database, you have to think what caches might be depending on your write and you'll have to remember to fire events accordingly.
That's the beauty of this approach. You don't need to think about it when you write. You only need to think about it in the caching layer.
Say you want to cache the query:
SELECT * FROM foo AS f INNER JOIN bar AS b ON b.foo_id = f.id WHERE f.id=12345;
The caching layer needs to `LISTEN foo_updates` and `LISTEN bar_updates`.
Anyone doing a write doesn't need to think about this at all if you set up database triggers to send the NOTIFY events.