golang開發的一個mysql連線代理池,支援多種語言客戶端(PHP範例)
阿新 • • 發佈:2019-02-20
golang mysql pool proxy(MPP)
golang開發的一個mysql連線代理池, HTTP返回查詢結果。
特性(迭代更新支援)
-
golang查詢mysql, 支援連線池, HTTP返回資料,通過POST傳遞sql語句 (已實現)
-
增加了postgre資料庫的支援 (已實現)
-
支援查詢資料快取 (已實現)
-
支援多種語言(傳送POST請求即可) (已實現)
-
讀寫分離
-
SQL防注入
-
支援HTTPS (已實現)
-
考慮支援分散式HTTP server
-
加入log檔案支援 (已實現)
編譯啟動方式(linux), windows照樣
cd project_path
go build
mv golang_mysql_proxy_pool mpp
./mpp
返回資料類似 {"code":0,"rows":"[email protected]","status":"success"} 的 json 格式
屬性說明
code 0 is for success 1 is for wrong query 2 is for wrong get data 3 is for wrong uukey status success or fail rows query data
怎麼使用?
example/mpp_cls.php檔案是PHP語言的客戶端,有目前現有的所有功能的範例,請參考
聯絡詳情可檢視github
測試
WIN7, go version go1.4.2 windows/386, PHP 5.6, MYSQL5.6, 1萬條mysql資料 example目錄
沒使用MPP的檔案, php no_use_mpp.php -----Use time: 1.2660720348358-------
使用MPP的檔案, php use_mpp.php -----Use time: 0.26302088737488-------