/** * Cache Key Builder Utility * * Provides standardized methods for building cache keys with consistent patterns. * All keys are designed to be prefixed by the service (handled by service layer). * * Key pattern: {prefix}:{type}:{identifier}:{params} * Example: "example:entity:123" or "user:list:page:1" * * @fileoverview Cache key building utilities */ /** * Cache key builder for standardized cache key generation. * * All methods return un-prefixed keys that should be prefixed by the service layer. * This allows each service to namespace their cache keys. * * @example * ```typescript * // In a service with cachePrefix = 'user' * const key = CacheKeyBuilder.entity('123'); * // Returns: "entity:123" * // After service prefixing: "user:entity:123" * ``` */ export declare class CacheKeyBuilder { /** * Build cache key for a single entity by ID * * @param id - Entity ID * @returns Cache key (unprefixed) * * @example * ```typescript * CacheKeyBuilder.entity('123') * // Returns: "entity:123" * // With prefix "user": "user:entity:123" * ``` */ static entity(id: string): string; /** * Build cache key for a list/collection query * * @param params - Query parameters (page, limit, filters, etc.) * @returns Cache key (unprefixed) * * @example * ```typescript * CacheKeyBuilder.list({ page: 1, limit: 10 }) * // Returns: "list:limit:10:page:1" * // With prefix: "user:list:limit:10:page:1" * * CacheKeyBuilder.list() // No params * // Returns: "list:all" * ``` */ static list(params?: Record): string; /** * Build cache key for a named query/filter * * @param queryName - Name of the query (e.g., 'active', 'byStatus', 'search') * @param params - Query parameters * @returns Cache key (unprefixed) * * @example * ```typescript * CacheKeyBuilder.query('active', { status: 'published' }) * // Returns: "query:active:status:\"published\"" * * CacheKeyBuilder.query('search', { q: 'hello', limit: 10 }) * // Returns: "query:search:limit:10:q:\"hello\"" * ``` */ static query(queryName: string, params?: Record): string; /** * Build cache key for aggregate/count operations * * @param operation - Operation name (e.g., 'count', 'sum', 'avg') * @param field - Field name (optional) * @param params - Additional parameters (optional) * @returns Cache key (unprefixed) * * @example * ```typescript * CacheKeyBuilder.aggregate('count') * // Returns: "aggregate:count" * * CacheKeyBuilder.aggregate('sum', 'amount') * // Returns: "aggregate:sum:amount" * * CacheKeyBuilder.aggregate('count', 'users', { status: 'active' }) * // Returns: "aggregate:count:users:status:\"active\"" * ``` */ static aggregate(operation: string, field?: string, params?: Record): string; /** * Build a custom cache key with type and identifier * * @param type - Cache key type * @param identifier - Unique identifier for this cache entry * @param params - Additional parameters (optional) * @returns Cache key (unprefixed) * * @example * ```typescript * CacheKeyBuilder.custom('session', 'abc123') * // Returns: "session:abc123" * * CacheKeyBuilder.custom('report', 'monthly', { year: 2025, month: 1 }) * // Returns: "report:monthly:month:1:year:2025" * ``` */ static custom(type: string, identifier: string, params?: Record): string; } //# sourceMappingURL=CacheKeyBuilder.d.ts.map