Open
Description
It looks like GET requests are cached, so when performing a PATCH request, it modifies the db row, but then returns the result from cache.
// TypeOrmModuleOptions
cache: {
type: 'redis',
options: {
host: process.env.REDIS_HOST,
port: +process.env.REDIS_PORT,
duration: 10000,
},
alwaysEnabled: true,
},
// user.entity.ts
@Crud({
model: {
type: User,
},
params: {
id: {
field: 'id',
type: 'string',
primary: true,
},
},
query: {
cache: 3000
▶ http PATCH :3000/api/users/f333c88b-46ae-436b-b91b-a8994bf8aa35 isActive:=false
HTTP/1.1 200 OK
{
...
"isActive": false,
...
}
~
▶ http PATCH :3000/api/users/f333c88b-46ae-436b-b91b-a8994bf8aa35 isActive:=true
HTTP/1.1 200 OK
{
...
"isActive": false, <-- this should be true, but is returned from cache
...
}
~
▶ http GET :3000/api/users/f333c88b-46ae-436b-b91b-a8994bf8aa35
HTTP/1.1 200 OK
{
...
"isActive": true,
...
}
PUT
seems to not be affected by this issue.
Metadata
Assignees
Labels
No labels