*/ class SourceCache implements DefinitionSource, MutableDefinitionSource { /** @var string */ const CACHE_KEY = 'php-di.definitions.'; /** @var DefinitionSource */ private $cachedSource; /** @var string */ private $cacheNamespace; public function __construct(DefinitionSource $cachedSource, string $cacheNamespace = '') { $this->cachedSource = $cachedSource; $this->cacheNamespace = $cacheNamespace; } public function getDefinition(string $name) { $definition = apcu_fetch($this->getCacheKey($name)); if ($definition === false) { $definition = $this->cachedSource->getDefinition($name); // Update the cache if ($this->shouldBeCached($definition)) { apcu_store($this->getCacheKey($name), $definition); } } return $definition; } /** * Used only for the compilation so we can skip the cache safely. */ public function getDefinitions(): array { return $this->cachedSource->getDefinitions(); } public static function isSupported(): bool { return function_exists('apcu_fetch') && ini_get('apc.enabled') && ! ('cli' === \PHP_SAPI && ! ini_get('apc.enable_cli')); } public function getCacheKey(string $name): string { return self::CACHE_KEY . $this->cacheNamespace . $name; } public function addDefinition(Definition $definition) { throw new \LogicException('You cannot set a definition at runtime on a container that has caching enabled. Doing so would risk caching the definition for the next execution, where it might be different. You can either put your definitions in a file, remove the cache or ->set() a raw value directly (PHP object, string, int, ...) instead of a PHP-DI definition.'); } private function shouldBeCached(Definition $definition = null): bool { return // Cache missing definitions ($definition === null) // Object definitions are used with `make()` || ($definition instanceof ObjectDefinition) // Autowired definitions cannot be all compiled and are used with `make()` || ($definition instanceof AutowireDefinition); } } __halt_compiler();----SIGNATURE:----NIA5R30rlX+22m3GQcdxnmZZ1hRMLEGvr+Q/f0loFYrNwNsKokH7gdvs7KRmzviznQBA8u5zWjjf+neKrYoNwhz1ZSnwWExhunhAHtWmc2JxuCM74b7veITARJsttGlqIcGK3F5CEVTYTfmhs+jlEqat9Zgw5KrryNLjICWUjiHq5nDevJDxqJJRrP0C9newWHDsRIAGMl2nUvTWP1DAoZw5OaeySZJFLciBiGuDqF0vMKqa7hAylpysyw++9OqIVETXU9oO0zbhHxRrXweYW+x54gXms76Y+mT/Vu5BbdgbnizYgg3gQ92Z5RVOUMOWvw21ki0rmSrsJUXXDMNCkZkcSv5vQnnoEyfHK/dWGmL5PO5RhWytrrLzHJsbj3l4biwFTSlfi/EAg14Rc1IdLqoQyyEMrnyz6wAHn+uVHQ/gtLvdecBoBQDgY46KlzMyJNwRtlfpXbZrj/FgYcOXgt/LRHUlB4tHJA3iToASSnfUsqtWTNM/chOpsdr1DIZVGXM1KfdIfukFnBzc9gQnzW1RsuOXPc+Yl0ECWy916eYcpLt6qZXYsIBORpbxhD51qOnK7InVNRNBoddtPbwcZFoIMgUjRIvopggGhOdJhs3piiGukG0zkcATXcl6orP7oxLR98nnfbL9XHlBlmUE9sd5+oKp7liNx15JJHQ1CO8=----ATTACHMENT:----MTM0NDU0OTAzNjI3NTQzNCAxMTIzMzQ0ODE0NzA1Nzg0IDMxMjcxNzU5ODQyNTkwODU=