Bearsampp
2026.9.23
Toggle main menu visibility
Loading...
Searching...
No Matches
ajax.clearcache.php
Go to the documentation of this file.
1
<?php
2
/*
3
* Copyright (c) 2026 Bearsampp
4
* License: GNU General Public License version 3 or later; see LICENSE.txt
5
* Website: https://bearsampp.com
6
* Github: https://github.com/Bearsampp
7
*/
8
16
header(
'Content-Type: application/json'
);
17
header(
'Cache-Control: no-store'
);
18
19
$response
= [];
20
21
try
{
22
if
(!
CacheManager::isEnabled
()) {
23
Log::error
(
'Cache clear attempted while caching is disabled'
);
24
$response
= [
25
'success'
=>
false
,
26
'error'
=>
'Caching is disabled.'
,
27
];
28
echo json_encode(
$response
);
29
exit
;
30
}
31
32
$deleted =
CacheManager::clearAll
();
33
$stats
=
Root::getCacheStats
();
34
35
$response
= [
36
'success'
=>
true
,
37
'deleted'
=> $deleted,
38
'filesCount'
=>
$stats
[
'filesCount'
],
39
'totalSize'
=>
$stats
[
'totalSize'
],
40
'oldestEntry'
=>
$stats
[
'oldestEntry'
],
41
'newestEntry'
=>
$stats
[
'newestEntry'
],
42
'largestEntry'
=>
$stats
[
'largestEntry'
],
43
];
44
45
Log::info
(
'Cache cleared from homepage: '
. $deleted .
' files deleted'
);
46
}
catch
(Exception $e) {
47
Log::error
(
'Error clearing cache: '
. $e->getMessage());
48
$response
= [
49
'success'
=>
false
,
50
'error'
=> $e->getMessage(),
51
];
52
}
53
54
echo json_encode(
$response
);
55
exit
;
exit
exit
Definition
ajax.apply.moduleconfig.php:72
$response
$response
Definition
ajax.apply.moduleconfig.php:26
$stats
$stats
Definition
ajax.clearcache.php:33
CacheManager\isEnabled
static isEnabled()
Definition
class.cachemanager.php:294
CacheManager\clearAll
static clearAll()
Definition
class.cachemanager.php:193
Log\info
static info($data, $file=null)
Definition
class.log.php:737
Log\error
static error($data, $file=null)
Definition
class.log.php:760
Root\getCacheStats
static getCacheStats()
Definition
class.root.php:161
sandbox
core
resources
homepage
ajax
ajax.clearcache.php
Generated by
1.17.0