修复 修正File缓存细节
This commit is contained in:
parent
ce02aa5cb6
commit
249688255a
|
@ -15,7 +15,6 @@ class memory_driver_file {
|
||||||
public $cacheName = 'File';
|
public $cacheName = 'File';
|
||||||
public $enable;
|
public $enable;
|
||||||
public $path;
|
public $path;
|
||||||
public $cacheData;
|
|
||||||
|
|
||||||
public function env() {
|
public function env() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -38,13 +37,13 @@ class memory_driver_file {
|
||||||
return str_replace('_', '/', $key).'/'.$key;
|
return str_replace('_', '/', $key).'/'.$key;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _get($key) {
|
public function get($key) {
|
||||||
$file = DISCUZ_ROOT.$this->path.$this->cachefile($key).'.php';
|
$file = DISCUZ_ROOT.$this->path.$this->cachefile($key).'.php';
|
||||||
if(!file_exists($file)) {
|
if(!file_exists($file)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$data = null;
|
$data = null;
|
||||||
@include_once $file;
|
@include $file;
|
||||||
if($data !== null) {
|
if($data !== null) {
|
||||||
if($data['exp'] && $data['exp'] < TIMESTAMP) {
|
if($data['exp'] && $data['exp'] < TIMESTAMP) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -56,13 +55,6 @@ class memory_driver_file {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($key) {
|
|
||||||
if(!isset($this->cacheData[$key])) {
|
|
||||||
$this->cacheData[$key] = $this->_get($key);
|
|
||||||
}
|
|
||||||
return $this->cacheData[$key];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function set($key, $value, $ttl = 0) {
|
public function set($key, $value, $ttl = 0) {
|
||||||
$file = DISCUZ_ROOT.$this->path.$this->cachefile($key).'.php';
|
$file = DISCUZ_ROOT.$this->path.$this->cachefile($key).'.php';
|
||||||
dmkdir(dirname($file));
|
dmkdir(dirname($file));
|
||||||
|
@ -71,7 +63,6 @@ class memory_driver_file {
|
||||||
'data' => $value,
|
'data' => $value,
|
||||||
);
|
);
|
||||||
file_put_contents($file, "<?php\n\$data = ".var_export($data, 1).";\n");
|
file_put_contents($file, "<?php\n\$data = ".var_export($data, 1).";\n");
|
||||||
$this->cacheData[$key] = $value;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue