向下支持 PHP 7.4

This commit is contained in:
iVampireSP.com 2023-02-10 12:14:18 +08:00
parent 50763da6dc
commit 92aa25cea1
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -72,7 +72,7 @@ try {
}
try {
if ($redis->ping()) {
if ($redis->ping('')) {
output('redis is ok');
}
} catch (RedisException $e) {
@ -114,7 +114,7 @@ while (true) {
redis_hset('nodes', $node_id, [
'type' => 'edge',
'id' => $node_id,
'id' => 'edge-'.$node_id,
'ip' => $ip,
// utc +8 timestamp
'last_heartbeat' => time(),
@ -152,7 +152,7 @@ while (true) {
exit;
}
$nodes = redis_hgetAll('nodes', []);
$nodes = redis_hgetAll('nodes');
if (! $nodes) {
output('nodes is empty');
@ -183,9 +183,7 @@ while (true) {
$temp_conf .= "server {$node['ip']}";
if (isset($node['weight'])) {
if ($node['weight'] === "0") {
continue;
} else {
if ($node['weight'] !== '0') {
$temp_conf .= " weight={$node['weight']} ";
}
} else {
@ -212,7 +210,7 @@ while (true) {
output('!!!!!!!!!!!!!!!!!');
$add_header = <<<EOF
add_header 'Cluster-Ready-Node-Id' '{$node_id}';
add_header 'Cluster-Ready-Node-Id' 'edge-$node_id';
add_header 'Powered-by' 'Cluster Ready!';
EOF;
@ -243,7 +241,7 @@ function output($context): void
echo $time_string.': '.$context.PHP_EOL;
}
function redis_get($key, $default = null): mixed
function redis_get($key, $default = null)
{
global $redis, $prefix;
@ -260,7 +258,7 @@ function redis_get($key, $default = null): mixed
return $value;
}
function redis_hget($key, $hash_key, $default = null): mixed
function redis_hget($key, $hash_key, $default = null)
{
global $redis, $prefix;
@ -277,7 +275,7 @@ function redis_hget($key, $hash_key, $default = null): mixed
return $value;
}
function redis_hgetAll($key): Redis|array
function redis_hgetAll($key)
{
global $redis, $prefix;