@@ -49,13 +49,9 @@ public function __construct(PhpCachePool $cachePool, Key $key)
4949 */
5050 public function getItem ($ key )
5151 {
52- $ item = $ this ->cachePool -> getItem ( $ key );
52+ $ items = $ this ->getItems ([ $ key] );
5353
54- if (!($ item instanceof EncryptedItemDecorator)) {
55- return new EncryptedItemDecorator ($ item , $ this ->key );
56- }
57-
58- return $ item ;
54+ return reset ($ items );
5955 }
6056
6157 /**
@@ -109,31 +105,23 @@ public function deleteItems(array $keys)
109105 */
110106 public function save (CacheItemInterface $ item )
111107 {
112- if (!$ item instanceof PhpCacheItem) {
113- throw new InvalidArgumentException ('Cache items are not transferable between pools. Item MUST implement PhpCacheItem. ' );
114- }
115-
116- if (!($ item instanceof EncryptedItemDecorator)) {
117- $ item = new EncryptedItemDecorator ($ item , $ this ->key );
108+ if (!$ item instanceof EncryptedItemDecorator) {
109+ throw new InvalidArgumentException ('Cache items are not transferable between pools. Item MUST implement EncryptedItemDecorator. ' );
118110 }
119111
120- return $ this ->cachePool ->save ($ item );
112+ return $ this ->cachePool ->save ($ item-> getCacheItem () );
121113 }
122114
123115 /**
124116 * {@inheritdoc}
125117 */
126118 public function saveDeferred (CacheItemInterface $ item )
127119 {
128- if (!$ item instanceof PhpCacheItem) {
129- throw new InvalidArgumentException ('Cache items are not transferable between pools. Item MUST implement PhpCacheItem. ' );
130- }
131-
132- if (!($ item instanceof EncryptedItemDecorator)) {
133- $ item = new EncryptedItemDecorator ($ item , $ this ->key );
120+ if (!$ item instanceof EncryptedItemDecorator) {
121+ throw new InvalidArgumentException ('Cache items are not transferable between pools. Item MUST implement EncryptedItemDecorator. ' );
134122 }
135123
136- return $ this ->cachePool ->saveDeferred ($ item );
124+ return $ this ->cachePool ->saveDeferred ($ item-> getCacheItem () );
137125 }
138126
139127 /**
0 commit comments