| 1 | <?php |
| 2 | |
| 3 | namespace Illuminate\Contracts\Cache; |
| 4 | |
| 5 | use Closure; |
| 6 | use Psr\SimpleCache\CacheInterface; |
| 7 | |
| 8 | interface Repository extends CacheInterface |
| 9 | { |
| 10 | /** |
| 11 | * Retrieve an item from the cache and delete it. |
| 12 | * |
| 13 | * @template TCacheValue |
| 14 | * |
| 15 | * @param array|string $key |
| 16 | * @param TCacheValue|(\Closure(): TCacheValue) $default |
| 17 | * @return (TCacheValue is null ? mixed : TCacheValue) |
| 18 | */ |
| 19 | public function pull($key, $default = null); |
| 20 | |
| 21 | /** |
| 22 | * Store an item in the cache. |
| 23 | * |
| 24 | * @param string $key |
| 25 | * @param mixed $value |
| 26 | * @param \DateTimeInterface|\DateInterval|int|null $ttl |
| 27 | * @return bool |
| 28 | */ |
| 29 | public function put($key, $value, $ttl = null); |
| 30 | |
| 31 | /** |
| 32 | * Store an item in the cache if the key does not exist. |
| 33 | * |
| 34 | * @param string $key |
| 35 | * @param mixed $value |
| 36 | * @param \DateTimeInterface|\DateInterval|int|null $ttl |
| 37 | * @return bool |
| 38 | */ |
| 39 | public function add($key, $value, $ttl = null); |
| 40 | |
| 41 | /** |
| 42 | * Increment 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 increment($key, $value = 1); |
| 49 | |
| 50 | /** |
| 51 | * Decrement the value of an item in the cache. |
| 52 | * |
| 53 | * @param string $key |
| 54 | * @param mixed $value |
| 55 | * @return int|bool |
| 56 | */ |
| 57 | public function decrement($key, $value = 1); |
| 58 | |
| 59 | /** |
| 60 | * Store an item in the cache indefinitely. |
| 61 | * |
| 62 | * @param string $key |
| 63 | * @param mixed $value |
| 64 | * @return bool |
| 65 | */ |
| 66 | public function forever($key, $value); |
| 67 | |
| 68 | /** |
| 69 | * Get an item from the cache, or execute the given Closure and store the result. |
| 70 | * |
| 71 | * @template TCacheValue |
| 72 | * |
| 73 | * @param string $key |
| 74 | * @param \DateTimeInterface|\DateInterval|\Closure|int|null $ttl |
| 75 | * @param \Closure(): TCacheValue $callback |
| 76 | * @return TCacheValue |
| 77 | */ |
| 78 | public function remember($key, $ttl, Closure $callback); |
| 79 | |
| 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 sear($key, Closure $callback); |
| 90 | |
| 91 | /** |
| 92 | * Get an item from the cache, or execute the given Closure and store the result forever. |
| 93 | * |
| 94 | * @template TCacheValue |
| 95 | * |
| 96 | * @param string $key |
| 97 | * @param \Closure(): TCacheValue $callback |
| 98 | * @return TCacheValue |
| 99 | */ |
| 100 | public function rememberForever($key, Closure $callback); |
| 101 | |
| 102 | /** |
| 103 | * Remove an item from the cache. |
| 104 | * |
| 105 | * @param string $key |
| 106 | * @return bool |
| 107 | */ |
| 108 | public function forget($key); |
| 109 | |
| 110 | /** |
| 111 | * Get the cache store implementation. |
| 112 | * |
| 113 | * @return \Illuminate\Contracts\Cache\Store |
| 114 | */ |
| 115 | public function getStore(); |
| 116 | } |