-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqa-ma-cache-that-event.php
More file actions
50 lines (36 loc) · 1.52 KB
/
qa-ma-cache-that-event.php
File metadata and controls
50 lines (36 loc) · 1.52 KB
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
<?php
class qa_ma_cache_that_event {
var $directory;
var $urltoroot;
//this runs before the module is used.
function load_module($directory, $urltoroot)
{
//file system path to the plugin directory
$this->directory=$directory;
//url path to the plugin relative to the current page request.
$this->urltoroot=$urltoroot;
}
function process_event($event, $userid, $handle, $cookieid, $params)
{
//is this an event that has to do with a question?
if (strpos($event, 'q_') === 0 ||
strpos($event, 'a_') === 0 ||
strpos($event, 'c_') === 0) {
global $ma_cache_that;
//yes. So delete the page cache for this question.
require_once($ma_cache_that['root_folder'] . '/class-cache.php');
//set the file path that the cache uses use
HH_cache::$cacheFolder = $ma_cache_that['cache_storage_folder'];
//delete anything that starts with "page-question-" and "questionId-".
//the part of the filename that's after the question is the compression type which doesn't matter for the delete process.
HH_cache::deleteStartsWith("page-question-" . $params['questionid'] . "-");
//As a temporary patch to keeping everything up to date, delete all pages that are cached.
//This will be cleaned up as the caching gets better and we can cache individual areas of a page instead of the entire page.
//At that point, we can just deleted the expired area instead of the entire page.
HH_cache::deleteStartsWith("page-");
}
}
};
/*
Omit PHP closing tag to help avoid accidental output
*/