前幾周想說來練習一下DB,剛好朋友丟了一個題目給我:即時資訊版
他們的原始結構長這樣
CREATE TABLE IF NOT EXISTS `sm_record_meta` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `steam_id` varchar(32) NOT NULL, `timestamp` int(10) unsigned NOT NULL DEFAULT '0', `expired` int(10) unsigned NOT NULL DEFAULT '0', `action` enum('ban','mute','spray','disarm','class') NOT NULL DEFAULT 'ban', `addition` varchar(32) NOT NULL, `operator` varchar(32) NOT NULL, `reason` varchar(64) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; INSERT INTO `sm_record_meta` (`id`, `steam_id`, `timestamp`, `expired`, `action`, `addition`, `operator`, `reason`) VALUES (1, 'STEAM_0:1:34921810', 1379765224, 0, 'class', 'scout', 'STEAM_0:0:12472998', ' General cheating/exploits'), (2, 'STEAM_0:1:34921810', 1379765619, 0, 'mute', '', 'STEAM_0:0:12472998', ' Other'), (3, 'STEAM_0:1:34921810', 1379765638, 1379852038, 'ban', '', 'STEAM_0:0:12472998', ' Speedhacking'), (4, 'STEAM_0:0:12472998', 1379765748, 1380370548, 'class', 'engineer', 'STEAM_0:0:12472998', ' Other');
我的任務就是要拿Steam_ID去抓官方使用者資料,並將所有資料顯示出來
結構如下
[顯示資料]->[檢查未查詢API資料]----非同步---->[更新]->[回存DB]
由於顯示資料與更新DB分開處理,可加快資料顯示速度
Demo: https://atifans.net/share/tf2/
完整Source Code: https://github.com/atitan/TF2-Dashboard
如有任何意見,歡迎留言
留言