Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
Update example app
Browse files Browse the repository at this point in the history
  • Loading branch information
Asjas committed Mar 21, 2022
1 parent 1a767c5 commit 475a314
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"license": "MIT",
"scripts": {
"build": "npm run clean && tsc",
"dev": "nodemon src/index.js",
"dev": "nodemon -- --inspect src/index.js",
"clean": "rimraf dist",
"start": "node dist/index.js",
"prisma:generate": "prisma generate",
Expand Down
18 changes: 15 additions & 3 deletions example/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@ console.log(createPrismaRedisCache);
const redis = new Redis(); // Uses default options for Redis connection
const prisma = new PrismaClient.PrismaClient();

const cache = createPrismaRedisCache({ storage: { type: "redis", options: { client: redis } }, defaultCacheTime: 600 });
const cache = createPrismaRedisCache({
storage: { type: "redis", options: { client: redis, invalidation: { referencesTTL: 60 }, log: console } },
defaultCacheTime: 60,
onDedupe: (key) => {
console.log("deduped", key);
},
onHit: (key) => {
console.log("hit", key);
},
onMiss: (key) => {
console.log("miss", key);
},
});

prisma.$use(cache);

Expand All @@ -22,7 +34,7 @@ async function main() {
},
});

console.log(res1);
console.log("res1", res1);

await prisma.user.update({ where: { email: "john@email.com" }, data: { email: "mary@email.com" } });

Expand All @@ -34,7 +46,7 @@ async function main() {
},
});

console.log(res2);
console.log("res2", res2);
}

main()
Expand Down

0 comments on commit 475a314

Please sign in to comment.