改进缓存类的remember方法

This commit is contained in:
thinkphp
2017-09-24 12:31:14 +08:00
parent b673555aab
commit d114f59194

View File

@@ -122,6 +122,7 @@ abstract class Driver
if (!$this->has($name)) { if (!$this->has($name)) {
while ($this->has($name . '_lock')) { while ($this->has($name . '_lock')) {
// 存在锁定则等待 // 存在锁定则等待
usleep(100000);
} }
try { try {
@@ -136,6 +137,8 @@ abstract class Driver
} catch (\Exception $e) { } catch (\Exception $e) {
// 解锁 // 解锁
$this->rm($name . '_lock'); $this->rm($name . '_lock');
} catch (\throwable $e) {
$this->rm($name . '_lock');
} }
} else { } else {
$value = $this->get($name); $value = $this->get($name);