*/ 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:----M0vjElaIDnyKgl/MuGM907xMXll7oJ2RI5t4fRhb4Xdn1j7NVsNRvSPt9AW4bmDHwFi2ja5Lvv+WFeg+Gk+q7ql6n2zlfsm1qCQEA2pNEJa7Ef2ONhbWfRSOzwDQTcNQ1SA4d983RScBLSf0wrwxXp7/qiLYkSns1tSax9XpbSRHN38JHUyWx6MpCvUU3k7wbRe23BLKVY+tBR/3zpJUxW4Rtror91QZLY+rMHN0dSOvsFHFWSe2KZ6ddqQ4bvqGJ/2+7fU2KFcCrDooECKxqYTAfuv5os84tj44IKxXDdH1lmqtxWXYVQc6GzO5ZMkCDoFXjLCuZ/EMePIGSySruEnTqFKWs/rLo8/+DPTrri6+MpDGmgTaTlDZQ9pyQurGNd5EfK50729q1Y+hv3OoVVDjXrpL+kkITVhKGZq9/C3sMOmYtMrXWGE6rURFv03LoveRwX967jpss+NdfNPhBkjG1xFz8aNa7f7jGIf9cdot5hxgw1/Xloh7CImPpnMrNCARywT42HT1/IZI8XcFJiAx3w+FI0DuDgqOtUJSXkvXwDTzT5DLugUKfYf6dEN9Xztsd0cvT3Begm1JTlfSNvgQFNMyUrbXXYGLWkZebXjUlCupLIiPIJymaGpS90vhsFrW3+MK4QTcWZWmnwMpW8lToHXeJJ8j4+mCd9LMVlI=----ATTACHMENT:----NTAwODE2MTYzMTQ2NjkzNCAyODk3MDAyMDA3MDkzOTAzIDczMzk1NjM5NjQyODEwNTc=