我正在使用phpfastcache https://github.com/khoaofgod/phpfastcache/
当我尝试删除缓存时,我会得到一个错误。
Warning: unlink(C:\...//sqlite/indexing): Permission denied in C:\...drivers\sqlite.php on line 328当有一个进程没有释放这些文件的句柄时,我通常会看到这样的错误。
再生产步骤
// 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'); 这是生成错误的"phpfastcache“方法。
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);
}
}
}有人知道怎么解决这个问题吗?
我暂时使用@unlink()
我试过了,但什么都没有改变
chmod($this->path."/".$file, 0777);
unlink($this->path."/".$file);更新
我在窗户下面..。
更新2
我使用管理帐户安装XAMPP,安装后使用管理权限运行.
更新3
解决方案:
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);
}
}
}发布于 2013-12-07 16:45:51
解决方案取决于为脚本提供服务的环境。
如果是CLI,则创建、删除或修改文件的能力由执行用户控制。
如果是PHP ( WAMP、XAMPP、ZendServer或自己的Webserver+PHP+MySQL-Stack ),则执行层( apache,nginx )必须使用有权做您想做的事情的用户。
在这两种情况下,这都取决于您配置了什么或继承到您的脚本、目录或驱动器中的是什么。
许可知识可以在这里找到:http://technet.microsoft.com/en-us/library/cc770962.aspx
发布于 2013-12-07 15:48:51
(在Windows下不工作)尝试更改权限之前:
chmod($yourfile, '0777');
unlink($yourfile);https://stackoverflow.com/questions/20443247
复制相似问题