改进缓存驱动

This commit is contained in:
thinkphp
2017-08-30 10:49:10 +08:00
parent 64ccd7ea68
commit a217d88e38
2 changed files with 7 additions and 13 deletions

View File

@@ -120,22 +120,22 @@ abstract class Driver
public function remember($name, $value, $expire = null)
{
if (!$this->has($name)) {
while ($this->has($name . '.lock')) {
while ($this->has($name . '_lock')) {
// 存在锁定则等待
}
try {
// 锁定
$this->set($name . '.lock', true);
$this->set($name . '_lock', true);
if ($value instanceof \Closure) {
$value = call_user_func($value);
}
$this->set($name, $value, $expire);
// 解锁
$this->rm($name . '.lock');
$this->rm($name . '_lock');
} catch (\Exception $e) {
// 解锁
$this->rm($name . '.lock');
$this->rm($name . '_lock');
}
} else {
$value = $this->get($name);