I am using feathers-redis-cache in order to cache data for some of the services in my feathersjs app. This is how my hooks look like:
const {hooks: redisCache} = require('feathers-redis-cache');
///... some code ..///
before: {
all: [],
find: [validateSearchParams,redisCache.before()],
get: [redisCache.before()],
create: [throw400Error('Not supported')],
update: [throw400Error('Not supported')],
patch: [preventAnyUnallowedChanges, redisCache.before()],
remove: [throw400Error('Not supported')]
},
after: {
all: [],
find: [removeSensitiveData(), redisCache.after({ expiration: 600 })],
get: [preventUnallowedConfig, removeSensitiveData(), redisCache.after({expiration: 600 })],
create: [redisCache.purge()],
update: [redisCache.purge()],
patch: [preventUnallowedData, redisCache.purge()],
remove: [redisCache.purge()]
},
Now, front end is sending properly formatted data that is getting through GET call (feathersjs get) and after changing and saving data in form, PATCH (feathersjs patch) is returning old, cached data. Once I removed from before hook / patch method redisCache.before(), the patching of the data goes without problem. With that redis method in place and with fetching the data with find and not get, this problem does not exist.
Can somebody explain the reason why patching is not working if data is fetched with get and then patched and it is working when data is fetched with find?