Add caching to the auto_loader for interfaces (#7320)

* update auto loader to load and cache interfaces

* use new method to update the auto loader cache

* use new interface

* use new interface to trigger a cache flush

* update the console upgrade menu

* update the missing implements syntax

* add the clear_cache to the flush cache button
This commit is contained in:
frytimo
2025-03-15 12:13:36 -03:00
committed by GitHub
parent 99b3100ee9
commit 0a42d8f198
7 changed files with 251 additions and 98 deletions

View File

@@ -9,7 +9,7 @@
* @access public
* @author Mark Crane <mark@fusionpbx.com>
*/
class settings {
class settings implements clear_cache {
/**
* Set in the constructor. String used to load a specific domain. Must be a value domain UUID before sending to the constructor.
@@ -446,31 +446,13 @@ class settings {
}
}
/**
* Clears the settings cache
* @param string $type Empty clears all settings. Values can be global, domain, or user.
*/
public static function clear_cache(string $type = '') {
if (function_exists('apcu_enabled') && apcu_enabled()) {
switch ($type) {
case 'all':
case '':
default:
$type = "";
break;
case 'global':
case 'domain':
case 'user':
$type .= "_";
break;
}
$cache = apcu_cache_info(false);
if (!empty($cache['cache_list'])) {
foreach ($cache['cache_list'] as $entry) {
$key = $entry['info'];
if (str_starts_with($key, 'settings_' . $type)) {
apcu_delete($key);
}
public static function clear_cache() {
$cache = apcu_cache_info(false);
if (!empty($cache['cache_list'])) {
foreach ($cache['cache_list'] as $entry) {
$key = $entry['info'];
if (str_starts_with($key, 'settings_')) {
apcu_delete($key);
}
}
}