PhpFilesCache.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\Simple;
  11. use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
  12. use Symfony\Component\Cache\Exception\CacheException;
  13. use Symfony\Component\Cache\PruneableInterface;
  14. use Symfony\Component\Cache\Traits\PhpFilesTrait;
  15. use Symfony\Contracts\Cache\CacheInterface;
  16. @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', PhpFilesCache::class, PhpFilesAdapter::class, CacheInterface::class), \E_USER_DEPRECATED);
  17. /**
  18. * @deprecated since Symfony 4.3, use PhpFilesAdapter and type-hint for CacheInterface instead.
  19. */
  20. class PhpFilesCache extends AbstractCache implements PruneableInterface
  21. {
  22. use PhpFilesTrait;
  23. /**
  24. * @param $appendOnly Set to `true` to gain extra performance when the items stored in this pool never expire.
  25. * Doing so is encouraged because it fits perfectly OPcache's memory model.
  26. *
  27. * @throws CacheException if OPcache is not enabled
  28. */
  29. public function __construct(string $namespace = '', int $defaultLifetime = 0, string $directory = null, bool $appendOnly = false)
  30. {
  31. $this->appendOnly = $appendOnly;
  32. self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time();
  33. parent::__construct('', $defaultLifetime);
  34. $this->init($namespace, $directory);
  35. $this->includeHandler = static function ($type, $msg, $file, $line) {
  36. throw new \ErrorException($msg, 0, $type, $file, $line);
  37. };
  38. }
  39. }