Gorgon.js Version 1.5.1
Faster Frontends, Faster servers, Less database calls. Simple.
A 3.83kb (1.3kb gzipped) caching library for your application.
-
Documentation →
Learn how Gorgon works and how to use it.
-
Github →
Explore the source code and example projects
Gorgon.js is a caching library designed to cache async functions and promises. It can be used in the frontend and backend of your application. Use it with any database, and any framework.
- Frontend / Backend Support
- Customizable Storage Providers
- Typescript Support
import Gorgon from '@gorgonjs/gorgon';
const getTODO = async (id: number) => {
return await Gorgon.get(`movie/${id}`, async () => {
return prisma.movie.findFirst({where: {id}, include: {tags: true}});
}, 60 * 1000); // 1 minute
};
const todo1 = await getTODO(1); // fetches from API
console.log(todo1);
const todo2 = await getTODO(2); // fetches from API
console.log(todo2);
const todo3 = await getTODO(1); // fetches from cache
console.log(todo3);