Repository.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. * @template TCacheValue
  11. *
  12. * @param array|string $key
  13. * @param TCacheValue|(\Closure(): TCacheValue) $default
  14. * @return (TCacheValue is null ? mixed : TCacheValue)
  15. */
  16. public function pull($key, $default = null);
  17. /**
  18. * Store an item in the cache.
  19. *
  20. * @param string $key
  21. * @param mixed $value
  22. * @param \DateTimeInterface|\DateInterval|int|null $ttl
  23. * @return bool
  24. */
  25. public function put($key, $value, $ttl = null);
  26. /**
  27. * Store an item in the cache if the key does not exist.
  28. *
  29. * @param string $key
  30. * @param mixed $value
  31. * @param \DateTimeInterface|\DateInterval|int|null $ttl
  32. * @return bool
  33. */
  34. public function add($key, $value, $ttl = null);
  35. /**
  36. * Increment the value of an item in the cache.
  37. *
  38. * @param string $key
  39. * @param mixed $value
  40. * @return int|bool
  41. */
  42. public function increment($key, $value = 1);
  43. /**
  44. * Decrement the value of an item in the cache.
  45. *
  46. * @param string $key
  47. * @param mixed $value
  48. * @return int|bool
  49. */
  50. public function decrement($key, $value = 1);
  51. /**
  52. * Store an item in the cache indefinitely.
  53. *
  54. * @param string $key
  55. * @param mixed $value
  56. * @return bool
  57. */
  58. public function forever($key, $value);
  59. /**
  60. * Get an item from the cache, or execute the given Closure and store the result.
  61. *
  62. * @template TCacheValue
  63. *
  64. * @param string $key
  65. * @param \DateTimeInterface|\DateInterval|\Closure|int|null $ttl
  66. * @param \Closure(): TCacheValue $callback
  67. * @return TCacheValue
  68. */
  69. public function remember($key, $ttl, Closure $callback);
  70. /**
  71. * Get an item from the cache, or execute the given Closure and store the result forever.
  72. *
  73. * @template TCacheValue
  74. *
  75. * @param string $key
  76. * @param \Closure(): TCacheValue $callback
  77. * @return TCacheValue
  78. */
  79. public function sear($key, Closure $callback);
  80. /**
  81. * Get an item from the cache, or execute the given Closure and store the result forever.
  82. *
  83. * @template TCacheValue
  84. *
  85. * @param string $key
  86. * @param \Closure(): TCacheValue $callback
  87. * @return TCacheValue
  88. */
  89. public function rememberForever($key, Closure $callback);
  90. /**
  91. * Remove an item from the cache.
  92. *
  93. * @param string $key
  94. * @return bool
  95. */
  96. public function forget($key);
  97. /**
  98. * Get the cache store implementation.
  99. *
  100. * @return \Illuminate\Contracts\Cache\Store
  101. */
  102. public function getStore();
  103. }