Open KieronWiltshire opened 7 years ago
Yes this is possible, you can achieve this by adding hooks and implement the logic for invalidation there.
Example:
Model.hook('afterCreate', function(instance, options) {
// Invalidate/update cache here
};
Model.hook('afterDestroy', function(instance, options) {
// Invalidate/update cache here
};
Model.hook('afterUpdate', function(instance, options) {
// Invalidate/update cache here
};
Model.hook('afterSave', function(instance, options) {
// Invalidate/update cache here
};
Model.hook('AfterUpsert', function(created, options) {
// Invalidate/update cache here
};
Thanks man!
@KieronWiltshire If you are using Sequelize 4, check out that module:
https://github.com/idangozlan/sequelize-redis
It's a full solution for caching + invalidating cache easily, and as much as I know it's the only Sequelize 4 caching module (right now).
Disclaimer: I'm the author of that module and I'm using that on production for daily traffic of 1m unique users.
So what I'd like to see implemented, is if the "create" method or similar is executed, then the cache will be invalidated.
For example, if I do a findAll, then a create, and repeat the findAll, I'd like to be able to retrieve the latest included within that find.
Is this possible?