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 RC2 |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
if (!defined('SMF')) |
15
|
|
|
die('Hacking attempt...'); |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Our Cache API class |
19
|
|
|
* |
20
|
|
|
* @package cacheAPI |
21
|
|
|
*/ |
22
|
|
|
class zend_cache extends cache_api |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* {@inheritDoc} |
26
|
|
|
*/ |
27
|
|
|
public function isSupported($test = false) |
28
|
|
|
{ |
29
|
|
|
$supported = function_exists('zend_shm_cache_fetch') || function_exists('output_cache_get'); |
30
|
|
|
|
31
|
|
|
if ($test) |
32
|
|
|
return $supported; |
33
|
|
|
return parent::isSupported() && $supported; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritDoc} |
38
|
|
|
*/ |
39
|
|
|
public function getData($key, $ttl = null) |
40
|
|
|
{ |
41
|
|
|
$key = $this->prefix . strtr($key, ':/', '-_'); |
42
|
|
|
|
43
|
|
|
// Zend's pricey stuff. |
44
|
|
|
if (function_exists('zend_shm_cache_fetch')) |
45
|
|
|
return zend_shm_cache_fetch('SMF::' . $key); |
46
|
|
|
elseif (function_exists('output_cache_get')) |
47
|
|
|
return output_cache_get($key, $ttl); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritDoc} |
52
|
|
|
*/ |
53
|
|
|
public function putData($key, $value, $ttl = null) |
54
|
|
|
{ |
55
|
|
|
$key = $this->prefix . strtr($key, ':/', '-_'); |
56
|
|
|
|
57
|
|
|
if (function_exists('zend_shm_cache_store')) |
58
|
|
|
return zend_shm_cache_store('SMF::' . $key, $value, $ttl); |
59
|
|
|
elseif (function_exists('output_cache_put')) |
60
|
|
|
return output_cache_put($key, $value); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritDoc} |
65
|
|
|
*/ |
66
|
|
|
public function cleanCache($type = '') |
67
|
|
|
{ |
68
|
|
|
$this->invalidateCache(); |
69
|
|
|
|
70
|
|
|
return zend_shm_cache_clear('SMF'); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* {@inheritDoc} |
75
|
|
|
*/ |
76
|
|
|
public function getVersion() |
77
|
|
|
{ |
78
|
|
|
return zend_version(); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
?> |