import type { ApplicationService } from '@adonisjs/core/types'; /** Minimal interface for the Redis client methods used by CacheInspector. */ interface RedisClient { ping(): Promise; info(section: string): Promise; dbsize(): Promise; scan(cursor: string, ...args: (string | number)[]): Promise<[string, string[]]>; type(key: string): Promise; ttl(key: string): Promise; get(key: string): Promise; del(key: string): Promise; lrange(key: string, start: number, stop: number): Promise; smembers(key: string): Promise; zrange(key: string, start: number, stop: number, ...args: string[]): Promise; hgetall(key: string): Promise>; xrange(key: string, start: string, end: string, ...args: (string | number)[]): Promise; call(...args: (string | number)[]): Promise; } export interface CacheStats { /** Whether the Redis connection is alive. */ connected: boolean; /** Total keyspace hits. */ hits: number; /** Total keyspace misses. */ misses: number; /** Hit rate as a percentage (0-100). */ hitRate: number; /** Redis memory usage in bytes. */ memoryUsedBytes: number; /** Human-readable memory usage (e.g. "12.34 MB"). */ memoryUsedHuman: string; /** Number of connected clients. */ connectedClients: number; /** Total number of keys across all databases. */ totalKeys: number; } export interface CacheKeyEntry { /** The full key name. */ key: string; /** Redis data type (string, list, set, hash, zset, stream). */ type: string; /** TTL in seconds, or -1 if no expiry, or -2 if key does not exist. */ ttl: number; } export interface CacheKeyListResult { /** Keys matching the scan pattern. */ keys: CacheKeyEntry[]; /** Cursor for the next SCAN iteration, or '0' when complete. */ cursor: string; } export interface CacheKeyDetail { /** The full key name. */ key: string; /** The stored value (stringified). */ value: string; /** Redis data type. */ type: string; /** TTL in seconds, or -1 if no expiry. */ ttl: number; /** Approximate size in bytes (from MEMORY USAGE, if available). */ sizeBytes: number | null; } /** * Inspects Redis cache keys, values, and statistics. * * Designed for the full-page dashboard's Cache section. * All methods are safe to call even when Redis is unavailable -- * they catch errors and return sensible defaults. */ export declare class CacheInspector { private redis; constructor(redis: RedisClient); /** * Detect whether `@adonisjs/cache` or `@adonisjs/redis` is available * in the application container. */ static isAvailable(app: ApplicationService): Promise; /** * Get high-level cache / Redis statistics. */ getStats(): Promise; /** * List keys using Redis SCAN (cursor-based, non-blocking). * * @param pattern Glob pattern for key matching (default `'*'`). * @param cursor SCAN cursor from a previous call (default `'0'`). * @param count Hint for how many keys to return per call (default `100`). */ listKeys(pattern?: string, cursor?: string, count?: number): Promise; /** * Get full details for a single cache key. */ getKey(key: string): Promise; /** * Delete a cache key. * * @returns `true` if the key was deleted, `false` otherwise. */ deleteKey(key: string): Promise; /** * Read a key's value using the appropriate Redis command for its type. */ private getValueByType; } export {};