forked from szepeviktor/w3-total-cache-fixed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CacheFlush.php
198 lines (169 loc) · 3.86 KB
/
CacheFlush.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
namespace W3TC;
/**
* W3 Cache flushing
*/
class CacheFlush {
private $_config;
/**
* PHP5 Constructor
*/
function __construct() {
$this->_config = Dispatcher::config();
$sns = $this->_config->get_boolean( 'cluster.messagebus.enabled' );
if ( $sns )
$this->_executor = new Enterprise_CacheFlush_MakeSnsEvent();
else
$this->_executor = new CacheFlush_Locally();
if ( function_exists( 'add_action' ) ) {
add_action( 'w3tc_redirect', array(
$this,
'execute_delayed_operations'
), 100000, 0 );
add_filter( 'wp_redirect', array(
$this,
'execute_delayed_operations_filter'
), 100000, 1 );
add_action( 'w3tc_messagebus_message_processed', array(
$this,
'execute_delayed_operations'
), 0 );
add_action( 'shutdown', array(
$this,
'execute_delayed_operations'
), 100000, 0 );
}
}
/**
* Flushes database cache
*/
function dbcache_flush() {
if ( $this->_config->get_boolean( 'dbcache.enabled' ) ) {
$this->_executor->dbcache_flush();
}
}
/**
* Flushes minify cache
*/
function minifycache_flush() {
if ( $this->_config->get_boolean( 'minify.enabled' ) ) {
$this->_executor->minifycache_flush();
}
}
/**
* Flushes object cache
*/
function objectcache_flush() {
if ( $this->_config->get_boolean( 'objectcache.enabled' ) ) {
$this->_executor->objectcache_flush();
}
}
/**
* Flushes fragment cache
*/
function fragmentcache_flush() {
$this->_executor->fragmentcache_flush();
}
/**
* Flushes fragment cache based on group
*/
function fragmentcache_flush_group( $group ) {
$this->_executor->fragmentcache_flush_group( $group );
}
/**
* Updates Browser Query String
*/
function browsercache_flush() {
if ( $this->_config->get_boolean( 'browsercache.enabled' ) ) {
$this->_executor->browsercache_flush();
}
}
/**
* Purge CDN mirror cache
*/
function cdn_purge_all() {
if ( $this->_config->get_boolean( 'cdn.enabled' ) )
return $this->_executor->cdn_purge_all();
return false;
}
/**
* Purges CDN files
*/
function cdn_purge_files( $purgefiles ) {
$this->_executor->cdn_purge_files( $purgefiles );
}
/**
* Clears the system APC
*
* @return mixed
*/
function opcache_flush() {
return $this->_executor->opcache_flush();
}
/**
* Reloads/compiles a PHP file.
*
* @param string $filename
* @return mixed
*/
function opcache_flush_file( $filename ) {
return $this->_executor->opcache_flush_file( $filename );
}
/**
* Purges/Flushes post page
*/
function flush_post( $post_id, $extras = null ) {
return $this->_executor->flush_post( $post_id, $extras );
}
/**
* Checks if page contents can be flushed (i.e. cached at all)
*/
function flushable_posts( $extras = null ) {
$flushable_posts = apply_filters( 'w3tc_flushable_posts', false,
$extras );
return $flushable_posts;
}
/**
* Purges/Flushes all posts
*/
function flush_posts( $extras = null ) {
return $this->_executor->flush_posts( $extras );
}
/**
* Purges/Flushes all enabled caches
*/
function flush_all( $extras = null ) {
static $flushed = false;
if ( !$flushed ) {
$flushed = true;
$this->_executor->flush_all( $extras );
}
}
/**
* Purges/Flushes url
*/
function flush_url( $url, $extras = null ) {
static $flushed_urls = array();
if ( !in_array( $url, $flushed_urls ) ) {
$flushed_urls[] = $url;
return $this->_executor->flush_url( $url, $extras );
}
return true;
}
/**
* Makes get request to url specific to post, ie permalinks
*
* @param unknown $post_id
* @return boolean
*/
function prime_post( $post_id ) {
return $this->_executor->prime_post( $post_id );
}
function execute_delayed_operations() {
return $this->_executor->execute_delayed_operations();
}
function execute_delayed_operations_filter( $v ) {
$this->execute_delayed_operations();
return $v;
}
}