public static function get_db_host_roll($db_read_host_array, $db)
 {
     $key = md5(implode("_", array_keys($db_read_host_array) . implode(array_values($db_read_host_array))));
     $cache_array = cls_shmop::readArray($key);
     if ($cache_array) {
         $host = array_shift($cache_array);
         cls_shmop::writeArray($key, $cache_array);
     } else {
         $host_str = $db_read_host_array[$db];
         if ($host_str) {
             $host_array = explode(',', $host_str);
             $read_host_list = self::get_read_host_list($host_array);
             $host = array_shift($read_host_list);
             cls_shmop::writeArray($key, $read_host_list);
         } else {
             $host = '';
         }
     }
     return $host;
 }
 public function nextValue($logic_table)
 {
     $file = fopen(ROOT_PATH . 'includes/cls/' . $logic_table . '_seq.txt', "w+");
     if (flock($file, LOCK_EX)) {
         //独占锁
         $value = 0;
         $is_write = false;
         for (;;) {
             $new_array = cls_shmop::readArray($logic_table);
             if ($new_array) {
                 $start = $new_array['start'];
                 $end = $new_array['end'];
                 $value = $start;
                 if ($start < $end) {
                     $new_array['start'] = $start + 1;
                 } else {
                     $new_array = array();
                 }
                 $is_write = cls_shmop::writeArray($logic_table, $new_array);
             } else {
                 $range = $this->getLastSeq($logic_table);
                 if ($range) {
                     $min = $range->getMin();
                     $max = $range->getMax();
                     $array = array();
                     $array['start'] = $min + 1;
                     $array['end'] = $max;
                     $value = $min;
                     $is_write = cls_shmop::writeArray($logic_table, $array);
                 }
             }
             if ($is_write && $value) {
                 break;
             }
         }
         flock($file, LOCK_UN);
     }
     fclose($file);
     return $value;
 }
 function __construct($config_array = array())
 {
     parent::__construct($config_array);
     if (isset($config_array['consistent_hash_separate_string'])) {
         $this->consistent_hash_separate_string = $config_array['consistent_hash_separate_string'];
     }
     if (isset($config_array['consistent_hash_separate_mod_max_value'])) {
         $this->consistent_hash_separate_mod_max_value = $config_array['consistent_hash_separate_mod_max_value'];
     }
     $list = cls_shmop::readArray(self::INIT_CONSISTENT_HASH_SECTION_CACHE_KEY . parent::getLogicTable());
     if ($list) {
         $this->node_list = $list;
     } else {
         $this->initNodeList();
     }
 }