Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 70510d3

Browse files
committed
fix: forgetTwin() may not forget
因為用 && 會導致前者失敗後者就直接不執行 而 || 會造成前者成功後者不執行 所以最後分開執行並給個暫時性變數 用這兩個變數進行 || 運算 只要有一邊成功就回傳真 都失敗才回傳假
1 parent 2b07c1e commit 70510d3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/TwinStore.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,11 @@ public function foreverTwin($key, $value)
328328
*/
329329
public function forgetTwin($key)
330330
{
331-
return $this->older->forget($key)
332-
&& $this->younger->forget($key);
331+
$forget_older = $this->older->forget($key);
332+
$forget_younger = $this->younger->forget($key);
333+
334+
// If one of them succeed, this will return ture
335+
return $forget_older || $forget_younger;
333336
}
334337

335338
/**

0 commit comments

Comments
 (0)