15
15
namespace phpFastCache \Core ;
16
16
17
17
use InvalidArgumentException ;
18
+ use Psr \Cache \CacheItemInterface ;
18
19
19
20
trait ExtendedCacheItemPoolTrait
20
21
{
@@ -28,7 +29,10 @@ trait ExtendedCacheItemPoolTrait
28
29
*/
29
30
public function getItemsAsJsonString (array $ keys = [], $ option = 0 , $ depth = 512 )
30
31
{
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 );
32
36
}
33
37
34
38
/**
@@ -39,9 +43,9 @@ public function getItemsAsJsonString(array $keys = [], $option = 0, $depth = 512
39
43
public function getItemsByTag ($ tagName )
40
44
{
41
45
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 ( );
45
49
46
50
return $ this ->getItems (array_unique (array_keys ($ items )));
47
51
} else {
@@ -83,7 +87,11 @@ public function getItemsByTags(array $tagNames)
83
87
*/
84
88
public function getItemsByTagsAsJsonString (array $ tagNames , $ option = 0 , $ depth = 512 )
85
89
{
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 );
87
95
}
88
96
89
97
/**
0 commit comments