{"repo":"JoelLefkowitz/cached-prisma","free":true,"listed":false,"github":"https://github.com/JoelLefkowitz/cached-prisma","clone":"git clone https://github.com/JoelLefkowitz/cached-prisma.git","description":"Add a caching interface to Prisma, compatible with Memcached, Redis and Hazelcast.","language":"TypeScript","stars":89,"topics":["caching","prisma","hazelcast","memcached","redis"],"license":"MIT","category":"databases-storage","readme_excerpt":"Cached Prisma Add a caching interface to Prisma, compatible with Memcached, Redis and Hazelcast. Motivation Prisma bundles their caching features into Accelerate which is sold as a subscription. It's unlikely they'll ever support caching outside of accelerate with services like Memcached and Redis . This package adds the caching logic to the prisma client for your choice of cache provider. Performance Installing Documentation Documentation and more detailed examples are hosted on Github Pages. Usage To control the object used for cache storage you can extend the Prisma class: Caches are also provided for Memcached , Redis , and Hazelcast . Minimal example Create a prisma schema: Create a database. In this example we create a postgres container. You can switch the db, user and password for your environment. Define the DATABASE URL environment variable mentioned in our prisma schema: Generate the types for your client: Migrate the database: Now we can create our client: Caches LruCache LfuCache Memcached Redis Hazelcast Design To implement the cache we need to divert the prisma client's internals so that we can return cached values without hitting the database. To do this we can use a singleton instance for the client and cache objects. Actions Caches implement safe read and write methods: We cache the following methods which do not mutate state: - findUnique - findMany - findFirst - queryRaw - aggregate - count After any of the following state mutating methods we flush the cac","default_branch":null,"files":null,"tree":[],"storefront":"/r/JoelLefkowitz","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/JoelLefkowitz/cached-prisma/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}