prisma-lrucache-middleware
Prisma (2) Client middleware.
Pass an LRU Cache to cache Prisma query results.
Only caches these actions
findOne
findMany
queryRaw
aggregate
Required Reading
Middlewares are an experimental feature. Read more about them here
Quick Start
Install the package using yarn
:
yarn add prisma-lrucache-middleware
Feature flag
Middlewares need to be enabled with the feature flag middlewares like so:
generator client {
provider = "prisma-client-js"
previewFeatures = ["middlewares"]
}
Code
;;; const db = ; const UserCache = 50; db; const PostCache = max: 500 maxAge: 1000 * 60 * 60; db;