Here is a small example of using ts_lua as a global plugin. please make
sure you a line of "tslua.so /home/kichan/main.lua" in plugin.config and
the content of main.lua is as below.
ts.add_package_cpath('/home/kichan/lib/?.so')
ts.add_package_path('/home/kichan/lualib/?.lua;/home/kichan/lualib/socket/?.lua')
local redis = require 'redis'
local client = redis.connect('127.0.0.1', 6379)
function do_global_send_response()
local response = client:ping()
local value = client:get('mykey')
ts.client_response.header['X-Redis-Ping'] = tostring(response)
ts.client_response.header['X-Redis-MyKey'] = value
end
Please note
1) I have a local redis and I set a "mykey" already beforehand
2) I downloaded and compiled luasocket and redis-lua and put all "so" into
/home/kichan/lib/ and all lua files from them into /home/kichan/lualib/
Thanks.
Kit
On Fri, Dec 5, 2014 at 12:47 PM, Luca Rea <[email protected]> wrote:
> Hi,
> can you share with us some lines of code / examples?
>