1.0.4 • Published 3 years ago

next-build-cache v1.0.4

Weekly downloads
56
License
ISC
Repository
github
Last release
3 years ago

next-build-cache

Next Build Cache is a ultra simple file-based caching solution built for usage during the Next.js build process to pass data from getStaticPaths to getStaticProps without re-fetching data.

The Problem:

Next.js calls separate workers for getStaticPaths and getStaticProps, which means that data cannot be cached in-memory to re-use in getStaticProps.

Installation

Using npm

$ npm i next-build-cache

Using yarn

$ yarn add next-build-cache

Usage

// using es modules 
import { accessCache } from 'next-build-cache';
// using commonjs
const { accessCache } = require('next-build-cache');

// access the cache using the file 'build.cache'
const cache = accessCache('build.cache');

// save a key-value pair with a specified time to live in ms
await cache.put('mykey', 'myvalue', 1000);

// get the value of a key
const value = await cache.get('mykey');

License

MIT

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago