diff options
Diffstat (limited to 'vendor/symfony/cache-contracts/CacheInterface.php')
| -rw-r--r-- | vendor/symfony/cache-contracts/CacheInterface.php | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/vendor/symfony/cache-contracts/CacheInterface.php b/vendor/symfony/cache-contracts/CacheInterface.php new file mode 100644 index 0000000..3e4aaf6 --- /dev/null +++ b/vendor/symfony/cache-contracts/CacheInterface.php | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | * This file is part of the Symfony package. | ||
| 5 | * | ||
| 6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
| 7 | * | ||
| 8 | * For the full copyright and license information, please view the LICENSE | ||
| 9 | * file that was distributed with this source code. | ||
| 10 | */ | ||
| 11 | |||
| 12 | namespace Symfony\Contracts\Cache; | ||
| 13 | |||
| 14 | use Psr\Cache\CacheItemInterface; | ||
| 15 | use Psr\Cache\InvalidArgumentException; | ||
| 16 | |||
| 17 | /** | ||
| 18 | * Covers most simple to advanced caching needs. | ||
| 19 | * | ||
| 20 | * @author Nicolas Grekas <p@tchwork.com> | ||
| 21 | */ | ||
| 22 | interface CacheInterface | ||
| 23 | { | ||
| 24 | /** | ||
| 25 | * Fetches a value from the pool or computes it if not found. | ||
| 26 | * | ||
| 27 | * On cache misses, a callback is called that should return the missing value. | ||
| 28 | * This callback is given a PSR-6 CacheItemInterface instance corresponding to the | ||
| 29 | * requested key, that could be used e.g. for expiration control. It could also | ||
| 30 | * be an ItemInterface instance when its additional features are needed. | ||
| 31 | * | ||
| 32 | * @template T | ||
| 33 | * | ||
| 34 | * @param string $key The key of the item to retrieve from the cache | ||
| 35 | * @param (callable(CacheItemInterface,bool):T)|(callable(ItemInterface,bool):T)|CallbackInterface<T> $callback | ||
| 36 | * @param float|null $beta A float that, as it grows, controls the likeliness of triggering | ||
| 37 | * early expiration. 0 disables it, INF forces immediate expiration. | ||
| 38 | * The default (or providing null) is implementation dependent but should | ||
| 39 | * typically be 1.0, which should provide optimal stampede protection. | ||
| 40 | * See https://en.wikipedia.org/wiki/Cache_stampede#Probabilistic_early_expiration | ||
| 41 | * @param array &$metadata The metadata of the cached item {@see ItemInterface::getMetadata()} | ||
| 42 | * | ||
| 43 | * @return T | ||
| 44 | * | ||
| 45 | * @throws InvalidArgumentException When $key is not valid or when $beta is negative | ||
| 46 | */ | ||
| 47 | public function get(string $key, callable $callback, ?float $beta = null, ?array &$metadata = null): mixed; | ||
| 48 | |||
| 49 | /** | ||
| 50 | * Removes an item from the pool. | ||
| 51 | * | ||
| 52 | * @param string $key The key to delete | ||
| 53 | * | ||
| 54 | * @return bool True if the item was successfully removed, false if there was any error | ||
| 55 | * | ||
| 56 | * @throws InvalidArgumentException When $key is not valid | ||
| 57 | */ | ||
| 58 | public function delete(string $key): bool; | ||
| 59 | } | ||
