Relative Content

Tag Archive for redislua

redis lua script can’t call on global

local function get_cur_time() local current_time = redis.call(‘TIME’)[1] local current_minute_start = math.floor(current_time / 60) * 60 return current_minute_start end — add below line would failed — local CURRENT_TIME = get_cur_time() redis.register_function(‘get_cur_time’, get_cur_time) I’d like reuse CURRENT_TIME in many place in my function, but once I added it to global scope, raise error: redis.exceptions.ResponseError: Error registering functions: […]

Redis evication policy using lua script

in my case i have alot of data in redis like
User_DB_1:<user_id> , User_Main:<user_id>, Skills_DB_1:<user_id>
I set the maxmemory to 50mb and write a lua script and run it in the redis that lua file should remove data that has pattern User_DB_1:<user_id> and shouldn’t remove any data for Skills pattern
I have tried alot and I see that each time remove data matches Skills pattern
and i run it uses
redis-cli --eval /data/redis_evication.lua
and the output is (integer) 1000