import type { CacheInterface, TypeCacheKey, TypePartialCacheKey } from '@cachehub/core'; export declare class CloudflareCache implements CacheInterface { private readonly baseUrl; private readonly getCache; /** * Constructor * * @param {string} baseUrl - The base URL for cache keys * @param {() => Promise} [getCache] - Function to get the cache instance */ constructor(baseUrl: string, getCache?: () => Promise); /** * Sets a value for a given key for a certain period of time * * @param {string | TypeCacheKey} key - The key of the entry * @param {TypeValue} value - The value to be stored * @param {number} [expiresAfter] - The time in seconds after which the entry should expire. * @returns {Promise} True if the value is set successfully, false otherwise */ set(key: string | TypeCacheKey, value: TypeValue, expiresAfter?: number): Promise; /** * Returns a value stored for a given key * * @param {string | TypeCacheKey} key - The key of the entry * @returns {Promise} The value stored for the given key */ get(key: string | TypeCacheKey): Promise; /** * Deletes an entry with a given key or pattern * * Supports: * - String keys: 'exact-key' * - TypeCacheKey objects: All treated as pattern deletion for maximum flexibility * - TypePartialCacheKey objects: Pattern deletion based on provided fields * * @param {string | TypeCacheKey | TypePartialCacheKey} key - The key to delete * @returns {Promise} True if any entries were deleted, false otherwise */ delete(key: string | TypeCacheKey | TypePartialCacheKey): Promise; /** * Checks if a key exists in the cache * * @param {string | CacheKey} key - The key to check * @returns {Promise} True if the key exists, false otherwise */ has(key: string | TypeCacheKey): Promise; /** * Deletes cache entries matching a pattern using key tracking * * @private * @param {Cache} cache - The cache instance * @param {TypePartialCacheKey} partialKey - The partial key pattern to match * @returns {Promise} True if any entries were deleted, false otherwise */ private deleteByPattern; /** * Tracks a cache key for pattern deletion support * * @private * @param {Cache} cache - The cache instance * @param {TypeCacheKey} key - The structured cache key * @param {string} serializedKey - The serialized cache key * @returns {Promise} */ private trackKey; /** * Removes a cache key from tracking lists * * @private * @param {Cache} cache - The cache instance * @param {string} serializedKey - The serialized cache key to untrack * @returns {Promise} */ private untrackKey; /** * Removes a key from a specific tracking list * * @private * @param {Cache} cache - The cache instance * @param {string} trackingKey - The tracking key to remove from * @param {string} serializedKey - The serialized key to remove * @returns {Promise} */ private removeKeyFromTrackingList; /** * Updates tracking list or removes it if empty * * @private * @param {Cache} cache - The cache instance * @param {string} trackingKey - The tracking key to update * @param {string[]} updatedKeys - The updated list of keys * @returns {Promise} */ private updateOrRemoveTrackingList; /** * Gets the most appropriate tracking key for a partial key pattern * * @private * @param {TypePartialCacheKey} partialKey - The partial key pattern * @returns {string} The tracking key that contains potential matches */ private getMostSpecificTrackingKey; /** * Checks if a serialized key matches a partial key pattern * * @private * @param {string} serializedKey - The serialized cache key * @param {TypePartialCacheKey} partialKey - The partial key pattern to match * @returns {boolean} True if the key matches the pattern */ private keyMatchesPattern; /** * Checks if namespace matches * * @private * @param {string[]} parts - The serialized key parts * @param {string} namespace - The namespace to match * @returns {boolean} True if namespace matches */ private namespaceMatches; /** * Checks if ID matches (if specified) * * @private * @param {string[]} parts - The serialized key parts * @param {string} [id] - The ID to match (optional) * @returns {boolean} True if ID matches or is not specified */ private idMatches; /** * Checks if context matches (if specified) * * @private * @param {string[]} parts - The serialized key parts * @param {Record} [context] - The context to match (optional) * @returns {boolean} True if context matches or is not specified */ private contextMatches; /** * Parses context from serialized key parts * * @private * @param {string[]} parts - The serialized key parts * @returns {Map} Map of context key-value pairs */ private parseContextFromSerializedKey; /** * Checks if all required context properties match * * @private * @param {Map} contextMap - Map of parsed context from serialized key * @param {Record} requiredContext - Required context properties to match * @returns {boolean} True if all required properties match */ private allRequiredContextPropertiesMatch; /** * Generates tracking keys for a given cache key * * @private * @param {TypeCacheKey | TypePartialCacheKey} key - The cache key * @returns {string[]} Array of tracking keys */ private generateTrackingKeys; /** * Generates possible tracking keys for a serialized cache key (for cleanup) * * @private * @param {string} serializedKey - The serialized cache key * @returns {string[]} Array of possible tracking keys */ private generatePossibleTrackingKeys; /** * Gets tracked keys for a tracking key * * @private * @param {Cache} cache - The cache instance * @param {string} trackingKey - The tracking key * @returns {Promise} Array of tracked keys */ private getTrackedKeys; /** * Sets tracked keys for a tracking key * * @private * @param {Cache} cache - The cache instance * @param {string} trackingKey - The tracking key * @param {string[]} keys - Array of keys to track * @returns {Promise} */ private setTrackedKeys; /** * Deletes a cache entry by setting it to null with a 1 second TTL * This works around Cloudflare Cache API delete() not working in development * * @private * @param {Cache} cache - The cache instance * @param {string} key - The cache key to delete * @returns {Promise} Always returns true since TTL set operations work */ private deleteByTTL; /** * Checks if a key object is a complete TypeCacheKey (has required id field) * * @private * @param {TypeCacheKey | TypePartialCacheKey} key - The key to check * @returns {boolean} True if key has id field (complete), false if partial */ private isCompleteKey; /** * Unescapes special characters in cache key values * * @private * @param {string} value - Value to unescape * @returns {string} Unescaped value */ private unescapeValue; /** * Returns a cache key as request for a given key * * @param {string} key - The key of the entry * @returns {Request} The cache request */ private getCacheKeyAsRequest; }