NullCache.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. * @return iterable
  31. */
  32. public function getMultiple($keys, $default = null)
  33. {
  34. foreach ($keys as $key) {
  35. yield $key => $default;
  36. }
  37. }
  38. /**
  39. * {@inheritdoc}
  40. *
  41. * @return bool
  42. */
  43. public function has($key)
  44. {
  45. return false;
  46. }
  47. /**
  48. * {@inheritdoc}
  49. *
  50. * @return bool
  51. */
  52. public function clear()
  53. {
  54. return true;
  55. }
  56. /**
  57. * {@inheritdoc}
  58. *
  59. * @return bool
  60. */
  61. public function delete($key)
  62. {
  63. return true;
  64. }
  65. /**
  66. * {@inheritdoc}
  67. *
  68. * @return bool
  69. */
  70. public function deleteMultiple($keys)
  71. {
  72. return true;
  73. }
  74. /**
  75. * {@inheritdoc}
  76. *
  77. * @return bool
  78. */
  79. public function set($key, $value, $ttl = null)
  80. {
  81. return false;
  82. }
  83. /**
  84. * {@inheritdoc}
  85. *
  86. * @return bool
  87. */
  88. public function setMultiple($values, $ttl = null)
  89. {
  90. return false;
  91. }
  92. }