Jeremy D commited on 2019-03-14 18:46:34
Showing 1 changed files, with 75 additions and 0 deletions.
Wrote this for a work project. Haven't even tested this for SMF, just putting it out there.
... | ... |
@@ -0,0 +1,75 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+/** |
|
4 |
+ * Simple Machines Forum (SMF) |
|
5 |
+ * |
|
6 |
+ * @package SMF |
|
7 |
+ * @author Simple Machines http://www.simplemachines.org |
|
8 |
+ * @copyright 2019 Simple Machines and individual contributors |
|
9 |
+ * @license http://www.simplemachines.org/about/smf/license.php BSD |
|
10 |
+ * |
|
11 |
+ * @version 2.1 RC1 |
|
12 |
+ */ |
|
13 |
+ |
|
14 |
+if (!defined('SMF')) |
|
15 |
+ die('Hacking attempt...'); |
|
16 |
+ |
|
17 |
+/** |
|
18 |
+ * Our Cache API class |
|
19 |
+ * |
|
20 |
+ * @package cacheAPI |
|
21 |
+ */ |
|
22 |
+class wincache_cache extends cache_api |
|
23 |
+{ |
|
24 |
+ /** |
|
25 |
+ * {@inheritDoc} |
|
26 |
+ */ |
|
27 |
+ public function isSupported($test = false) |
|
28 |
+ { |
|
29 |
+ $supported = function_exists('wincache_ucache_set') && function_exists('wincache_ucache_get'); |
|
30 |
+ if ($test) |
|
31 |
+ return $supported; |
|
32 |
+ return parent::isSupported() && $supported; |
|
33 |
+ } |
|
34 |
+ |
|
35 |
+ /** |
|
36 |
+ * {@inheritDoc} |
|
37 |
+ */ |
|
38 |
+ public function getData($key, $ttl = null) |
|
39 |
+ { |
|
40 |
+ $key = $this->prefix . strtr($key, ':/', '-_'); |
|
41 |
+ return wincache_ucache_get($key); |
|
42 |
+ } |
|
43 |
+ |
|
44 |
+ /** |
|
45 |
+ * {@inheritDoc} |
|
46 |
+ */ |
|
47 |
+ public function putData($key, $value, $ttl = null) |
|
48 |
+ { |
|
49 |
+ $key = $this->prefix . strtr($key, ':/', '-_'); |
|
50 |
+ $ttl = !empty($ttl) ? $ttl : $this->getDefaultTTL(); |
|
51 |
+ |
|
52 |
+ // No value, delete it. |
|
53 |
+ if ($value === null) |
|
54 |
+ return wincache_ucache_delete($key); |
|
55 |
+ else |
|
56 |
+ return wincache_ucache_set($key, $value, $ttl); |
|
57 |
+ } |
|
58 |
+ |
|
59 |
+ /** |
|
60 |
+ * {@inheritDoc} |
|
61 |
+ */ |
|
62 |
+ public function cleanCache($type = '') |
|
63 |
+ { |
|
64 |
+ $this->invalidateCache(); |
|
65 |
+ return wincache_ucache_clear(); |
|
66 |
+ } |
|
67 |
+ |
|
68 |
+ /** |
|
69 |
+ * {@inheritDoc} |
|
70 |
+ */ |
|
71 |
+ public function getVersion() |
|
72 |
+ { |
|
73 |
+ return phpversion('wincache'); |
|
74 |
+ } |
|
75 |
+} |
|
0 | 76 |