I'm using phpfastcache https://github.com/khoaofgod/phpfastcache/
when I try to delete the cache I get an error
Warning: unlink(C:\...//sqlite/indexing): Permission denied in C:\...drivers\sqlite.php on line 328
I usually see that kind of error when there is a process not releasing the handle of those files.
Step to reproduce
// Require phpfastcache
require_once 'phpfastcache_v2.1_release\phpfastcache\phpfastcache.php';
// Simple singleton
class MyCache extends phpFastCache
{
private static $istance;
Private $obCache;
function __construct()
{
$option = array('securityKey' => 'aCache', 'path' => dirname(__FILE__));
$this->obCache = parent::__construct('sqlite', $option);
}
public static function getIstance()
{
if( is_null(self::$istance) )
{
self::$istance = new self();
}
return self::$istance;
}
}
// check if cached
if( $CacheData = MyCache::getIstance()->get('aKeyword') )
{
die('Cached');
}
// store in cache
MyCache::getIstance()->set('aKeyword','aValue', 60*60*24);
// clean cache (throw error)
MyCache::getIstance()->clean();
die('No cached');
this is the method of "phpfastcache" that generates the error
function driver_clean($option = array()) {
// delete everything before reset indexing
$dir = opendir($this->path);
while($file = readdir($dir)) {
if($file != "." && $file!="..") {
unlink($this->path."/".$file);
}
}
}
does anyone know how to fix this?
I'm temporarily using @unlink()
I tried but nothing has changed
chmod($this->path."/".$file, 0777);
unlink($this->path."/".$file);
UPDATE
I'm under windows...
UPDATE 2
I installed XAMPP using the admin account, after installation run with admin privileges...
UPDATE 3
Solution:
function driver_clean($option = array()) {
// close connection
$this->instant = array();
$this->indexing = NULL;
// delete everything before reset indexing
$dir = opendir($this->path);
while($file = readdir($dir)) {
if($file != "." && $file!="..") {
unlink($this->path."/".$file);
}
}
}
(Doesn't work under Windows) Try to change permissions before: