TurboRedisΒΆ

TurboRedis is a Redis library for the blazing fast Turbo.Lua web/networking library.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
local turbo = require("turbo")
local turboredis = require("turboredis")
 
local redis = turboredis.Connection:new()
 
local HelloRedisHandler = class("RedisHandler", turbo.web.RequestHandler)
 
function HelloRedisHandler:get()
    local msg = coroutine.yield(redis:get("msg"))
    self:write(msg .. "\n")
end
 
local app = turbo.web.Application({
    {"^/", HelloRedisHandler}
})
app:listen(8888)
 
turbo.ioloop.instance():add_callback(function ()
    coroutine.yield(redis:connect())
    coroutine.yield(redis:set("msg", "Hello World!!!"))
end)
 
turbo.ioloop.instance():start()

Contents:

TurboRedis

Navigation

Fork me on GitHub