javascript - 更新/补丁无法在使用在钩子中使用的 feathers-redis-cache 的 feathersjs 应用程序服务中工作
问题描述
我正在使用 feathers-redis-cache 来缓存我的 feathersjs 应用程序中某些服务的数据。这就是我的钩子的样子:
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()]
},
现在,前端正在发送通过 GET 调用(feathersjs get)获取的格式正确的数据,并且在更改并保存表单中的数据之后,PATCH(feathersjs 补丁)正在返回旧的缓存数据。一旦我从之前的钩子/补丁方法 redisCache.before() 中删除,数据的修补就没有问题了。使用该 redis 方法并使用 find 而不是 get 获取数据,这个问题就不存在了。
如果使用 get 获取数据然后修补并且使用 find 获取数据时它正在工作,有人可以解释为什么修补不起作用的原因吗?
解决方案
推荐阅读
- reactjs - React firebase google authentication 奇怪的行为
- amazon-web-services - Add users in AWS account
- caffeine-cache - 如何使咖啡因异步?
- python - 如何参数化pytest中的参数?
- python - 为什么图像属性没有方法文件名上传到 gcs?
- r - 在 Iris 数据集中查找均值和标准差并绘制图形
- android - Flutter:结合 Notification Channel 和 FCM Topic
- r - 如何更改 S4 对象中的对象类型?
- go - Golang 升级不兼容的模块
- java - “org.apache.tomcat.jdbc.pool.DataSourceFactory”的“maxAge”是否会影响活动数据库连接