fix: demo cache key prefix

This commit is contained in:
Innei
2022-05-25 21:20:30 +08:00
parent ad1b5f6df3
commit 2c237b7a8d

View File

@@ -1,10 +1,14 @@
import { isInDemoMode } from '~/app.config'
import { RedisKeys } from '~/constants/cache.constant'
type Prefix = 'mx' | 'mx-demo'
const prefix = isInDemoMode ? 'mx-demo' : 'mx'
export const getRedisKey = <T extends string = RedisKeys | '*'>(
key: T,
...concatKeys: string[]
): `mx:${T}${string | ''}` => {
return `mx:${key}${
): `${Prefix}:${T}${string | ''}` => {
return `${prefix}:${key}${
concatKeys && concatKeys.length ? `:${concatKeys.join('_')}` : ''
}`
}