├── .github └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── Changelog.md ├── LICENSE ├── README.md ├── TaggableCacheItemInterface.php ├── TaggableCacheItemPoolInterface.php └── composer.json /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | This is a READ ONLY repository. 2 | 3 | Please make your pull request to https://github.com/php-cache/cache 4 | 5 | Thank you for contributing. 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | composer.lock 2 | vendor 3 | -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. 4 | 5 | ## 1.1.0 6 | 7 | * Support PHP 8.1 8 | * Support for psr/cache v2 9 | 10 | ## 1.0.1 11 | 12 | * Support PHP 8 13 | 14 | ## 1.0.0 15 | 16 | * First release 17 | 18 | 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Aaron Scherer, Tobias Nyholm 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tag support for PSR-6 Cache 2 | [![Gitter](https://badges.gitter.im/php-cache/cache.svg)](https://gitter.im/php-cache/cache?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 3 | [![Latest Stable Version](https://poser.pugx.org/cache/tag-interop/v/stable)](https://packagist.org/packages/cache/tag-interop) 4 | [![Total Downloads](https://poser.pugx.org/cache/tag-interop/downloads)](https://packagist.org/packages/cache/tag-interop) 5 | [![Monthly Downloads](https://poser.pugx.org/cache/tag-interop/d/monthly.png)](https://packagist.org/packages/cache/tag-interop) 6 | [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) 7 | 8 | This repository holds two interfaces for tagging. These interfaces will make their 9 | way into PHP Fig. Representatives from Symfony, PHP-cache and Drupal has worked 10 | together to agree on these interfaces. 11 | 12 | ### Install 13 | 14 | ```bash 15 | composer require cache/tag-interop 16 | ``` 17 | 18 | ### Use 19 | 20 | Read the [documentation on usage](http://www.php-cache.com/). 21 | 22 | ### Contribute 23 | 24 | Contributions are very welcome! Send a pull request to the [main repository](https://github.com/php-cache/cache) or 25 | report any issues you find on the [issue tracker](http://issues.php-cache.com). 26 | -------------------------------------------------------------------------------- /TaggableCacheItemInterface.php: -------------------------------------------------------------------------------- 1 | , Tobias Nyholm 7 | * 8 | * This source file is subject to the MIT license that is bundled 9 | * with this source code in the file LICENSE. 10 | */ 11 | 12 | namespace Cache\TagInterop; 13 | 14 | use Psr\Cache\CacheItemInterface; 15 | use Psr\Cache\InvalidArgumentException; 16 | 17 | /** 18 | * An item that supports tags. This interface is a soon-to-be-PSR. 19 | * 20 | * @author Tobias Nyholm 21 | * @author Nicolas Grekas 22 | */ 23 | interface TaggableCacheItemInterface extends CacheItemInterface 24 | { 25 | /** 26 | * Get all existing tags. These are the tags the item has when the item is 27 | * returned from the pool. 28 | * 29 | * @return array 30 | */ 31 | public function getPreviousTags(); 32 | 33 | /** 34 | * Overwrite all tags with a new set of tags. 35 | * 36 | * @param string[] $tags An array of tags 37 | * 38 | * @throws InvalidArgumentException When a tag is not valid. 39 | * 40 | * @return TaggableCacheItemInterface 41 | */ 42 | public function setTags(array $tags); 43 | } 44 | -------------------------------------------------------------------------------- /TaggableCacheItemPoolInterface.php: -------------------------------------------------------------------------------- 1 | , Tobias Nyholm 7 | * 8 | * This source file is subject to the MIT license that is bundled 9 | * with this source code in the file LICENSE. 10 | */ 11 | 12 | namespace Cache\TagInterop; 13 | 14 | use Psr\Cache\CacheItemPoolInterface; 15 | use Psr\Cache\InvalidArgumentException; 16 | 17 | /** 18 | * Interface for invalidating cached items using tags. This interface is a soon-to-be-PSR. 19 | * 20 | * @author Tobias Nyholm 21 | * @author Nicolas Grekas 22 | */ 23 | interface TaggableCacheItemPoolInterface extends CacheItemPoolInterface 24 | { 25 | /** 26 | * Invalidates cached items using a tag. 27 | * 28 | * @param string $tag The tag to invalidate 29 | * 30 | * @throws InvalidArgumentException When $tags is not valid 31 | * 32 | * @return bool True on success 33 | */ 34 | public function invalidateTag($tag); 35 | 36 | /** 37 | * Invalidates cached items using tags. 38 | * 39 | * @param string[] $tags An array of tags to invalidate 40 | * 41 | * @throws InvalidArgumentException When $tags is not valid 42 | * 43 | * @return bool True on success 44 | */ 45 | public function invalidateTags(array $tags); 46 | 47 | /** 48 | * {@inheritdoc} 49 | * 50 | * @return TaggableCacheItemInterface 51 | */ 52 | public function getItem($key); 53 | 54 | /** 55 | * {@inheritdoc} 56 | * 57 | * @return array|\Traversable|TaggableCacheItemInterface[] 58 | */ 59 | public function getItems(array $keys = []); 60 | } 61 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cache/tag-interop", 3 | "description": "Framework interoperable interfaces for tags", 4 | "license": "MIT", 5 | "type": "library", 6 | "keywords": [ 7 | "cache", 8 | "psr6", 9 | "tag", 10 | "psr" 11 | ], 12 | "authors": [ 13 | { 14 | "name": "Tobias Nyholm", 15 | "email": "tobias.nyholm@gmail.com", 16 | "homepage": "https://github.com/nyholm" 17 | }, 18 | { 19 | "name": "Nicolas Grekas ", 20 | "email": "p@tchwork.com", 21 | "homepage": "https://github.com/nicolas-grekas" 22 | } 23 | ], 24 | "homepage": "https://www.php-cache.com/en/latest/", 25 | "require": { 26 | "php": "^5.5 || ^7.0 || ^8.0", 27 | "psr/cache": "^1.0 || ^2.0" 28 | }, 29 | "autoload": { 30 | "psr-4": { 31 | "Cache\\TagInterop\\": "" 32 | } 33 | }, 34 | "extra": { 35 | "branch-alias": { 36 | "dev-master": "1.1-dev" 37 | } 38 | } 39 | } 40 | --------------------------------------------------------------------------------