You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PhpFilesAdapter.php 1.3KB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Cache\Adapter;
  11. use Symfony\Component\Cache\Exception\CacheException;
  12. use Symfony\Component\Cache\PruneableInterface;
  13. use Symfony\Component\Cache\Traits\PhpFilesTrait;
  14. class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface
  15. {
  16. use PhpFilesTrait;
  17. /**
  18. * @param $appendOnly Set to `true` to gain extra performance when the items stored in this pool never expire.
  19. * Doing so is encouraged because it fits perfectly OPcache's memory model.
  20. *
  21. * @throws CacheException if OPcache is not enabled
  22. */
  23. public function __construct(string $namespace = '', int $defaultLifetime = 0, string $directory = null, bool $appendOnly = false)
  24. {
  25. $this->appendOnly = $appendOnly;
  26. self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time();
  27. parent::__construct('', $defaultLifetime);
  28. $this->init($namespace, $directory);
  29. $this->includeHandler = static function ($type, $msg, $file, $line) {
  30. throw new \ErrorException($msg, 0, $type, $file, $line);
  31. };
  32. }
  33. }