-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathobject-cache.php
158 lines (135 loc) · 3.4 KB
/
object-cache.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
/**
* W3 Total Cache Object Cache
*/
if (!defined('ABSPATH')) {
die();
}
if (!defined('W3TC_DIR')) {
define('W3TC_DIR', WP_CONTENT_DIR . '/plugins/w3-total-cache');
}
if (!@is_dir(W3TC_DIR) || !file_exists(W3TC_DIR . '/inc/define.php')) {
if (!defined('WP_ADMIN')) { // lets don't show error on front end
require_once (ABSPATH . WPINC . '/cache.php');
} else {
@header('HTTP/1.1 503 Service Unavailable');
die(sprintf('<strong>W3 Total Cache Error:</strong> some files appear to be missing or out of place. Please re-install plugin or remove <strong>%s</strong>.', __FILE__));
}
} else {
require_once W3TC_DIR . '/inc/define.php';
/**
* Init cache
*
* @return void
*/
function wp_cache_init() {
$GLOBALS['wp_object_cache'] = & w3_instance('W3_ObjectCache');
}
/**
* Close cache
*
* @return boolean
*/
function wp_cache_close() {
return true;
}
/**
* Get from cache
*
* @param string $id
* @param string $group
* @return mixed
*/
function wp_cache_get($id, $group = 'default') {
global $wp_object_cache;
return $wp_object_cache->get($id, $group);
}
/**
* Set cache
*
* @param string $id
* @param mixed $data
* @param string $group
* @param integer $expire
* @return boolean
*/
function wp_cache_set($id, $data, $group = 'default', $expire = 0) {
global $wp_object_cache;
return $wp_object_cache->set($id, $data, $group, $expire);
}
/**
* Delete from cache
*
* @param string $id
* @param string $group
* @return boolean
*/
function wp_cache_delete($id, $group = 'default') {
global $wp_object_cache;
return $wp_object_cache->delete($id, $group);
}
/**
* Add data to cache
*
* @param string $id
* @param mixed $data
* @param string $group
* @param integer $expire
* @return boolean
*/
function wp_cache_add($id, $data, $group = 'default', $expire = 0) {
global $wp_object_cache;
return $wp_object_cache->add($id, $data, $group, $expire);
}
/**
* Replace data in cache
*
* @param string $id
* @param mixed $data
* @param string $group
* @param integer $expire
* @return boolean
*/
function wp_cache_replace($id, $data, $group = 'default', $expire = 0) {
global $wp_object_cache;
return $wp_object_cache->replace($id, $data, $group, $expire);
}
/**
* Reset cache
*
* @return boolean
*/
function wp_cache_reset() {
global $wp_object_cache;
return $wp_object_cache->reset();
}
/**
* Flush cache
*
* @return boolean
*/
function wp_cache_flush() {
global $wp_object_cache;
return $wp_object_cache->flush();
}
/**
* Add global groups
*
* @param array $groups
* @return void
*/
function wp_cache_add_global_groups($groups) {
global $wp_object_cache;
$wp_object_cache->add_global_groups($groups);
}
/**
* add non-persistent groups
*
* @param array $groups
* @return void
*/
function wp_cache_add_non_persistent_groups($groups) {
global $wp_object_cache;
$wp_object_cache->add_nonpersistent_groups($groups);
}
}