Repository.php 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. namespace Illuminate\Contracts\Cache;
  3. use Closure;
  4. use Psr\SimpleCache\CacheInterface;
  5. interface Repository extends CacheInterface
  6. {
  7. /**
  8. * Determine if an item exists in the cache.
  9. *
  10. * @param string $key
  11. * @return bool
  12. */
  13. public function has($key);
  14. /**
  15. * Retrieve an item from the cache by key.
  16. *
  17. * @param string $key
  18. * @param mixed $default
  19. * @return mixed
  20. */
  21. public function get($key, $default = null);
  22. /**
  23. * Retrieve an item from the cache and delete it.
  24. *
  25. * @param string $key
  26. * @param mixed $default
  27. * @return mixed
  28. */
  29. public function pull($key, $default = null);
  30. /**
  31. * Store an item in the cache.
  32. *
  33. * @param string $key
  34. * @param mixed $value
  35. * @param \DateTimeInterface|\DateInterval|float|int $minutes
  36. * @return void
  37. */
  38. public function put($key, $value, $minutes);
  39. /**
  40. * Store an item in the cache if the key does not exist.
  41. *
  42. * @param string $key
  43. * @param mixed $value
  44. * @param \DateTimeInterface|\DateInterval|float|int $minutes
  45. * @return bool
  46. */
  47. public function add($key, $value, $minutes);
  48. /**
  49. * Increment the value of an item in the cache.
  50. *
  51. * @param string $key
  52. * @param mixed $value
  53. * @return int|bool
  54. */
  55. public function increment($key, $value = 1);
  56. /**
  57. * Decrement the value of an item in the cache.
  58. *
  59. * @param string $key
  60. * @param mixed $value
  61. * @return int|bool
  62. */
  63. public function decrement($key, $value = 1);
  64. /**
  65. * Store an item in the cache indefinitely.
  66. *
  67. * @param string $key
  68. * @param mixed $value
  69. * @return void
  70. */
  71. public function forever($key, $value);
  72. /**
  73. * Get an item from the cache, or store the default value.
  74. *
  75. * @param string $key
  76. * @param \DateTimeInterface|\DateInterval|float|int $minutes
  77. * @param \Closure $callback
  78. * @return mixed
  79. */
  80. public function remember($key, $minutes, Closure $callback);
  81. /**
  82. * Get an item from the cache, or store the default value forever.
  83. *
  84. * @param string $key
  85. * @param \Closure $callback
  86. * @return mixed
  87. */
  88. public function sear($key, Closure $callback);
  89. /**
  90. * Get an item from the cache, or store the default value forever.
  91. *
  92. * @param string $key
  93. * @param \Closure $callback
  94. * @return mixed
  95. */
  96. public function rememberForever($key, Closure $callback);
  97. /**
  98. * Remove an item from the cache.
  99. *
  100. * @param string $key
  101. * @return bool
  102. */
  103. public function forget($key);
  104. /**
  105. * Get the cache store implementation.
  106. *
  107. * @return \Illuminate\Contracts\Cache\Store
  108. */
  109. public function getStore();
  110. }