Skip to content

Commit 770248b

Browse files
committed
Merge pull request #14 from Nyholm/hierarchy
Hierarchy support
2 parents 5b7d182 + f7dc2ca commit 770248b

9 files changed

Lines changed: 27 additions & 23 deletions

.travis.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
language: php
22
php:
3-
- "7.0"
4-
- "5.6"
5-
- "5.5"
6-
- "5.4"
3+
- 7.0
4+
- 5.6
5+
- 5.5
6+
- 5.4
7+
- hhvm
8+
79

810
matrix:
911
fast_finish: true
1012

1113
sudo: false
1214

1315
before_install:
14-
- phpenv config-rm xdebug.ini
16+
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' ]]; then phpenv config-rm xdebug.ini; fi;
1517
- pip install --user codecov
1618

1719
before_script:

src/TaggableItemInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of php-cache\taggable-cache package.
55
*
6-
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>
6+
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com>
77
*
88
* This source file is subject to the MIT license that is bundled
99
* with this source code in the file LICENSE.

src/TaggableItemTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of php-cache\taggable-cache package.
55
*
6-
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>
6+
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com>
77
*
88
* This source file is subject to the MIT license that is bundled
99
* with this source code in the file LICENSE.
@@ -38,10 +38,10 @@ public function getTaggedKey()
3838
*/
3939
protected function getKeyFromTaggedKey($taggedKey)
4040
{
41-
if (false === $pos = strrpos($taggedKey, ':')) {
41+
if (false === $pos = strpos($taggedKey, ':')) {
4242
return $taggedKey;
4343
}
4444

45-
return substr($taggedKey, $pos + 1);
45+
return substr($taggedKey, 0, $pos);
4646
}
4747
}

src/TaggablePoolInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of php-cache\taggable-cache package.
55
*
6-
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>
6+
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com>
77
*
88
* This source file is subject to the MIT license that is bundled
99
* with this source code in the file LICENSE.
@@ -19,6 +19,8 @@
1919
*/
2020
interface TaggablePoolInterface
2121
{
22+
const TAG_SEPARATOR = ':';
23+
2224
public function getItem($key, array $tags = []);
2325

2426
public function getItems(array $keys = [], array $tags = []);

src/TaggablePoolTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of php-cache\taggable-cache package.
55
*
6-
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>
6+
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com>
77
*
88
* This source file is subject to the MIT license that is bundled
99
* with this source code in the file LICENSE.
@@ -107,7 +107,7 @@ protected function generateCacheKey($key, array $tags)
107107
}
108108
$tagsNamespace = sha1(implode('|', $tagIds));
109109

110-
return $tagsNamespace.':'.$key;
110+
return $key.TaggablePoolInterface::TAG_SEPARATOR.$tagsNamespace;
111111
}
112112

113113
/**
@@ -138,7 +138,7 @@ private function getTagId($name)
138138
*/
139139
private function getTagKey($name)
140140
{
141-
return 'tag:'.$name;
141+
return $name.TaggablePoolInterface::TAG_SEPARATOR.'tag';
142142
}
143143

144144
/**

tests/Helper/CacheItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of php-cache\taggable-cache package.
55
*
6-
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>
6+
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com>
77
*
88
* This source file is subject to the MIT license that is bundled
99
* with this source code in the file LICENSE.

tests/Helper/CachePool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of php-cache\taggable-cache package.
55
*
6-
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>
6+
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com>
77
*
88
* This source file is subject to the MIT license that is bundled
99
* with this source code in the file LICENSE.

tests/TaggableItemTraitTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of php-cache\taggable-cache package.
55
*
6-
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>
6+
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com>
77
*
88
* This source file is subject to the MIT license that is bundled
99
* with this source code in the file LICENSE.
@@ -20,10 +20,10 @@ public function testGetKey()
2020
$item = new CacheItem('key');
2121
$this->assertEquals('key', $item->getKey());
2222

23-
$item = new CacheItem('foo:key');
23+
$item = new CacheItem('key:foo');
2424
$this->assertEquals('key', $item->getKey());
2525

26-
$item = new CacheItem('foo:bar:key');
26+
$item = new CacheItem('key:foo:bar');
2727
$this->assertEquals('key', $item->getKey());
2828
}
2929

@@ -32,10 +32,10 @@ public function testGetTaggedKey()
3232
$item = new CacheItem('key');
3333
$this->assertEquals('key', $item->getTaggedKey());
3434

35-
$item = new CacheItem('foo:key');
36-
$this->assertEquals('foo:key', $item->getTaggedKey());
35+
$item = new CacheItem('key:foo');
36+
$this->assertEquals('key:foo', $item->getTaggedKey());
3737

38-
$item = new CacheItem('foo:bar:key');
39-
$this->assertEquals('foo:bar:key', $item->getTaggedKey());
38+
$item = new CacheItem('key:foo:bar');
39+
$this->assertEquals('key:foo:bar', $item->getTaggedKey());
4040
}
4141
}

tests/TaggablePoolTraitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of php-cache\taggable-cache package.
55
*
6-
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>
6+
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com>
77
*
88
* This source file is subject to the MIT license that is bundled
99
* with this source code in the file LICENSE.

0 commit comments

Comments
 (0)