Re: Redis Lua Problem?

82 views
Skip to first unread message

霍其坤

unread,
Dec 16, 2012, 6:40:11 PM12/16/12
to redi...@googlegroups.com
try this
local t = {}
t[#t+1]=1
t[#t+1]=2

return redis.call('sadd','test',unpack(t))


发自我的 iPad

在 2012-12-17,2:13,Harachie <hara...@gmail.com> 写道:

Hi all,

I am working with the cool LUA feature.

To add multiple items to a set I want to simply add a LUA table via SADD.
Here is my test script:

local t = {}

table.insert(t, 1)
table.insert(t, 2)

redis.call('sadd', 'teststst', t)

return 0

The thing that makes me wonder is this line 'redis.call('sadd', 'teststst', t)'
It does simply nothing,
but I would expect to have added every entry from the table to the set.

My current workaround it to do this in a simple for loop.

Is this supposed to work, or am I missing something?
It does not throw any error, so I have no idea if this is the expected behaviour ;-).

Hope any one can shed some light onto this.


Kind regards,
Bastian Kröger

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To view this discussion on the web visit https://groups.google.com/d/msg/redis-db/-/o_NpPHKAePQJ.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.

Bastian Kröger

unread,
Dec 17, 2012, 11:14:41 AM12/17/12
to redi...@googlegroups.com
Hi,

it works as expected,
thanks for the help :-)

Kind regards,
Bastian Kröger
Reply all
Reply to author
Forward
0 new messages