python - How to delete all values from sorted set which are part of different unsorted set -


i trying delete using lua script don't know what's going wrong

import redis r = redis.redis(host='localhost',port=6379) pipe = r.pipeline(transaction = false) lua = """ local env = redis.call('smembers', 'user_key') redis.call('zrem','another_key', unpack(env)) """ p = r.register_script(lua) p(client=pipe) 

local reserved lua keyword that's used declaring local variables. in redis' lua scripting engine, variables must local prevent sandbox litter getting out of hand (read docs @ http://redis.io/commands/eval#global-variables-protection)

your script missing variable name - following should work better:

import redis r = redis.redis(host='localhost',port=6379) pipe = r.pipeline(transaction = false) lua = """ local l = redis.call('smembers' 'user_key') redis.call('zrem', unpack(l)) """ p = r.register_script(lua) p(client=pipe) 

also, there's no real need pipeline here imo.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -