Commit c9f45929e0e877c168165f82091f9069ecbe36cb

Authored by Neil Blakey-Milner
1 parent 38d857c9

Save cacheDir on the Cache object, and implement deleteAllCaches for the

upgrade script.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5206 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 26 additions and 0 deletions
lib/cache/cache.inc.php
... ... @@ -41,6 +41,9 @@ class KTCache {
41 41 $aOptions['lifeTime'] = 60;
42 42 $aOptions['memoryCaching'] = true;
43 43 $aOptions['automaticSerialization'] = true;
  44 +
  45 + $this->cacheDir = $aOptions['cacheDir'];
  46 +
44 47 $this->oLite =& new Cache_Lite($aOptions);
45 48 }
46 49  
... ... @@ -75,6 +78,29 @@ class KTCache {
75 78 }
76 79 return $this->oLite->clean(strtolower($group));
77 80 }
  81 +
  82 + function deleteAllCaches() {
  83 + $this->oLite->clean();
  84 +
  85 + return;
  86 + $dir = $this->cacheDir;
  87 +
  88 + $dh = @opendir($dir);
  89 + if (empty($dh)) {
  90 + return;
  91 + }
  92 +
  93 + $aFiles = array();
  94 + while (false !== ($sFilename = readdir($dh))) {
  95 + if (substr($sFilename, 0, 6) == "cache_") {
  96 + $aFiles[] = sprintf('%s/%s', $dir, $sFilename);
  97 + }
  98 + }
  99 + foreach ($aFiles as $sFile) {
  100 + @unlink($sFile);
  101 + }
  102 +
  103 + }
78 104 }
79 105  
80 106 ?>
... ...