Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"router",
"session"
],
"homepage": "https://github.com/php-cache/cache-bundle",
"homepage": "http://www.php-cache.com/en/latest/",
"license": "MIT",
"authors": [
{
Expand All @@ -24,15 +24,15 @@
}
],
"require": {
"php": "^5.5|^7",
"php": "^5.5|^7.0",
"symfony/framework-bundle": "^2.7|^3.0",
"cache/taggable-cache": "^0.3",
"cache/taggable-cache": "^0.4",
"cache/session-handler": "^0.1"
},
"require-dev": {
"phpunit/phpunit": "^5.1|^4.0",
"cache/psr-6-doctrine-bridge": "^2.0",
"cache/array-adapter": "@stable"
"cache/array-adapter": "^0.4"
},
"suggest": {
"cache/adapter-bundle": "To register PSR-6 compliant cache implementations as services.",
Expand Down
27 changes: 21 additions & 6 deletions src/Cache/FixedTaggingCachePool.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Cache\CacheBundle\Cache;

use Cache\Taggable\TaggableItemInterface;
use Cache\Taggable\TaggablePoolInterface;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
Expand Down Expand Up @@ -48,54 +49,56 @@ public function __construct(TaggablePoolInterface $cache, array $tags)
*/
public function getItem($key)
{
return $this->cache->getItem($key, $this->tags);
return $this->cache->getItem($key);
}

/**
* {@inheritdoc}
*/
public function getItems(array $keys = [])
{
return $this->cache->getItems($keys, $this->tags);
return $this->cache->getItems($keys);
}

/**
* {@inheritdoc}
*/
public function hasItem($key)
{
return $this->cache->hasItem($key, $this->tags);
return $this->cache->hasItem($key);
}

/**
* {@inheritdoc}
*/
public function clear()
{
return $this->cache->clear($this->tags);
return $this->cache->clear();
}

/**
* {@inheritdoc}
*/
public function deleteItem($key)
{
return $this->cache->deleteItem($key, $this->tags);
return $this->cache->deleteItem($key);
}

/**
* {@inheritdoc}
*/
public function deleteItems(array $keys)
{
return $this->cache->deleteItems($keys, $this->tags);
return $this->cache->deleteItems($keys);
}

/**
* {@inheritdoc}
*/
public function save(CacheItemInterface $item)
{
$this->addTags($item);

return $this->cache->save($item);
}

Expand All @@ -104,9 +107,21 @@ public function save(CacheItemInterface $item)
*/
public function saveDeferred(CacheItemInterface $item)
{
$this->addTags($item);

return $this->cache->saveDeferred($item);
}

/**
* @param TaggableItemInterface $item
*/
private function addTags(TaggableItemInterface $item)
{
foreach ($this->tags as $tag) {
$item->addTag($tag);
}
}

/**
* {@inheritdoc}
*/
Expand Down
38 changes: 23 additions & 15 deletions src/Cache/RecordingCachePool.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ private function timeCall($name, array $arguments = null)
return $object;
}

public function getItem($key, array $tags = [])
public function getItem($key)
{
$call = $this->timeCall(__FUNCTION__, [$key, $tags]);
$result = $call->result;
$call->isHit = $result->isHit();
$call = $this->timeCall(__FUNCTION__, [$key]);
$result = $call->result;
$call->isHit = $result->isHit();

// Display the result in a good way depending on the data type
if ($call->isHit) {
Expand All @@ -85,17 +85,17 @@ public function getItem($key, array $tags = [])
return $result;
}

public function hasItem($key, array $tags = [])
public function hasItem($key)
{
$call = $this->timeCall(__FUNCTION__, [$key, $tags]);
$call = $this->timeCall(__FUNCTION__, [$key]);
$this->addCall($call);

return $call->result;
}

public function deleteItem($key, array $tags = [])
public function deleteItem($key)
{
$call = $this->timeCall(__FUNCTION__, [$key, $tags]);
$call = $this->timeCall(__FUNCTION__, [$key]);
$this->addCall($call);

return $call->result;
Expand Down Expand Up @@ -125,35 +125,43 @@ public function saveDeferred(CacheItemInterface $item)
return $call->result;
}

public function getItems(array $keys = [], array $tags = [])
public function getItems(array $keys = [])
{
$call = $this->timeCall(__FUNCTION__, [$keys, $tags]);
$call = $this->timeCall(__FUNCTION__, [$keys]);
$result = $call->result;
$call->result = sprintf('<DATA:%s>', gettype($result));
$this->addCall($call);

return $result;
}

public function clear(array $tags = [])
public function clear()
{
$call = $this->timeCall(__FUNCTION__, []);
$this->addCall($call);

return $call->result;
}

public function clearTags(array $tags)
{
$call = $this->timeCall(__FUNCTION__, [$tags]);
$call = $this->timeCall(__FUNCTION__, [$tags]);
$this->addCall($call);

return $call->result;
}

public function deleteItems(array $keys, array $tags = [])
public function deleteItems(array $keys)
{
$call = $this->timeCall(__FUNCTION__, [$keys, $tags]);
$call = $this->timeCall(__FUNCTION__, [$keys]);
$this->addCall($call);

return $call->result;
}

public function commit()
{
$call = $this->timeCall(__FUNCTION__);
$call = $this->timeCall(__FUNCTION__);
$this->addCall($call);

return $call->result;
Expand Down
2 changes: 1 addition & 1 deletion src/Command/CacheFlushCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private function clearTypedCacheFromService($type, $serviceId)
/** @type \Psr\Cache\CacheItemPoolInterface $service */
$service = $this->getContainer()->get($serviceId);
if ($service instanceof TaggablePoolInterface) {
return $service->clear([$type]);
return $service->clearTags([$type]);
} else {
return $service->clear();
}
Expand Down
10 changes: 5 additions & 5 deletions src/Routing/CachingRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Cache\CacheBundle\Routing;

use Cache\Taggable\TaggablePoolInterface;
use Cache\Taggable\TaggableItemInterface;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouterInterface;
Expand Down Expand Up @@ -163,10 +163,10 @@ public function __call($method, $args)
*/
private function getCacheItemFromKey($key, $tag)
{
if ($this->cache instanceof TaggablePoolInterface) {
$item = $this->cache->getItem($key, ['router', $tag]);
} else {
$item = $this->cache->getItem($key);
$item = $this->cache->getItem($key);

if ($item instanceof TaggableItemInterface) {
$item->setTags(['router', $tag]);
}

return $item;
Expand Down
3 changes: 0 additions & 3 deletions tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
*/
class ContainerTest extends TestCase
{
/**
*
*/
public function testContainer()
{
//$container = $this->createContainer();
Expand Down
3 changes: 0 additions & 3 deletions tests/DependencyInjection/CacheExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
*/
class CacheExtensionTest extends TestCase
{
/**
*
*/
public function testRouterBuilder()
{
$container = $this->createContainerFromFile('router');
Expand Down