1- <?php namespace CodeIgniter \Cache \Handlers ;
1+ <?php
2+ namespace CodeIgniter \Cache \Handlers ;
23
34/**
45 * CodeIgniter
3536 * @since Version 3.0.0
3637 * @filesource
3738 */
38-
3939use CodeIgniter \Cache \CacheInterface ;
4040
41+ /**
42+ * Cache handler for WinCache from Microsoft & IIS.
43+ * Windows-only, so not testable on travis-ci.
44+ * Unusable methods flagged for code coverage ignoring.
45+ *
46+ */
4147class WincacheHandler implements CacheInterface
4248{
4349
@@ -59,6 +65,7 @@ public function __construct($config)
5965
6066 /**
6167 * Takes care of any handler-specific setup that must be done.
68+ * @codeCoverageIgnore
6269 */
6370 public function initialize ()
6471 {
@@ -69,6 +76,7 @@ public function initialize()
6976
7077 /**
7178 * Attempts to fetch an item from the cache store.
79+ * @codeCoverageIgnore
7280 *
7381 * @param string $key Cache item name
7482 *
@@ -79,7 +87,7 @@ public function get(string $key)
7987 $ key = $ this ->prefix . $ key ;
8088
8189 $ success = false ;
82- $ data = wincache_ucache_get ($ key , $ success );
90+ $ data = wincache_ucache_get ($ key , $ success );
8391
8492 // Success returned by reference from wincache_ucache_get()
8593 return ($ success ) ? $ data : false ;
@@ -89,6 +97,7 @@ public function get(string $key)
8997
9098 /**
9199 * Saves an item to the cache store.
100+ * @codeCoverageIgnore
92101 *
93102 * @param string $key Cache item name
94103 * @param mixed $value The data to save
@@ -107,6 +116,7 @@ public function save(string $key, $value, int $ttl = 60)
107116
108117 /**
109118 * Deletes a specific item from the cache store.
119+ * @codeCoverageIgnore
110120 *
111121 * @param string $key Cache item name
112122 *
@@ -124,6 +134,7 @@ public function delete(string $key)
124134 /**
125135 * Performs atomic incrementation of a raw stored value.
126136 *
137+ * @codeCoverageIgnore
127138 * @param string $key Cache ID
128139 * @param integer $offset Step/value to increase by
129140 *
@@ -134,7 +145,7 @@ public function increment(string $key, int $offset = 1)
134145 $ key = $ this ->prefix . $ key ;
135146
136147 $ success = false ;
137- $ value = wincache_ucache_inc ($ key , $ offset , $ success );
148+ $ value = wincache_ucache_inc ($ key , $ offset , $ success );
138149
139150 return ($ success === true ) ? $ value : false ;
140151 }
@@ -143,6 +154,7 @@ public function increment(string $key, int $offset = 1)
143154
144155 /**
145156 * Performs atomic decrementation of a raw stored value.
157+ * @codeCoverageIgnore
146158 *
147159 * @param string $key Cache ID
148160 * @param integer $offset Step/value to increase by
@@ -154,7 +166,7 @@ public function decrement(string $key, int $offset = 1)
154166 $ key = $ this ->prefix . $ key ;
155167
156168 $ success = false ;
157- $ value = wincache_ucache_dec ($ key , $ offset , $ success );
169+ $ value = wincache_ucache_dec ($ key , $ offset , $ success );
158170
159171 return ($ success === true ) ? $ value : false ;
160172 }
@@ -163,6 +175,7 @@ public function decrement(string $key, int $offset = 1)
163175
164176 /**
165177 * Will delete all items in the entire cache.
178+ * @codeCoverageIgnore
166179 *
167180 * @return mixed
168181 */
@@ -175,6 +188,7 @@ public function clean()
175188
176189 /**
177190 * Returns information on the entire cache.
191+ * @codeCoverageIgnore
178192 *
179193 * The information returned and the structure of the data
180194 * varies depending on the handler.
@@ -191,6 +205,7 @@ public function getCacheInfo()
191205 /**
192206 * Returns detailed information about the specific item in the cache.
193207 *
208+ * @codeCoverageIgnore
194209 * @param string $key Cache item name.
195210 *
196211 * @return mixed
@@ -201,15 +216,15 @@ public function getMetaData(string $key)
201216
202217 if ($ stored = wincache_ucache_info (false , $ key ))
203218 {
204- $ age = $ stored ['ucache_entries ' ][1 ]['age_seconds ' ];
205- $ ttl = $ stored ['ucache_entries ' ][1 ]['ttl_seconds ' ];
219+ $ age = $ stored ['ucache_entries ' ][1 ]['age_seconds ' ];
220+ $ ttl = $ stored ['ucache_entries ' ][1 ]['ttl_seconds ' ];
206221 $ hitcount = $ stored ['ucache_entries ' ][1 ]['hitcount ' ];
207222
208223 return [
209- 'expire ' => $ ttl - $ age ,
210- 'hitcount ' => $ hitcount ,
211- 'age ' => $ age ,
212- 'ttl ' => $ ttl ,
224+ 'expire ' => $ ttl - $ age ,
225+ 'hitcount ' => $ hitcount ,
226+ 'age ' => $ age ,
227+ 'ttl ' => $ ttl ,
213228 ];
214229 }
215230
0 commit comments