You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.6 KiB

  1. <?php
  2. /**
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage Cache
  7. * @since 2010-03-04
  8. */
  9. abstract class Cache
  10. {
  11. /**
  12. * Add an item to the cache
  13. *
  14. * @param string $key
  15. * @param mixed $value
  16. * @param int $expire
  17. * @return bool
  18. */
  19. abstract public function add($key, $value, $expire = 0);
  20. /**
  21. * Decrement item's value
  22. *
  23. * @param string $key
  24. * @param int $decrement
  25. * @return bool
  26. */
  27. abstract public function decrement($key, $decrement = 1);
  28. /**
  29. * Delete item from the cache
  30. *
  31. * @param string $key
  32. * @return bool
  33. */
  34. abstract public function del($key);
  35. /**
  36. * Flush all existing items
  37. *
  38. * @return bool
  39. */
  40. abstract public function flush();
  41. /**
  42. * Retrieve item from the cache
  43. *
  44. * @param mixed $key
  45. * @return mixed
  46. */
  47. abstract public function get($key);
  48. /**
  49. * Increment item's value
  50. *
  51. * @param string $key
  52. * @param int $increment
  53. * @return bool
  54. */
  55. abstract public function increment($key, $increment = 1);
  56. /**
  57. * Replace value of the existing item
  58. *
  59. * @param string $key
  60. * @param mixed $value
  61. * @param int $expire
  62. * @return bool
  63. */
  64. abstract public function replace($key, $value, $expire = 0);
  65. /**
  66. * Store data in the cache
  67. *
  68. * @param string $key
  69. * @param mixed $value
  70. * @param int $expire
  71. * @return bool
  72. */
  73. abstract public function set($key, $value, $expire = 0);
  74. }