Repository.php 2.5 KB

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