This commit is contained in:
Travis Fischer
2022-03-25 10:42:28 -04:00
parent 2b556582b3
commit 4a4b8e1c3b
4 changed files with 32 additions and 8 deletions

View File

@@ -94,6 +94,8 @@ export const includeNotionIdInUrls: boolean = getSiteConfig(
// ----------------------------------------------------------------------------
// Optional redis instance for persisting preview images
export const isRedisEnabled: boolean = getSiteConfig('isRedisEnabled', false)
// (if you want to enable redis, only REDIS_HOST and REDIS_PASSWORD are required)
// we recommend that you store these in a local `.env` file
export const redisHost: string | null = getEnv('REDIS_HOST', null)

View File

@@ -1,14 +1,12 @@
import Keyv from 'keyv'
import {
isPreviewImageSupportEnabled,
redisUrl,
redisNamespace
} from './config'
import { isRedisEnabled, redisUrl, redisNamespace } from './config'
let db: Keyv
if (isPreviewImageSupportEnabled) {
if (isRedisEnabled) {
db = new Keyv(redisUrl, { namespace: redisNamespace || undefined })
} else {
db = new Keyv()
}
export { db }