-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
I have a problem that when I update a model the cache does not update, the same information remains, I tried to hook them in sequelize, but it did not work.
const config = require('../config'),
Sequelize = require('sequelize'),
cacher = require('sequelize-redis-cache'),
redis = require('redis'),
redisCache = redis.createClient(config.redis.port, config.redis.host),
database = new Sequelize(config.DATABASE_URI, {
define: {
hooks: {
afterCreate: (instance, options) => clearCache(instance, options),
afterDestroy: (instance, options) => clearCache(instance, options),
afterUpdate: (instance, options) => clearCache(instance, options),
afterSave: (instance, options) => clearCache(instance, options),
afterUpsert: (instance, options) => clearCache(instance, options),
}
}
});
const clearCache = function(instance, options) {
if (instance.constructor.name === 'Session') {
return;
}
cacher(database, redisCache).model(instance.constructor.name).clearCache();
};
Metadata
Metadata
Assignees
Labels
No labels