0.1, self::REDUCED => 0.5, self::COMPRESSED => 0.75, self::NORMAL => 1.0, self::EXTENDED => 1.5 }; } /** * Get compression requirement for this level */ public function requiresCompression(): bool { return match ($this) { self::MINIMAL, self::REDUCED, self::COMPRESSED => true, self::NORMAL, self::EXTENDED => false }; } /** * Get default compression level for this cache level */ public function getDefaultCompressionLevel(): CompressionLevel { return match ($this) { self::MINIMAL => CompressionLevel::MAXIMUM, self::REDUCED => CompressionLevel::HIGH, self::COMPRESSED => CompressionLevel::MEDIUM, self::NORMAL => CompressionLevel::LOW, self::EXTENDED => CompressionLevel::NONE }; } /** * Get description of this cache level */ public function getDescription(): string { return match ($this) { self::MINIMAL => 'Minimal caching with maximum compression and very short TTL', self::REDUCED => 'Reduced caching with high compression and short TTL', self::COMPRESSED => 'Normal caching with medium compression', self::NORMAL => 'Standard caching behavior', self::EXTENDED => 'Extended caching with longer TTL and no compression' }; } /** * Check if this level is more aggressive than another */ public function isMoreAggressiveThan(self $other): bool { $levels = [ self::EXTENDED => 0, self::NORMAL => 1, self::COMPRESSED => 2, self::REDUCED => 3, self::MINIMAL => 4, ]; return $levels[$this] > $levels[$other]; } /** * Suggest cache level based on memory pressure */ public static function fromMemoryPressure(float $pressure): self { return match (true) { $pressure >= 0.95 => self::MINIMAL, $pressure >= 0.85 => self::REDUCED, $pressure >= 0.75 => self::COMPRESSED, $pressure >= 0.30 => self::NORMAL, default => self::EXTENDED }; } }