API:clearCache

From MODx Wiki

Jump to: navigation, search
 API Function Definition: 
clearCache
Versions 
> 0.6.0 ?
Return Values
Success: stripped string
Fail: null
Data Type 
boolean
Object Hierarchy 
DocumentParser
boolean clearCache();


Clears the cache directory.

Examples

 // do some changes that are not noted by the cache manager 
 // typically in a module
 
 $modx->clearCache();

Related Functions

Source Code

File: manager/includes/document.parser.class.inc.php
Line: 1495
  1. function clearCache() {
  2. $basepath= $this->config["base_path"] . "assets/cache";
  3. if (@ $handle= opendir($basepath)) {
  4. $filesincache= 0;
  5. $deletedfilesincache= 0;
  6. while (false !== ($file= readdir($handle))) {
  7. if ($file != "." && $file != "..") {
  8. $filesincache += 1;
  9. if (preg_match("/\.pageCache/", $file)) {
  10. $deletedfilesincache += 1;
  11. unlink($basepath . "/" . $file);
  12. }
  13. }
  14. }
  15. closedir($handle);
  16. return true;
  17. } else {
  18. return false;
  19. }
  20. }

Notes

Personal tools