67 lines
1.6 KiB
PHP
67 lines
1.6 KiB
PHP
<?php
|
|
|
|
$g_conf_mysql_cluster = require('../config/game2001api.mysql.cluster.php');
|
|
$g_conf_redis_cluster = require('../config/game2001api.redis.cluster.php');
|
|
|
|
|
|
function checkMysqlConfig()
|
|
{
|
|
$instance_id = 1;
|
|
global $g_conf_mysql_cluster;
|
|
foreach ($g_conf_mysql_cluster as $instance) {
|
|
if ($instance_id != $instance['instance_id']) {
|
|
error_log('game2001api.mysql.cluster.php config error');
|
|
die();
|
|
}
|
|
$instance_id++;
|
|
}
|
|
}
|
|
|
|
|
|
function checkRedisConfig()
|
|
{
|
|
$instance_id = 1;
|
|
global $g_conf_redis_cluster;
|
|
foreach ($g_conf_redis_cluster as $instance) {
|
|
if ($instance_id != $instance['instance_id']) {
|
|
error_log('game2001api.redis.cluster.php config error');
|
|
die();
|
|
}
|
|
$instance_id++;
|
|
}
|
|
}
|
|
|
|
|
|
function getMysqlConfig($hash_value)
|
|
{
|
|
if ($hash_value < 0) {
|
|
die('hash_value < 0 ' . $hash_value);
|
|
}
|
|
global $g_conf_mysql_cluster;
|
|
$idx = $hash_value % count($g_conf_mysql_cluster);
|
|
return $g_conf_mysql_cluster[$idx];
|
|
}
|
|
|
|
function getRedisConfig($hash_value)
|
|
{
|
|
if ($hash_value < 0) {
|
|
die('hash_value < 0 ' . $hash_value);
|
|
}
|
|
global $g_conf_redis_cluster;
|
|
$idx = $hash_value % count($g_conf_redis_cluster);
|
|
return $g_conf_redis_cluster[$idx];
|
|
}
|
|
|
|
function getSkinConfig($skin_table ,$item_id)
|
|
{
|
|
return array_key_exists($item_id, $skin_table) ? $skin_table[$item_id] : null;
|
|
}
|
|
|
|
function getEquipConfig($equip_table, $item_id)
|
|
{
|
|
return array_key_exists($item_id, $equip_table) ? $equip_table[$item_id] : null;
|
|
}
|
|
|
|
checkMysqlConfig();
|
|
checkRedisConfig();
|