|
| 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\CacheException; |
| 15 | +use Psr\Cache\CacheItemInterface; |
| 16 | +use Psr\Cache\InvalidArgumentException; |
| 17 | + |
| 18 | +/** |
| 19 | + * @author Nicolas Grekas <p@tchwork.com> |
| 20 | + */ |
| 21 | +interface ItemInterface extends CacheItemInterface |
| 22 | +{ |
| 23 | + /** |
| 24 | + * References the Unix timestamp stating when the item will expire. |
| 25 | + */ |
| 26 | + const METADATA_EXPIRY = 'expiry'; |
| 27 | + |
| 28 | + /** |
| 29 | + * References the time the item took to be created, in milliseconds. |
| 30 | + */ |
| 31 | + const METADATA_CTIME = 'ctime'; |
| 32 | + |
| 33 | + /** |
| 34 | + * References the list of tags that were assigned to the item, as string[]. |
| 35 | + */ |
| 36 | + const METADATA_TAGS = 'tags'; |
| 37 | + |
| 38 | + /** |
| 39 | + * Adds a tag to a cache item. |
| 40 | + * |
| 41 | + * Tags are strings that follow the same validation rules as keys. |
| 42 | + * |
| 43 | + * @param string|string[] $tags A tag or array of tags |
| 44 | + * |
| 45 | + * @return $this |
| 46 | + * |
| 47 | + * @throws InvalidArgumentException When $tag is not valid |
| 48 | + * @throws CacheException When the item comes from a pool that is not tag-aware |
| 49 | + */ |
| 50 | + public function tag($tags): self; |
| 51 | + |
| 52 | + /** |
| 53 | + * Returns a list of metadata info that were saved alongside with the cached value. |
| 54 | + * |
| 55 | + * See ItemInterface::METADATA_* consts for keys potentially found in the returned array. |
| 56 | + */ |
| 57 | + public function getMetadata(): array; |
| 58 | +} |
0 commit comments