mirror of
https://github.com/friendica/friendica
synced 2025-04-25 05:10:11 +00:00
Cache clearing rearrangements
This commit is contained in:
parent
5c3d077dfb
commit
66bfb9e76f
2 changed files with 42 additions and 32 deletions
|
@ -21,7 +21,6 @@
|
|||
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Photo;
|
||||
|
@ -35,21 +34,12 @@ class ClearCache
|
|||
public static function execute()
|
||||
{
|
||||
$a = DI::app();
|
||||
$last = DI::config()->get('system', 'cache_last_cleared');
|
||||
|
||||
if ($last) {
|
||||
$next = $last + (3600); // Once per hour
|
||||
$clear_cache = ($next <= time());
|
||||
} else {
|
||||
$clear_cache = true;
|
||||
}
|
||||
|
||||
if (!$clear_cache) {
|
||||
return;
|
||||
}
|
||||
|
||||
// clear old cache
|
||||
DI::cache()->clear();
|
||||
if (!DI::config()->get('system', 'optimize_tables')) {
|
||||
DBA::e("OPTIMIZE TABLE `cache`");
|
||||
}
|
||||
|
||||
// clear old item cache files
|
||||
clear_cache();
|
||||
|
@ -76,25 +66,14 @@ class ClearCache
|
|||
|
||||
// Delete the cached OEmbed entries that are older than three month
|
||||
DBA::delete('oembed', ["`created` < NOW() - INTERVAL 3 MONTH"]);
|
||||
if (!DI::config()->get('system', 'optimize_tables')) {
|
||||
DBA::e("OPTIMIZE TABLE `oembed`");
|
||||
}
|
||||
|
||||
// Delete the cached "parse_url" entries that are older than three month
|
||||
DBA::delete('parsed_url', ["`created` < NOW() - INTERVAL 3 MONTH"]);
|
||||
|
||||
if (DI::config()->get('system', 'optimize_tables')) {
|
||||
Logger::info('Optimize start');
|
||||
DBA::e("OPTIMIZE TABLE `auth_codes`");
|
||||
DBA::e("OPTIMIZE TABLE `cache`");
|
||||
DBA::e("OPTIMIZE TABLE `challenge`");
|
||||
DBA::e("OPTIMIZE TABLE `locks`");
|
||||
DBA::e("OPTIMIZE TABLE `oembed`");
|
||||
if (!DI::config()->get('system', 'optimize_tables')) {
|
||||
DBA::e("OPTIMIZE TABLE `parsed_url`");
|
||||
DBA::e("OPTIMIZE TABLE `profile_check`");
|
||||
DBA::e("OPTIMIZE TABLE `session`");
|
||||
DBA::e("OPTIMIZE TABLE `tokens`");
|
||||
DBA::e("OPTIMIZE TABLE `process`");
|
||||
Logger::info('Optimize finished');
|
||||
}
|
||||
|
||||
DI::config()->set('system', 'cache_last_cleared', time());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue