Hi, I'm a long time mysql dba but I'm brand new to lua. Proxy is great, and I'm trying to do some testing with it and build new utilities, however I'm having issues getting some stuff to run. I know it's an environment issue, and probably something simple but I can't quite see it.
I'm trying to write an external query cache using proxy & memcached. This way it's possible to dedicate gigs of RAM on any number of external boxes to caching w/out competing for resources with using mysql's built in query cache.
Plus it would be possible to add application-specific caching, the more semantic info your cache method knows about the end use, the more efficiently the cache can be used. For example we could choose to only cache rows that select based on a primary key lookup, and then be more selective about when an update would invalidate cache items.
So here's where I'm stuck:
I've got a proxy script trying to load Memcached.lua which in turn loads the lua socket library.
see
http://trac.lighttpd.net/trac/attachment/ticket/1139/Memcached.lua
and
http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/
And here's the simple test lua script I'm trying to load:
require("Memcached")
cache = Memcached.Connect("localhost")
function read_query( packet )
local var1 = cache:get("var1")
print("got var 1 " .. var1 .."\n")
end
However, a test case with just the require and connect runs fine from the command line, I've verified in a non-proxy test script that it can load the libraries, connect & read & write to the memcached server. However when running through proxy, it errors out on trying to load the socket library.
# mysql-proxy --proxy-lua-script=/usr/local/mysql-proxy-0.6.0-linux-fc4-x86/share/memcachedtest.lua
< then run any query against proxy >
(lua-error) [/usr/local/mysql-proxy-0.6.0-linux-fc4-x86/share/vardump.lua]
error loading module 'socket' from file './socket.so':
./socket.so: cannot open shared object file: No such file or directory
(lua-error) [/usr/local/mysql-proxy-0.6.0-linux-fc4-x86/share/vardump.lua]
...al/mysql-proxy-0.6.0-linux-fc4-x86/share/vardump.lua:1: loop or previous error loading module 'Memcached'
My enviroment is:
LUA_PATH=/usr/local/mysql-proxy-0.6.0-linux-fc4-x86/?.lua;;
LUA_CPATH=/usr/local/lib/lua/5.1/?.so;;
# find /usr/ -name lua
/usr/local/share/lua
/usr/local/bin/lua
/usr/local/lib/lua
# find /usr/ -name socket
/usr/local/share/lua/5.1/socket
/usr/local/lib/lua/5.1/socket
This does work:
# lua memcachetest.lua
got value for key2 :val2
# cat memcachetest.lua
require("Memcached")
cache = Memcached.Connect("localhost")
cache:set('key1', "val1")
cache:set("key2", "val2")
value = cache:get("key2")
print(" got value for key2 :" .. value .. "\n")
Any suggestions would be really appreciated. It looks to me like the enviroment that proxy is running scripts under is different than the default configured enviroment for the command line lua, but I don't know enough about either to know what that difference is. I don't know enough about what it's expecting when it gives me the error about /usr/local/lib/lua/5.1/socket/core.so, because that file exists.
Thanks!
-Gavin Towey