改进Model的延迟写入方法

This commit is contained in:
thinkphp
2016-08-05 18:14:01 +08:00
parent e9ba9dc1ab
commit 700dc44d4f

View File

@@ -565,9 +565,7 @@ class Query
// 延迟写入 // 延迟写入
$guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition)); $guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition));
$step = $this->lazyWrite('inc', $guid, $step, $lazyTime); $step = $this->lazyWrite('inc', $guid, $step, $lazyTime);
if (false === $step) { return false === $step ? true : $this->setField($field, $step);
return true; // 等待下次写入
}
} }
return $this->setField($field, ['exp', $field . '+' . $step]); return $this->setField($field, ['exp', $field . '+' . $step]);
} }
@@ -592,10 +590,7 @@ class Query
// 延迟写入 // 延迟写入
$guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition)); $guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition));
$step = $this->lazyWrite('dec', $guid, $step, $lazyTime); $step = $this->lazyWrite('dec', $guid, $step, $lazyTime);
if (false === $step) { return false === $step ? true : $this->setField($field, $step);
return true; // 等待下次写入
}
$step = -$step;
} }
return $this->setField($field, ['exp', $field . '-' . $step]); return $this->setField($field, ['exp', $field . '-' . $step]);
} }