/** * Namespaced Storage Implementation * * Wraps a StorageAdapter to provide namespace prefixing. * All operations automatically prefix keys with the namespace path. */ import type { StorageAdapter, NamespacedStorage, SetOptions, SetEntry, MessageHandler, Unsubscribe } from './types'; /** * Separator used between namespace segments. */ export declare const NAMESPACE_SEPARATOR = ":"; /** * Build a namespace prefix from name and optional id. * * @param name - Namespace name (e.g., 'session', 'user') * @param id - Optional identifier (e.g., session ID, user ID) * @returns Prefix string with trailing separator * * @example * ```typescript * buildPrefix('session', 'abc123'); // 'session:abc123:' * buildPrefix('global'); // 'global:' * ``` */ export declare function buildPrefix(name: string, id?: string): string; /** * Implementation of NamespacedStorage. * Wraps a StorageAdapter and prefixes all keys. */ export declare class NamespacedStorageImpl implements NamespacedStorage { private readonly adapter; readonly prefix: string; readonly root: StorageAdapter; constructor(adapter: StorageAdapter, prefix?: string, root?: StorageAdapter); /** * Add prefix to a key. */ private prefixKey; /** * Remove prefix from a key. */ private unprefixKey; /** * Add prefix to a pattern (for keys() operation). */ private prefixPattern; /** * Add prefix to a channel (for pub/sub). */ private prefixChannel; namespace(name: string, id?: string): NamespacedStorage; connect(): Promise; disconnect(): Promise; ping(): Promise; get(key: string): Promise; set(key: string, value: string, options?: SetOptions): Promise; delete(key: string): Promise; exists(key: string): Promise; mget(keys: string[]): Promise<(string | null)[]>; mset(entries: SetEntry[]): Promise; mdelete(keys: string[]): Promise; expire(key: string, ttlSeconds: number): Promise; ttl(key: string): Promise; keys(pattern?: string): Promise; count(pattern?: string): Promise; incr(key: string): Promise; decr(key: string): Promise; incrBy(key: string, amount: number): Promise; publish(channel: string, message: string): Promise; subscribe(channel: string, handler: MessageHandler): Promise; supportsPubSub(): boolean; } /** * Create a root namespaced storage from an adapter. * The root has an empty prefix. * * @param adapter - Storage adapter to wrap * @returns RootStorage (NamespacedStorage with empty prefix) */ export declare function createRootStorage(adapter: StorageAdapter): NamespacedStorage; /** * Create a namespaced storage with an initial prefix. * * @param adapter - Storage adapter to wrap * @param prefix - Initial prefix (without trailing separator) * @returns NamespacedStorage with the given prefix */ export declare function createNamespacedStorage(adapter: StorageAdapter, prefix: string): NamespacedStorage;