Gorgon.js

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.

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.

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);