天天看點

lua mysql 字元串截取_lua redis 操作

https://redis.io/commands/keys

周遊redis裡面的所有key ,還能進行模糊比對, 這樣就省去了對key的手動過濾了

比如

keys term_info*

1) "term_info:51"2) "term_info:94"3) "term_info:103"4) "term_info:149"5) "term_info:18"

大緻思路 :

1 周遊key ,讀取redis 裡面的資料, 為寫入mysql增加一個腳本檔案,

2 定時/手動将redis的檔案導入到MySQL

3 頁面資料由MySQL進行查詢顯示與永久存儲

redis-server會關閉空閑逾時的連接配接 就不需要redis.close()了, 這個簡單些

lua 替換最後一個字元,字元串截取, 然後在添加一個分号

redis_to_mysql = string.sub(redis_to_mysql,1,-3)..";"

utils.write_file("/usr/lib/lua/luci/service/audit/audit_view_ex_record.sql",redis_to_mysql)

然後再寫到資料庫裡面,執行sql語句

source insight 4.0

菜單欄中【File】 > 【Reload As Encoding...】 > 【Chinese Simplified (GB18030)】 > 選擇後,點選load,我的用utf-8解決亂碼問題