1515namespace phpFastCache \Core ;
1616
1717use InvalidArgumentException ;
18+ use Psr \Cache \CacheItemInterface ;
1819
1920trait ExtendedCacheItemPoolTrait
2021{
@@ -28,7 +29,10 @@ trait ExtendedCacheItemPoolTrait
2829 */
2930 public function getItemsAsJsonString (array $ keys = [], $ option = 0 , $ depth = 512 )
3031 {
31- return json_encode (array_values ($ this ->getItems ($ keys )), $ option , $ depth );
32+ $ callback = function (CacheItemInterface $ item ){
33+ return $ item ->get ();
34+ };
35+ return json_encode (array_map ($ callback , array_values ($ this ->getItems ($ keys ))), $ option , $ depth );
3236 }
3337
3438 /**
@@ -39,9 +43,9 @@ public function getItemsAsJsonString(array $keys = [], $option = 0, $depth = 512
3943 public function getItemsByTag ($ tagName )
4044 {
4145 if (is_string ($ tagName )) {
42- $ driverResponse = $ this ->driverRead ($ this ->getTagKey ($ tagName ));
43- if ($ driverResponse ) {
44- $ items = (array ) $ this -> driverUnwrapData ( $ driverResponse );
46+ $ driverResponse = $ this ->getItem ($ this ->getTagKey ($ tagName ));
47+ if ($ driverResponse-> isHit () ) {
48+ $ items = (array ) $ driverResponse -> get ( );
4549
4650 return $ this ->getItems (array_unique (array_keys ($ items )));
4751 } else {
@@ -83,7 +87,11 @@ public function getItemsByTags(array $tagNames)
8387 */
8488 public function getItemsByTagsAsJsonString (array $ tagNames , $ option = 0 , $ depth = 512 )
8589 {
86- return json_encode (array_values ($ this ->getItemsByTags ($ tagNames )), $ option , $ depth );
90+ $ callback = function (CacheItemInterface $ item ){
91+ return $ item ->get ();
92+ };
93+
94+ return json_encode (array_map ($ callback , array_values ($ this ->getItemsByTags ($ tagNames ))), $ option , $ depth );
8795 }
8896
8997 /**
0 commit comments