import { BarChart3, Zap, Database, HardDrive, RefreshCw, TrendingUp } from 'lucide-react'; import { useCacheStats } from '../hooks/useCacheStats'; import { formatMemory } from '../utils/formatters'; const CacheStats = () => { const { stats, isLoading, error, refresh } = useCacheStats(30000); if (error) { return (

{error}

); } const hitRate = stats?.hit_rate ?? 0; const hitRateColor = hitRate >= 80 ? 'text-green-600' : hitRate >= 50 ? 'text-yellow-600' : 'text-red-600'; const hitRateBg = hitRate >= 80 ? 'bg-green-500' : hitRate >= 50 ? 'bg-yellow-500' : 'bg-red-500'; return (
{/* Header */}

Cache Performance

{/* Stats Grid */}
{/* Total Analyses */} } label="Total Keys" value={stats?.total_keys?.toLocaleString() ?? '-'} isLoading={isLoading} /> {/* Cache Hit Rate */} } label="Hit Rate" value={stats ? `${hitRate.toFixed(1)}%` : '-'} valueClass={hitRateColor} isLoading={isLoading} > {stats && (
)} {/* Hits vs Misses */} } label="Hits / Misses" value={stats ? `${stats.hits} / ${stats.misses}` : '-'} isLoading={isLoading} /> {/* Memory Used */} } label="Memory Used" value={stats ? formatMemory(stats.memory_used_mb) : '-'} isLoading={isLoading} />
{/* Status Indicator */} {stats && (
Redis {stats.status === 'connected' ? 'Connected' : 'Disconnected'} Auto-refreshes every 30s
)}
); }; interface StatCardProps { icon: React.ReactNode; label: string; value: string; valueClass?: string; isLoading?: boolean; children?: React.ReactNode; } const StatCard = ({ icon, label, value, valueClass = '', isLoading, children }: StatCardProps) => { return (
{icon} {label}
{isLoading ? (
) : ( <>

{value}

{children} )}
); }; export default CacheStats;