Skip to content

Commit e8131ff

Browse files
committed
Making cache tags more efficient by rewriting the API.
Related to php-cache/issues#21
1 parent 5fb4242 commit e8131ff

File tree

4 files changed

+51
-10
lines changed

4 files changed

+51
-10
lines changed

Tests/IntegrationHierarchyTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of php-cache organization.
5+
*
6+
* (c) 2015-2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
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\Adapter\Void\Tests;
13+
14+
use Cache\Adapter\Void\VoidCachePool;
15+
use Cache\IntegrationTests\HierarchicalCachePoolTest;
16+
17+
class IntegrationHierarchyTest extends HierarchicalCachePoolTest
18+
{
19+
protected $skippedTests = [
20+
'testBasicUsage' => 'Void adapter does not save,',
21+
'testChain' => 'Void adapter does not save,',
22+
'testRemoval' => 'Void adapter does not save,',
23+
'testRemovalWhenDeferred' => 'Void adapter does not save,',
24+
];
25+
26+
public function createCachePool()
27+
{
28+
return new VoidCachePool();
29+
}
30+
}

Tests/IntegrationTagTest.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@
1717
class IntegrationTagTest extends TaggableCachePoolTest
1818
{
1919
protected $skippedTests = [
20-
'testBasicUsage' => 'Void adapter does not save,',
21-
'testGetItems' => 'Void adapter does not save,',
22-
'testHasItem' => 'Void adapter does not save,',
23-
'testDeleteItem' => 'Void adapter does not save,',
24-
'testKeysWithDeferred' => 'Void adapter does not save,',
25-
'testSaveDeferred' => 'Void adapter does not save,',
20+
'testBasicUsage' => 'Void adapter does not save,',
21+
'testGetItems' => 'Void adapter does not save,',
22+
'testHasItem' => 'Void adapter does not save,',
23+
'testDeleteItem' => 'Void adapter does not save,',
24+
'testKeysWithDeferred' => 'Void adapter does not save,',
25+
'testSaveDeferred' => 'Void adapter does not save,',
26+
'testMultipleTags' => 'Void adapter does not save,',
27+
'testRemoveTagWhenItemIsRemoved' => 'Void adapter does not save,',
28+
'testClear' => 'Void adapter does not save,',
29+
'testClearTag' => 'Void adapter does not save,',
2630
];
2731

2832
public function createCachePool()

VoidCachePool.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@
1212
namespace Cache\Adapter\Void;
1313

1414
use Cache\Adapter\Common\AbstractCachePool;
15+
use Cache\Hierarchy\HierarchicalPoolInterface;
16+
use Cache\Taggable\TaggablePoolInterface;
1517
use Psr\Cache\CacheItemInterface;
1618

1719
/**
1820
* @author Tobias Nyholm <[email protected]>
1921
*/
20-
class VoidCachePool extends AbstractCachePool
22+
class VoidCachePool extends AbstractCachePool implements TaggablePoolInterface, HierarchicalPoolInterface
2123
{
2224
protected function fetchObjectFromCache($key)
2325
{
24-
return [false, null];
26+
return [false, null, []];
2527
}
2628

2729
protected function clearAllObjectsFromCache()
@@ -34,7 +36,12 @@ protected function clearOneObjectFromCache($key)
3436
return true;
3537
}
3638

37-
protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
39+
protected function storeItemInCache(CacheItemInterface $item, $ttl)
40+
{
41+
return true;
42+
}
43+
44+
public function clearTags(array $tags)
3845
{
3946
return true;
4047
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"require-dev": {
3232
"phpunit/phpunit": "^4.0|^5.1",
33-
"cache/integration-tests": "0.7.0"
33+
"cache/integration-tests": "0.9.0"
3434
},
3535
"provide": {
3636
"psr/cache-implementation": "^1.0"

0 commit comments

Comments
 (0)