11
11
12
12
namespace Cache \CacheBundle \Cache ;
13
13
14
- use Aequasi \Cache \CacheItem ;
15
- use Aequasi \Cache \CachePool ;
16
14
use Psr \Cache \CacheItemInterface ;
17
15
use Psr \Cache \CacheItemPoolInterface ;
16
+ use Psr \Cache \InvalidArgumentException ;
18
17
19
18
/**
20
19
* @author Aaron Scherer <[email protected] >
21
20
*/
22
- class LoggingCachePool extends CachePool
21
+ class LoggingCachePool implements CacheItemPoolInterface
23
22
{
24
23
/**
25
24
* @var array $calls
@@ -70,7 +69,7 @@ public function deleteItem($key)
70
69
71
70
public function save (CacheItemInterface $ item )
72
71
{
73
- $ itemClone = clone $ item ;
72
+ $ itemClone = clone $ item ;
74
73
$ itemClone ->set (sprintf ('<DATA:%s ' , gettype ($ item ->get ())));
75
74
76
75
$ call = $ this ->timeCall (__FUNCTION__ , [$ item ]);
@@ -82,21 +81,68 @@ public function save(CacheItemInterface $item)
82
81
83
82
/**
84
83
* @param string $name
85
- * @param $arguments
84
+ * @param array $arguments
86
85
*
87
86
* @return object
88
87
*/
89
- private function timeCall ($ name , $ arguments )
88
+ private function timeCall ($ name , array $ arguments = null )
90
89
{
91
90
$ start = microtime (true );
92
91
$ result = call_user_func_array ([$ this ->cachePool , $ name ], $ arguments );
93
92
$ time = microtime (true ) - $ start ;
94
93
95
- $ object = (object ) compact ('name ' , 'arguments ' , 'start ' , 'time ' , 'result ' );
94
+ $ object = (object )compact ('name ' , 'arguments ' , 'start ' , 'time ' , 'result ' );
96
95
97
96
return $ object ;
98
97
}
99
98
99
+ public function getItems (array $ keys = [])
100
+ {
101
+ $ call = $ this ->timeCall (__FUNCTION__ , [$ keys ]);
102
+ $ result = $ call ->result ;
103
+ $ call ->result = sprintf ('<DATA:%s> ' , gettype ($ result ));
104
+
105
+ $ this ->calls [] = $ call ;
106
+
107
+ return $ result ;
108
+ }
109
+
110
+ public function clear ()
111
+ {
112
+ $ call = $ this ->timeCall (__FUNCTION__ );
113
+ $ this ->calls [] = $ call ;
114
+
115
+ return $ call ->result ;
116
+ }
117
+
118
+ public function deleteItems (array $ keys )
119
+ {
120
+ $ call = $ this ->timeCall (__FUNCTION__ , [$ keys ]);
121
+ $ this ->calls [] = $ call ;
122
+
123
+ return $ call ->result ;
124
+ }
125
+
126
+ public function saveDeferred (CacheItemInterface $ item )
127
+ {
128
+ $ itemClone = clone $ item ;
129
+ $ itemClone ->set (sprintf ('<DATA:%s ' , gettype ($ item ->get ())));
130
+
131
+ $ call = $ this ->timeCall (__FUNCTION__ , [$ item ]);
132
+ $ call ->arguments = ['<CacheItem> ' , $ itemClone ];
133
+ $ this ->calls [] = $ call ;
134
+
135
+ return $ call ->result ;
136
+ }
137
+
138
+ public function commit ()
139
+ {
140
+ $ call = $ this ->timeCall (__FUNCTION__ );
141
+ $ this ->calls [] = $ call ;
142
+
143
+ return $ call ->result ;
144
+ }
145
+
100
146
/**
101
147
* @return array
102
148
*/
0 commit comments