forked from
npmx.dev/npmx.dev
[READ-ONLY]
a fast, modern browser for the npm registry
1import { Redis } from '@upstash/redis'
2
3export function getCacheAdapter(prefix: string): CacheAdapter {
4 const config = useRuntimeConfig()
5
6 if (!import.meta.dev && config.upstash?.redisRestUrl && config.upstash?.redisRestToken) {
7 const redis = new Redis({
8 url: config.upstash.redisRestUrl,
9 token: config.upstash.redisRestToken,
10 })
11 return new RedisCacheAdapter(redis, prefix)
12 }
13 return new LocalCacheAdapter()
14}