简体   繁体   中英

LuaSocket, Lua 5.2 and Redis

Has anyone been able to get these working together? I've gotten 5.2 working great, and it can find lua-redis (redis.lua), however it fails loading the socket module, which I can't seem to get working with lua (LuaSocket version 2.0.2). Anyone have any tips to get this working?

I've tried making luasocket, however it fails completely, which I'm assuming is due to my lua version 5.2.

Is the answer just to revert back to lua 5.1, or is there another fix that i'm not aware of?

The current release of LuaSocket, as many Lua libraries, does not support Lua 5.2. For Lua changes in the second digit of the version indicate major releases, and backwards-compatibility is not maintained (except in some cases via compilation flags to re-enable deprecated features).

Lua 5.1 is stable, and there is no particular reason not to use it unless you need a feature that was added in 5.2.

That said, many libraries are currently being updated to be 5.2-compatible, including LuaSocket. If you are determined and happy to compile from source and tweak makefiles, try this repository which is a 5.2 compatible version of LuaSocket.

Note that Lua 5.2 must have been built with LUA_COMPAT_MODULE defined for this version of LuaSocket to compile with it. You'll also need to edit the makefiles to adjust for the correct paths on your system.

Given another 3-4 months or so and I think many of the common libraries will be 5.2 compatible. However in my opinion unless it's small stuff, I think it is early days to be basing projects off 5.2. Porting code to 5.2 down the line is not that hard (especially if you familiarise yourself with the deprecated features so you can avoid depending on them too much in 5.1 - especially setfenv() and module() ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM