NullCache.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 Psr\SimpleCache\CacheInterface as Psr16CacheInterface;
  12. use Symfony\Component\Cache\Adapter\NullAdapter;
  13. use Symfony\Contracts\Cache\CacheInterface;
  14. @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', NullCache::class, NullAdapter::class, CacheInterface::class), E_USER_DEPRECATED);
  15. /**
  16. * @deprecated since Symfony 4.3, use NullAdapter and type-hint for CacheInterface instead.
  17. */
  18. class NullCache implements Psr16CacheInterface
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function get($key, $default = null)
  24. {
  25. return $default;
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function getMultiple($keys, $default = null)
  31. {
  32. foreach ($keys as $key) {
  33. yield $key => $default;
  34. }
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function has($key)
  40. {
  41. return false;
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function clear()
  47. {
  48. return true;
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function delete($key)
  54. {
  55. return true;
  56. }
  57. /**
  58. * {@inheritdoc}
  59. */
  60. public function deleteMultiple($keys)
  61. {
  62. return true;
  63. }
  64. /**
  65. * {@inheritdoc}
  66. */
  67. public function set($key, $value, $ttl = null)
  68. {
  69. return false;
  70. }
  71. /**
  72. * {@inheritdoc}
  73. */
  74. public function setMultiple($values, $ttl = null)
  75. {
  76. return false;
  77. }
  78. }