Skip to content

Commit

Permalink
[WEB] Provide ability to skip redis cache via env var
Browse files Browse the repository at this point in the history
  • Loading branch information
samtgarson committed Jun 8, 2024
1 parent 8b539ef commit fa50f19
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion web/src/utils/kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { SuperJSONResult } from 'superjson/dist/types'
import { stringify } from './superjson'

const CACHE_VERSION = 'v1'
const ROOT_SKIP = !!process.env.SKIP_REDIS_CACHE

const redis = new Redis({
url: process.env.UPSTASH_REDIS_URL,
Expand All @@ -25,7 +26,7 @@ export async function getOrPopulateKv<R>(
skipResult?: (data: R) => boolean
} = {}
) {
if (!enabled) return exec()
if (!enabled || ROOT_SKIP) return exec()

const key = ['baf', CACHE_VERSION, ...keys].join(':')
try {
Expand Down

0 comments on commit fa50f19

Please sign in to comment.