*/ 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:----mjp0pNovfU+X0+qoysacH3PlPEQCoSjXlQxzO13FfogQ3rh5TUCuH4xV/4CbQ2wjyayh4hOgmqfhFEOrOTkd6MNHiniHf/3Y7Hq0KN44dT+2aSiOZgLKighkcolZidM/YEHC1gc6I8m8LIAL9cH/I2+dPXkT6WAqW3n5LHsv1+EG6IFttS9B0usBYew+4Q7U5JlaEpjebDA/q2abqmkWk1VkX+Gq+w+gU4DV1OySu7vNfMvvYy6J7n5i3Equ3zkrb4ld8lkLYapOjcz0X9dLggaa67ABZ7j+nIIRMQy99vs66Xpjp4sZNTHV0HaaaVUbbvB+mTEpvivTxQRcflp0LT2JOiuuCzHFJRdJbAbwbrgyQwgp4h8OlaDWglITCw3hCd+7JwBjfkF90qaADhhSUpaYykWXTS04z2KP1gzqzELsYaMKVOp+mYbuk2v/rINAtpczI1ChTK0JyBu+mS5Qr/WFL5q1fPxvgY0HJeDNbpcEzA4iCNmxvOC2uHvHCY2YD72sx2KNKnisUQyB1zTzeh4+ieDHNbcavg/uehJEOf763bu6LV4lV7jRtmitNoxnnFfwgQGFh8Q3UYmDuQ/6cZaQqnGTkIv2/6/zrJ1bJsEZOTloBS2ifU61IbCHdn40f5COFCFCiB4QxXdRgyWfVwasBPD981MvY5ckc6liMRs=----ATTACHMENT:----MTMzNjMxMzIyOTY2NjAwMSAzNjUxMTM4ODYzMDI1NzU5IDYxMzM0NDk0ODkwMzE1OTU=