NewNamespacedCache
Creates a new namespaced cache that prefixes any key with the given namespace.
def NewNamespacedCache(
namespace: string,
underlying: cache.CacheInterface[T]
) - > NamespacedCache[T]
Creates a new namespaced cache that prefixes any key with the given namespace. This allows multiple logical caches to share the same underlying cache storage without key collisions.
Parameters
| Name | Type | Description |
|---|---|---|
| namespace | string | The string prefix to apply to all keys stored or retrieved from the underlying cache. This ensures keys are unique within the shared cache. |
| underlying | cache.CacheInterface[T] | The actual cache implementation that will store the data. The namespaced cache will delegate all operations to this underlying cache after applying the namespace prefix. |
Returns
| Type | Description |
|---|---|
NamespacedCache[T] | A new NamespacedCache instance that wraps the underlying cache with the specified namespace. |