Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

82 lines
2.8KB

  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\caching;
  8. /**
  9. * DummyCache is a placeholder cache component.
  10. *
  11. * DummyCache does not cache anything. It is provided so that one can always configure
  12. * a 'cache' application component and save the check of existence of `\Yii::$app->cache`.
  13. * By replacing DummyCache with some other cache component, one can quickly switch from
  14. * non-caching mode to caching mode.
  15. *
  16. * @author Qiang Xue <qiang.xue@gmail.com>
  17. * @since 2.0
  18. */
  19. class DummyCache extends Cache
  20. {
  21. /**
  22. * Retrieves a value from cache with a specified key.
  23. * This is the implementation of the method declared in the parent class.
  24. * @param string $key a unique key identifying the cached value
  25. * @return string|boolean the value stored in cache, false if the value is not in the cache or expired.
  26. */
  27. protected function getValue($key)
  28. {
  29. return false;
  30. }
  31. /**
  32. * Stores a value identified by a key in cache.
  33. * This is the implementation of the method declared in the parent class.
  34. *
  35. * @param string $key the key identifying the value to be cached
  36. * @param string $value the value to be cached
  37. * @param integer $duration the number of seconds in which the cached value will expire. 0 means never expire.
  38. * @return boolean true if the value is successfully stored into cache, false otherwise
  39. */
  40. protected function setValue($key, $value, $duration)
  41. {
  42. return true;
  43. }
  44. /**
  45. * Stores a value identified by a key into cache if the cache does not contain this key.
  46. * This is the implementation of the method declared in the parent class.
  47. * @param string $key the key identifying the value to be cached
  48. * @param string $value the value to be cached
  49. * @param integer $duration the number of seconds in which the cached value will expire. 0 means never expire.
  50. * @return boolean true if the value is successfully stored into cache, false otherwise
  51. */
  52. protected function addValue($key, $value, $duration)
  53. {
  54. return true;
  55. }
  56. /**
  57. * Deletes a value with the specified key from cache
  58. * This is the implementation of the method declared in the parent class.
  59. * @param string $key the key of the value to be deleted
  60. * @return boolean if no error happens during deletion
  61. */
  62. protected function deleteValue($key)
  63. {
  64. return true;
  65. }
  66. /**
  67. * Deletes all values from cache.
  68. * This is the implementation of the method declared in the parent class.
  69. * @return boolean whether the flush operation was successful.
  70. */
  71. protected function flushValues()
  72. {
  73. return true;
  74. }
  75. }