`Prisma.$queryRaw` is being cached
CristianPQ opened this issue · 2 comments
Describe the bug
A clear and concise description of what the bug is.
Prisma.$queryRaw
is being cached but documentation mentions that it should not happen.
They generated key has the format:
{ "params":{ "action": "queryRaw", "args": { "parameters": ... } } }
To Reproduce
Steps to reproduce the behavior:
- Configure
onHit
andonMiss
functions to print thekey
- Execute a query with
Prisma.$queryRaw
-- >onMiss
will be executed - Execute same query with as step 2 -- >
onHit
will be executed
Expected behavior
To not trigger the cache because of being 'queryRaw' query type
Desktop (please complete the following information):
- OS: any
- Browser any
- Version any
Smartphone (please complete the following information):
- Device: any
- OS: any
- Browser any
- Version any
Additional context
"@prisma/client": "^4.8.0"
Possible fix
include "queryRaw"
in defaultMutationMethods
array
We have been able to fix our issue by sending timestamp dynamically instead of relying on ´CURRENT_DATE´ from PostgreSQL which creates different keys and is constantly a miss for the cache middleware.
But still it would be really useful at least to update the documentation
had the same issue,
resolved by setting cacheTime for every model to some value, and leaving default cacheTime 0.
that way since queryRaw record has no model, it doesn't get cached
maybe it will help somebody