redis.call('ZINTERSTORE', 'dummyKey123', numKeys, unpack(KEYS))
--
Javier
--
Javier
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
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.
Not in unpack, but in redis.call().
Not stack, but the limit on number of function arguments.
This is a problem in Redis API, BTW.
Maybe allow redis.call to optionally accept table with arguments
(keeping the current API as well, of course)?
I.e.
table.insert(KEYS, 1, "ZINTERSTORE")
table.insert(KEYS, 1, "dummyKey123")
table.insert(KEYS, 1, numKeys)
redis.call(KEYS)
Inserting at the beginning of the table is not very efficient, though,
so, maybe allow to mix styles?
redis.call("ZINTERSTORE", "dummyKey123", numKeys, KEYS)
Alexander.
Number of return values, right.
Sorry, not fully awake yet :-)
Alexander.
> And afaik the limit is LUAI_MAXCSTACK.
Hey, we are not running into Raspberry Pi (for now), so we can alter
this default value to an higher value. Makes sense?
Salvatore
--
Salvatore 'antirez' Sanfilippo
open source developer - VMware
http://invece.org
"We are what we repeatedly do. Excellence, therefore, is not an act,
but a habit." -- Aristotele
No. You will hit the limit anyway eventually. (And the default should
be large enough, I think.)
The point is to remove the limit (or rather provide a limitless, if
less convenient option :-) ) — and this can only be done by offering a
different API.
Alexander.
Well that's entirely possible because:
redis 127.0.0.1:6379> EVAL 'return redis.call({1,2,3})' 0
(error) Lua redis() command arguments must be strings or integers
So we can introduce a new calling convention so that tables are
automatically expanded into arguments.
This way calling: (1,2,3) or (1,{2,3}) is he same. The most
straightforward use would be to just a single call, but also this
allows to just write: redis.call("MGET",mykeys).
Sounds good?
Cheers,
Pieter
Good point, thanks you Pieter... maybe it's time to use our secret
weapon of waiting a few months before proceeding ;)
Cheers,
Salvatore
Probably this is the best way. BTW, the problem with list head
insertion overhead may be alleviated if there would be a way to append
result of command to the existing table.
Something like (pseudocode):
local command = { 'ZINTERSTORE', 'dummyKey123', 0 }
local num_keys = redis.call_append_result(command)
command[3] = num_keys
redis.call(command)
Not so pretty, of course...
> Good point, thanks you Pieter... maybe it's time to use our secret
> weapon of waiting a few months before proceeding ;)
May be a good idea.
Alexander.
Above should be:
local num_keys = redis.call_append_result(command, 'KEYS', '*')
Hi, Salvatore.
Looks like you've been waiting enough :). I ran into this issue for real here - https://github.com/Suor/django-cacheops/blob/fc13ce96d8a198090238d75f4800042e8c72f703/cacheops/lua/invalidate.lua#L29 - trying to delete to many keys at a time.
I am going to use this workaround now:
local call_in_chunks = function (command, args)
local step = 100
for i = 1, #args, step do
redis.call(command, unpack(args, i, math.min(i + step - 1, #args)))
end
end
call_in_chunks('del', cache_keys)
However, it would be much nicer just write
redis.call('del', cache_keys)
Regards, Alexander.
четверг, 1 марта 2012 г., 5:22:54 UTC+8 пользователь Salvatore Sanfilippo написал: