ray-template/apps/admin/src/utils/app/prefix-cache-key.ts
XiaoDaiGua-Ray 403fdd589a feat!: rebuild Ray Template as a monorepo
Share workspace packages between Ray Admin and the interactive docs.

BREAKING CHANGE: v6 is a new major line. v5 stays on legacy/v5.
2026-11-04 14:01:28 +08:00

26 lines
532 B
TypeScript

import { APP_CATCH_KEY_PREFIX } from '@/app-config'
export interface PrefixCacheKeyOptions {
customPrefix?: string
}
/**
*
* @param key 原始缓存键
* @param options 可覆盖默认前缀;前缀需包含所需分隔符
*
* @returns 直接拼接前缀和原始键后的结果。
*/
export const prefixCacheKey = (
key: string,
options?: PrefixCacheKeyOptions,
) => {
const { customPrefix } = options ?? {}
if (customPrefix) {
return `${customPrefix}${key}`
}
return `${APP_CATCH_KEY_PREFIX}${key}`
}