protected function cache($group = '') { if (!$group) { $group = $this->group; } return Com_Cache::factory($group); }
public function start() { $argv = $_SERVER['argv']; if ($argv[1] != "game" && $argv[1] != "setting") { $argv[1] = "setting"; // echo "warning: argument missing\nusage: php /data/web/crontab/memcache.php game|setting\n"; // exit(); } if (Com_Cache::factory($argv[1])->flush()) { echo "{$argv[1]} flush ok...\n"; } else { echo "{$argv[1]} flush failure...\n"; } }
public function doAction() { $userInfo_json = base64_decode($_POST['data']); $userInfo_array = json_decode($userInfo_json, true); $state = isset($userInfo_array['state']) ? $userInfo_array['state'] : ""; $data = array(); if (!empty($state) && !in_array($state, $this->state)) { $data['status'] = 8; echo json_encode($data); exit; } else { $data['status'] = 0; } if ($state == 'reload') { #reload tables $data['status'] = 1; $data['data'] = 'ok'; Protocol::input(0, 7, 4, 402, array(1)); Protocol::out(); } elseif ($state == 'memcache') { #清memcache 不通知前端 $data['status'] = 1; $data['data'] = 'ok'; Com_Cache::factory('setting')->flush(); } elseif ($state == 'memcache_2') { #清memcache、并通知前端 $data['status'] = 1; $data['data'] = 'ok'; Com_Cache::factory('setting')->flush(); Protocol::input(0, 7, 4, 525, array(1)); Protocol::out(); session_unset(); } elseif ('reset' == $state) { Protocol::input(0, 7, 4, 525, array(1)); Protocol::out(); session_unset(); $data['status'] = 1; $data['data'] = 'ok'; } echo json_encode($data); return; }
Com_AdCache::factory()->set('auto_player_max_id', $auto_player_max_id); } if ($auto_union_id) { // echo "auto_union_id:".$auto_union_id."\n"; Com_AdCache::factory()->set('auto_union_id', $auto_union_id); } if ($auto_union_max_id) { // echo "auto_union_max_id:".$auto_union_max_id."\n"; Com_AdCache::factory()->set('auto_union_max_id', $auto_union_max_id); } shell_exec("/etc/init.d/php-fpm restart"); sleep(1); shell_exec("/etc/init.d/memcached restart"); sleep(1); Com_Cache::factory('game')->flush(); Com_Cache::factory('setting')->flush(); sleep(1); shell_exec("sudo -u nobody /usr/local/webserver/php/bin/php " . PROJECT_ROOT . "/crontab/process.php"); sleep(1); /* //初始化setting,game,log库 $files = array( 'setting' => dirname(__FILE__).'/tenyear2_settings.sql', 'game' => dirname(__FILE__).'/tenyear2_game.sql', 'log' => dirname(__FILE__).'/tenyear2_logs.sql', ); //初始化数据库 foreach($files as $base => $file){ if(is_file($file)){ echo "mysql -hlocalhost -u{$dbConfig[$base]['user']} -p{$dbConfig[$base]['pass']} -e \" use {$dbConfig[$base]['name']}; source {$file};\"\n";
public function flush_cache() { Com_Cache::factory('setting')->flush(); // Com_Cache::factory("game")->flush(); // Com_Queued::send("process", "restart"); $data[0] = intval(1); // Protocol::input(0,7,4,402,$data); // Protocol::out('192.168.1.136'); Protocol::input(0, 7, 4, 402, $data); Protocol::out('192.168.1.105'); // Protocol::make_data($data); // $raw_data = Protocol::output(7,4,402,2); // // $server_ip = Com_System::get_client_ip(); // // $url = "http://{$server_ip}/nginx2cppsvr.do"; // $header = "Content-type: application/octet-stream"; // $ch = curl_init(); //初始化curl // curl_setopt($ch, CURLOPT_URL, $url);//设置链接 // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//设置是否返回信息 // curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));//设置HTTP头 // curl_setopt($ch, CURLOPT_POST, 1);//设置为POST方式 // curl_setopt($ch, CURLOPT_POSTFIELDS, $raw_data);//POST数据 // curl_setopt($ch, CURLOPT_TIMEOUT,1); // curl_exec($ch); // curl_close($ch); }
/** * 建议事物提交时判定锁值来决定是否提交 * * @param unknown_type $lockKey * @param unknown_type $val * @return unknown */ public static function checkVal($lockKey, $val) { return Com_Cache::factory('game')->get($lockKey) === $val; }
public function flush_cache($dbname = "setting") { Com_Cache::factory($dbname)->flush(); Com_Cache::factory("game")->flush(); Com_Queued::send("process", "restart"); }