Update cache.php

This commit is contained in:
FusionPBX 2017-07-22 13:18:03 -06:00 committed by GitHub
parent c2663c3e59
commit c857ce7f69
1 changed files with 68 additions and 34 deletions

View File

@ -81,6 +81,9 @@ class cache {
* @var string $key cache id
*/
public function delete($key) {
//cache method memcache
if (strlen($_SESSION['cache']['method']['text']) == "memcache") {
// connect to event socket
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp === false) {
@ -101,6 +104,18 @@ class cache {
//close event socket
fclose($fp);
}
//cache method file
if (strlen($_SESSION['cache']['method']['text']) == "file") {
$key = str_replace(":", ".", $key);
if (file_exists($_SESSION['cache']['location']['text'] . "/" . $key)) {
unlink($_SESSION['cache']['location']['text'] . "/" . $key);
if (file_exists($_SESSION['cache']['location']['text'] . "/" . $key . ".tmp")) {
unlink($_SESSION['cache']['location']['text'] . "/" . $key . ".tmp");
}
}
}
// return result
return $result;
@ -110,6 +125,8 @@ class cache {
* Delete the entire cache
*/
public function flush() {
//cache method memcache
if (strlen($_SESSION['cache']['method']['text']) == "memcache") {
// connect to event socket
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp === false) {
@ -130,6 +147,23 @@ class cache {
//close event socket
fclose($fp);
}
//cache method file
if (strlen($_SESSION['cache']['method']['text']) == "file") {
//send a custom event
$event = "sendevent CUSTOM\n";
$event .= "Event-Name: CUSTOM\n";
$event .= "Event-Subclass: fusion::file\n";
$event .= "API-Command: file\n";
$event .= "API-Command-Argument: flush\n";
event_socket_request($fp, $event);
//remove the cache
recursive_delete($_SESSION['cache']['location']['text']);
}
// return result
return $result;