Circuit breaker design pattern: Difference between revisions

Content deleted Content added
Line 54:
===PHP===
 
The following is a sample implementation in PHP. The proof of concept stores the status of a MySQL server into a shared memory cache ([[AlternativeAPC PHPUser Cache|APC]]).
 
==== Check ====
Line 64:
 
if ($mysqli->connect_error) {
apc_storeapcu_add("dbStatus", "down");
} else {
apc_storeapcu_add("dbStatus", "up");
$mysqli->close();
}
Line 74:
 
<syntaxhighlight lang="php">
if (apc_fetchapcu_fetch("dbStatus") === "down") {
echo "The database server is currently not available. Please try again in a minute.";
exit;