hitCount + $this->missCount; if ($total === 0) { return Percentage::fromFloat(0.0); } return Percentage::fromFloat($this->hitCount / $total); } /** * Calculate miss rate */ public function getMissRate(): Percentage { $hitRate = $this->getHitRate(); return Percentage::fromFloat(1.0 - $hitRate->toFloat()); } /** * Get total operations */ public function getTotalOperations(): int { return $this->hitCount + $this->missCount + $this->setCount + $this->removeCount + $this->updateCount; } /** * Convert to array for serialization */ public function toArray(): array { return [ 'total_keys' => $this->totalKeys, 'hit_count' => $this->hitCount, 'miss_count' => $this->missCount, 'set_count' => $this->setCount, 'remove_count' => $this->removeCount, 'update_count' => $this->updateCount, 'hit_rate' => $this->getHitRate()->toFloat(), 'hit_rate_percentage' => $this->getHitRate()->toString(), 'miss_rate' => $this->getMissRate()->toFloat(), 'miss_rate_percentage' => $this->getMissRate()->toString(), 'total_operations' => $this->getTotalOperations(), 'average_set_time_ms' => $this->averageSetTime->toMilliseconds(), 'average_get_time_ms' => $this->averageGetTime->toMilliseconds(), 'expired_keys' => $this->expiredKeys, 'memory_usage_bytes' => $this->memoryUsage->toBytes(), 'memory_usage_mb' => $this->memoryUsage->toMegabytes(), 'memory_usage_human' => $this->memoryUsage->toHumanReadable(), ]; } }