33[ ![ npm version] ( https://img.shields.io/npm/v/@trieb.work/nextjs-turbo-redis-cache.svg )] ( https://www.npmjs.com/package/@trieb.work/nextjs-turbo-redis-cache )
44![ Turbo redis cache image] ( https://github.com/user-attachments/assets/98e0dfd9-f38a-42ad-a355-9843740cc2d6 )
55
6-
7-
8-
96The ultimate Redis caching solution for Next.js. Built for production-ready, large-scale projects, it delivers unparalleled performance and efficiency with features tailored for high-traffic applications. This package has been created after extensibly testing the @neshca package and finding several major issues with it.
107
118Key Features:
@@ -31,18 +28,19 @@ Currently PPR, 'use cache', cacheLife and cacheTag are not tested. Use these ope
3128
3229## Available Options (needs Option B of getting started)
3330
34- | Option | Description | Default Value |
35- | ---------------------- | ----------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
36- | database | Redis database number to use. Uses DB 0 for production, DB 1 otherwise | ` process.env.VERCEL_ENV === 'production' ? 0 : 1 ` |
37- | keyPrefix | Prefix added to all Redis keys | ` process.env.VERCEL_URL \|\| 'UNDEFINED_URL_' ` |
38- | sharedTagsKey | Key used to store shared tags hash map in Redis | ` '__sharedTags__' ` |
39- | timeoutMs | Timeout in milliseconds for Redis operations | ` 5000 ` |
40- | revalidateTagQuerySize | Number of entries to query in one batch during full sync of shared tags hash map | ` 250 ` |
41- | avgResyncIntervalMs | Average interval in milliseconds between tag map full re-syncs | ` 3600000 ` (1 hour) |
42- | redisGetDeduplication | Enable deduplication of Redis get requests via internal in-memory cache. | ` true ` |
43- | inMemoryCachingTime | Time in milliseconds to cache Redis get results in memory. Set this to 0 to disable in-memory caching completely. | ` 10000 ` |
44- | defaultStaleAge | Default stale age in seconds for cached items | ` 1209600 ` (14 days) |
45- | estimateExpireAge | Function to calculate expire age (redis TTL value) from stale age | Production: ` staleAge * 2 ` <br > Other: ` staleAge * 1.2 ` |
31+ | Option | Description | Default Value |
32+ | ---------------------- | ----------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
33+ | redis_url | Redis connection url | ` process.env.REDIS_URL? process.env.REDIS_URL : process.env.REDISHOST ? ` redis://${process.env.REDISHOST}:${process.env.REDISPORT}` : 'redis://localhost:6379' ` |
34+ | database | Redis database number to use. Uses DB 0 for production, DB 1 otherwise | ` process.env.VERCEL_ENV === 'production' ? 0 : 1 ` |
35+ | keyPrefix | Prefix added to all Redis keys | ` process.env.VERCEL_URL \|\| 'UNDEFINED_URL_' ` |
36+ | sharedTagsKey | Key used to store shared tags hash map in Redis | ` '__sharedTags__' ` |
37+ | timeoutMs | Timeout in milliseconds for Redis operations | ` 5000 ` |
38+ | revalidateTagQuerySize | Number of entries to query in one batch during full sync of shared tags hash map | ` 250 ` |
39+ | avgResyncIntervalMs | Average interval in milliseconds between tag map full re-syncs | ` 3600000 ` (1 hour) |
40+ | redisGetDeduplication | Enable deduplication of Redis get requests via internal in-memory cache. | ` true ` |
41+ | inMemoryCachingTime | Time in milliseconds to cache Redis get results in memory. Set this to 0 to disable in-memory caching completely. | ` 10000 ` |
42+ | defaultStaleAge | Default stale age in seconds for cached items | ` 1209600 ` (14 days) |
43+ | estimateExpireAge | Function to calculate expire age (redis TTL value) from stale age | Production: ` staleAge * 2 ` <br > Other: ` staleAge * 1.2 ` |
4644
4745## Getting started
4846
0 commit comments