mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-27 09:49:22 +02:00
Another way to clear database cache
This commit is contained in:
parent
3a58c8a6f9
commit
87df817eae
@ -74,7 +74,7 @@ if(ModelsFAQ::count() == 0) {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearCache();
|
$db->setClearCacheAfter(true);
|
||||||
|
|
||||||
$locale['step_finish_desc'] = str_replace('$ADMIN_PANEL$', generateLink(str_replace('tools/', '',ADMIN_URL), $locale['step_finish_admin_panel'], true), $locale['step_finish_desc']);
|
$locale['step_finish_desc'] = str_replace('$ADMIN_PANEL$', generateLink(str_replace('tools/', '',ADMIN_URL), $locale['step_finish_admin_panel'], true), $locale['step_finish_desc']);
|
||||||
$locale['step_finish_desc'] = str_replace('$HOMEPAGE$', generateLink(str_replace('tools/', '', BASE_URL), $locale['step_finish_homepage'], true), $locale['step_finish_desc']);
|
$locale['step_finish_desc'] = str_replace('$HOMEPAGE$', generateLink(str_replace('tools/', '', BASE_URL), $locale['step_finish_homepage'], true), $locale['step_finish_desc']);
|
||||||
|
@ -1213,7 +1213,6 @@ function clearCache()
|
|||||||
'towns', 'groups', 'vocations',
|
'towns', 'groups', 'vocations',
|
||||||
'visitors', 'views_counter', 'failed_logins',
|
'visitors', 'views_counter', 'failed_logins',
|
||||||
'template_menus',
|
'template_menus',
|
||||||
'database_tables', 'database_columns', 'database_checksum',
|
|
||||||
'last_kills',
|
'last_kills',
|
||||||
'hooks', 'plugins_hooks', 'plugins_routes', 'plugins_settings', 'plugins_themes', 'plugins_commands',
|
'hooks', 'plugins_hooks', 'plugins_routes', 'plugins_settings', 'plugins_themes', 'plugins_commands',
|
||||||
'settings',
|
'settings',
|
||||||
@ -1242,6 +1241,9 @@ function clearCache()
|
|||||||
$cache->delete($item);
|
$cache->delete($item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global $db;
|
||||||
|
$db->setClearCacheAfter(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteDirectory(CACHE . 'signatures', ['index.html'], true);
|
deleteDirectory(CACHE . 'signatures', ['index.html'], true);
|
||||||
|
@ -28,6 +28,8 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
|||||||
{
|
{
|
||||||
private $has_table_cache = array();
|
private $has_table_cache = array();
|
||||||
private $has_column_cache = array();
|
private $has_column_cache = array();
|
||||||
|
|
||||||
|
private $clearCacheAfter = false;
|
||||||
/**
|
/**
|
||||||
* Creates database connection.
|
* Creates database connection.
|
||||||
*
|
*
|
||||||
@ -96,7 +98,8 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
|||||||
}
|
}
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
if(class_exists('Cache') && ($cache = Cache::getInstance()) && $cache->enabled()) {
|
$cache = Cache::getInstance();
|
||||||
|
if($cache->enabled()) {
|
||||||
$tmp = null;
|
$tmp = null;
|
||||||
$need_revalidation = true;
|
$need_revalidation = true;
|
||||||
if($cache->fetch('database_checksum', $tmp) && $tmp) {
|
if($cache->fetch('database_checksum', $tmp) && $tmp) {
|
||||||
@ -147,10 +150,18 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
|||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if(class_exists('Cache') && ($cache = Cache::getInstance()) && $cache->enabled()) {
|
$cache = Cache::getInstance();
|
||||||
$cache->set('database_tables', serialize($this->has_table_cache), 3600);
|
if($cache->enabled()) {
|
||||||
$cache->set('database_columns', serialize($this->has_column_cache), 3600);
|
if ($this->clearCacheAfter) {
|
||||||
$cache->set('database_checksum', serialize(sha1($config['database_host'] . '.' . $config['database_name'])), 3600);
|
$cache->delete('database_tables');
|
||||||
|
$cache->delete('database_columns');
|
||||||
|
$cache->delete('database_checksum');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$cache->set('database_tables', serialize($this->has_table_cache), 3600);
|
||||||
|
$cache->set('database_columns', serialize($this->has_column_cache), 3600);
|
||||||
|
$cache->set('database_checksum', serialize(sha1($config['database_host'] . '.' . $config['database_name'])), 3600);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->logged) {
|
if($this->logged) {
|
||||||
@ -238,6 +249,11 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setClearCacheAfter($clearCache)
|
||||||
|
{
|
||||||
|
$this->clearCacheAfter = $clearCache;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user