mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 07:32:48 +08:00
Merge branch 'master' of https://github.com/top-think/framework
This commit is contained in:
14
library/think/cache/driver/File.php
vendored
14
library/think/cache/driver/File.php
vendored
@@ -27,6 +27,8 @@ class File extends Driver
|
|||||||
'data_compress' => false,
|
'data_compress' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $expire;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造函数
|
* 构造函数
|
||||||
* @param array $options
|
* @param array $options
|
||||||
@@ -107,11 +109,13 @@ class File extends Driver
|
|||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
$content = file_get_contents($filename);
|
$content = file_get_contents($filename);
|
||||||
|
$this->expire = null;
|
||||||
if (false !== $content) {
|
if (false !== $content) {
|
||||||
$expire = (int) substr($content, 8, 12);
|
$expire = (int) substr($content, 8, 12);
|
||||||
if (0 != $expire && time() > filemtime($filename) + $expire) {
|
if (0 != $expire && time() > filemtime($filename) + $expire) {
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
$this->expire = $expire;
|
||||||
$content = substr($content, 32);
|
$content = substr($content, 32);
|
||||||
if ($this->options['data_compress'] && function_exists('gzcompress')) {
|
if ($this->options['data_compress'] && function_exists('gzcompress')) {
|
||||||
//启用数据压缩
|
//启用数据压缩
|
||||||
@@ -171,10 +175,13 @@ class File extends Driver
|
|||||||
{
|
{
|
||||||
if ($this->has($name)) {
|
if ($this->has($name)) {
|
||||||
$value = $this->get($name) + $step;
|
$value = $this->get($name) + $step;
|
||||||
|
$expire = $this->expire;
|
||||||
} else {
|
} else {
|
||||||
$value = $step;
|
$value = $step;
|
||||||
|
$expire = 0;
|
||||||
}
|
}
|
||||||
return $this->set($name, $value, 0) ? $value : false;
|
|
||||||
|
return $this->set($name, $value, $expire) ? $value : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,10 +195,13 @@ class File extends Driver
|
|||||||
{
|
{
|
||||||
if ($this->has($name)) {
|
if ($this->has($name)) {
|
||||||
$value = $this->get($name) - $step;
|
$value = $this->get($name) - $step;
|
||||||
|
$expire = $this->expire;
|
||||||
} else {
|
} else {
|
||||||
$value = -$step;
|
$value = -$step;
|
||||||
|
$expire = 0;
|
||||||
}
|
}
|
||||||
return $this->set($name, $value, 0) ? $value : false;
|
|
||||||
|
return $this->set($name, $value, $expire) ? $value : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user