prisma-redis
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

prisma-redis

This package is a middleware for Prisma that caches its requests to a Redis database. Based on the work done by @Asjas on prisma-redis-middleware

This package requires ioredis.

Installation

npm i prisma-redis

or

yarn add prisma-redis

Implementation

import { PrismaClient } from "@prisma/client";
import { createPrismaRedisCache } from "prisma-redis";
import Redis from "ioredis";

const prisma = new PrismaClient();

const redis = new Redis();
prisma.$use(createPrismaRedisCache(["Objects","to","cache"], 60, redis));

...

In the 4th argument you can define object with property 'include' or 'exclude'. That property is an array of these strings: "findUnique", "findFirst", "findMany", "queryRaw", "aggregate", "count" and "groupBy". By default all of the above are cached. Include overrides all and cached are only the ones you include. Exclude excludes only the ones you exclude.

Dependents (0)

Package Sidebar

Install

npm i prisma-redis

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

11.1 kB

Total Files

8

Last publish

Collaborators

  • czm1k3