feature #27398 [Cache] Remove TaggableCacheInterface, alias cache.app.taggable to CacheInterface (nicolas-grekas)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Cache] Remove TaggableCacheInterface, alias cache.app.taggable to CacheInterface

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Actually, there is no downside in using a taggable cache pool as a backend for CacheInterface.
This means we can simplify things and remove the TaggableCacheInterface and keep only CacheInterface (master-only).

Commits
-------

c250fbdda0 [Cache] Remove TaggableCacheInterface, alias cache.app.taggable to CacheInterface
This commit is contained in:
Fabien Potencier 2018-05-31 16:26:45 +02:00
commit c81f88f38b
6 changed files with 7 additions and 47 deletions

View File

@ -126,9 +126,8 @@
<service id="cache.global_clearer" parent="cache.default_clearer" public="true" />
<service id="cache.app_clearer" alias="cache.default_clearer" public="true" />
<service id="Psr\Cache\CacheItemPoolInterface" alias="cache.app" />
<service id="Symfony\Component\Cache\TaggableCacheInterface" alias="cache.app.taggable" />
<service id="Psr\SimpleCache\CacheInterface" alias="cache.app.simple" />
<service id="Symfony\Component\Cache\Adapter\AdapterInterface" alias="cache.app" />
<service id="Symfony\Component\Cache\CacheInterface" alias="cache.app" />
<service id="Symfony\Component\Cache\CacheInterface" alias="cache.app.taggable" />
</services>
</container>

View File

@ -13,17 +13,17 @@ namespace Symfony\Component\Cache\Adapter;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\InvalidArgumentException;
use Symfony\Component\Cache\CacheInterface;
use Symfony\Component\Cache\CacheItem;
use Symfony\Component\Cache\PruneableInterface;
use Symfony\Component\Cache\ResettableInterface;
use Symfony\Component\Cache\TaggableCacheInterface;
use Symfony\Component\Cache\Traits\GetTrait;
use Symfony\Component\Cache\Traits\ProxyTrait;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class TagAwareAdapter implements TagAwareAdapterInterface, TaggableCacheInterface, PruneableInterface, ResettableInterface
class TagAwareAdapter implements CacheInterface, TagAwareAdapterInterface, PruneableInterface, ResettableInterface
{
const TAGS_PREFIX = "\0tags\0";

View File

@ -11,12 +11,12 @@
namespace Symfony\Component\Cache\Adapter;
use Symfony\Component\Cache\TaggableCacheInterface;
use Symfony\Component\Cache\CacheInterface;
/**
* @author Robin Chalas <robin.chalas@gmail.com>
*/
class TraceableTagAwareAdapter extends TraceableAdapter implements TaggableCacheInterface, TagAwareAdapterInterface
class TraceableTagAwareAdapter extends TraceableAdapter implements CacheInterface, TagAwareAdapterInterface
{
public function __construct(TagAwareAdapterInterface $pool)
{

View File

@ -4,7 +4,7 @@ CHANGELOG
4.2.0
-----
* added `CacheInterface` and `TaggableCacheInterface`
* added `CacheInterface`, which should become the preferred way to use a cache
* throw `LogicException` when `CacheItem::tag()` is called on an item coming from a non tag-aware pool
3.4.0

View File

@ -11,8 +11,6 @@
namespace Symfony\Component\Cache;
use Psr\Cache\CacheItemInterface;
/**
* Gets and stores items from a cache.
*
@ -22,14 +20,12 @@ use Psr\Cache\CacheItemInterface;
* - the corresponding PSR-6 CacheItemInterface object,
* allowing time-based expiration control.
*
* If you need tag-based invalidation, use TaggableCacheInterface instead.
*
* @author Nicolas Grekas <p@tchwork.com>
*/
interface CacheInterface
{
/**
* @param callable(CacheItemInterface):mixed $callback Should return the computed value for the given key/item
* @param callable(CacheItem):mixed $callback Should return the computed value for the given key/item
*
* @return mixed The value corresponding to the provided key
*/

View File

@ -1,35 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Cache;
/**
* Gets and stores items from a tag-aware cache.
*
* On cache misses, a callback is called that should return the missing value.
* It is given two arguments:
* - the missing cache key
* - the corresponding Symfony CacheItem object,
* allowing time-based *and* tags-based expiration control
*
* If you don't need tags-based invalidation, use CacheInterface instead.
*
* @author Nicolas Grekas <p@tchwork.com>
*/
interface TaggableCacheInterface extends CacheInterface
{
/**
* @param callable(CacheItem):mixed $callback Should return the computed value for the given key/item
*
* @return mixed The value corresponding to the provided key
*/
public function get(string $key, callable $callback);
}