Skip to content

Commit

Permalink
优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
titrxw committed Dec 21, 2020
1 parent 28c24ff commit 4df2fbf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/CacheModelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ public function boot() {
private function registerListener() {
//处理在事物中使用缓存问题
Model::getEventDispatcher()->listen(TransactionCommitted::class, function (TransactionCommitted $instance) {
if ($instance->connection->transactionLevel() !== 0) {
if ($instance->connection->transactionLevel() !== 0 || empty($instance->connection->transCallback)) {
return false;
}

$callbacks = $instance->connection->transCallback;
$instance->connection->transCallback = [];
foreach ((array)$callbacks as $callback) {
Expand Down

0 comments on commit 4df2fbf

Please sign in to comment.