1. 程式人生 > >Windows下lua+redis除錯環境搭建

Windows下lua+redis除錯環境搭建

Lua+Redis 斷點除錯環境搭建
windows環境,使用Redis,寫lua指令碼頭疼的問題之一不能對指令碼斷點除錯,google加上自己的摸索,終於搞定。
1、下載ZeroBraneStudio,我下載的是破解版(我自己為自己感到可恥,其實並不貴,百十來塊錢的樣子)
解壓後在bin下有lua直譯器的路徑,把該路徑新增到環境變數中:假設直譯器路徑是:D:/ZeroBraneStudio/bin/lua.exe,那麼就把D:/ZeroBraneStudio/bin新增到Path環境變數下。
2、下載luaRocks,它是一個lua相關型別的維護工具包,下載地址:https://github.com/keplerproject/luarocks/wiki/Installation-instructions-for-Windows


下載後從cmd命令列中執行Install.bat安裝。
3、安裝redis及除錯相關類庫:
開啟cmd依次執行三個命令進行安裝:
luarocks install remdebug
luarocks install prtr-dump
luarocks install redis-lua
4、開啟ZeroBraneStudio,建lua指令碼,名字隨意,比如my.lua,新增如下內容:

local redis = require 'redis'
local host = "127.0.0.1"
local port = 6379
client = redis.connect(host, port)

redis.call = function
(cmd, ...) return assert(loadstring('return client:'.. string.lower(cmd) ..'(...)'))(...) end

這裡寫圖片描述