NullCache.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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;
  12. /**
  13. * @author Nicolas Grekas <p@tchwork.com>
  14. */
  15. class NullCache implements CacheInterface
  16. {
  17. /**
  18. * {@inheritdoc}
  19. */
  20. public function get($key, $default = null)
  21. {
  22. return $default;
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function getMultiple($keys, $default = null)
  28. {
  29. foreach ($keys as $key) {
  30. yield $key => $default;
  31. }
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function has($key)
  37. {
  38. return false;
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function clear()
  44. {
  45. return true;
  46. }
  47. /**
  48. * {@inheritdoc}
  49. */
  50. public function delete($key)
  51. {
  52. return true;
  53. }
  54. /**
  55. * {@inheritdoc}
  56. */
  57. public function deleteMultiple($keys)
  58. {
  59. return true;
  60. }
  61. /**
  62. * {@inheritdoc}
  63. */
  64. public function set($key, $value, $ttl = null)
  65. {
  66. return false;
  67. }
  68. /**
  69. * {@inheritdoc}
  70. */
  71. public function setMultiple($values, $ttl = null)
  72. {
  73. return false;
  74. }
  75. }