1111
1212namespace Cache \Encryption ;
1313
14+ use Cache \Adapter \Common \PhpCacheItem ;
1415use Cache \Adapter \Common \PhpCachePool ;
1516use Cache \TagInterop \TaggableCacheItemInterface ;
1617use Cache \Taggable \TaggablePSR6PoolAdapter ;
2526 *
2627 * @author Daniel Bannert <[email protected] > 2728 */
28- class EncryptedCachePool implements TaggableCacheItemPoolInterface
29+ class EncryptedCachePool implements PhpCachePool
2930{
3031 /**
31- * @type TaggableCacheItemInterface
32+ * @type PhpCachePool
3233 */
3334 private $ cachePool ;
3435
@@ -38,12 +39,12 @@ class EncryptedCachePool implements TaggableCacheItemPoolInterface
3839 private $ key ;
3940
4041 /**
41- * @param CacheItemPoolInterface $cachePool
42- * @param Key $key
42+ * @param PhpCachePool $cachePool
43+ * @param Key $key
4344 */
44- public function __construct (CacheItemPoolInterface $ cachePool , Key $ key )
45+ public function __construct (PhpCachePool $ cachePool , Key $ key )
4546 {
46- $ this ->cachePool = TaggablePSR6PoolAdapter:: makeTaggable ( $ cachePool) ;
47+ $ this ->cachePool = $ cachePool ;
4748 $ this ->key = $ key ;
4849 }
4950
@@ -66,7 +67,7 @@ public function getItem($key)
6667 */
6768 public function getItems (array $ keys = [])
6869 {
69- return array_map (function (CacheItemInterface $ inner ) {
70+ return array_map (function (PhpCacheItem $ inner ) {
7071 if (!($ inner instanceof EncryptedItemDecorator)) {
7172 return new EncryptedItemDecorator ($ inner , $ this ->key );
7273 }
@@ -112,6 +113,10 @@ public function deleteItems(array $keys)
112113 */
113114 public function save (CacheItemInterface $ item )
114115 {
116+ if (!$ item instanceof PhpCacheItem) {
117+ throw new InvalidArgumentException ('Cache items are not transferable between pools. Item MUST implement PhpCacheItem. ' );
118+ }
119+
115120 if (!($ item instanceof EncryptedItemDecorator)) {
116121 $ item = new EncryptedItemDecorator ($ item , $ this ->key );
117122 }
@@ -124,6 +129,10 @@ public function save(CacheItemInterface $item)
124129 */
125130 public function saveDeferred (CacheItemInterface $ item )
126131 {
132+ if (!$ item instanceof PhpCacheItem) {
133+ throw new InvalidArgumentException ('Cache items are not transferable between pools. Item MUST implement PhpCacheItem. ' );
134+ }
135+
127136 if (!($ item instanceof EncryptedItemDecorator)) {
128137 $ item = new EncryptedItemDecorator ($ item , $ this ->key );
129138 }
0 commit comments