I am working with the Redis Ruby Gem and and trying to accomplish some server side scripting in Lua, however I cannot convert one of my variables into the required string format.
My variable in it's natural form is: v = 495584087797551105
If I pass v = '495584087797551105' (note the single quotes) everything works fine and I get my desired output of 1.
print redis.eval(" local test
local v
v = '495584087797551105'
test = redis.call('sismember', 'testkey',v)
return test")
**Returns "1"**
However, I cannot convert 495584087797551105 to '495584087797551105'. I have tried using both tostring(v) and string.format('%d',v) and both return the incorrect 0 result.
print redis.eval(" local test
local v
local b
v = 495584087797551105
b = tostring(v) --attempt 1
b = string.format('%d',v) --attempt 2
test = redis.call('sismember', 'testkey',b)
return test")
**Returns "0"**
I have tried using double quotes inside my eval statement however in Ruby does not like it and throws an error. It seems like there has to be a simple solution.