Skip to main content

namespacedCache

@quik/cache


@quik/cache / namespacedCache

Function: namespacedCache()

namespacedCache(prefix): IQCache

Defined in: cache/src/namespacedCache.ts:21

Returns an IQCache that automatically prefixes every key with prefix:.

Useful for isolating cache entries per module or feature without risk of key collisions when multiple concerns share the same underlying cache backend.

Parameters​

prefix​

string

Namespace prefix applied to every key.

Returns​

IQCache

Example​

const usersCache = namespacedCache('users');
await usersCache.set('session:1', data);
// stored as "users:session:1" in the underlying cache