lua
it just send the lua file to server
test lua set
local function getSlotsMinAndMax (s, s1)
local t = {}
local i = 0
local j = 0
while true do
j = string.find(s,'\n',i+1)
if j == nil then
-- endPos
t[#t+1] = string.sub (s,i,string.len(s))
break
end
t [#t+1] = string.sub (s,i,j-1)
i = j+1
end
for i =1,#t do
local iSpace = string.find(t[i],' ')
local data = string.sub(t[i],1,iSpace -1)
if data ~= s1 then
else
-- cur Line opt
local iMaster1,iMaster2 = string.find(t[i], 'master')
if iMaster1 == nil then
return
else
for k,v in string.gmatch(t[i],"(%w+)-(%w+)")do
return tonumber(k),tonumber(v)
end
end
end
end
end
local myid = redis.call(‘cluster’, ‘myid’)
local nodes = redis.call(‘cluster’, ‘nodes’)
local slotMin, slotMax = getSlotsMinAndMax (nodes,myid)
if slotMin == nil then
return
end
for i=1, 1000000 do
local key =’h’..i
local sv = redis.call (‘cluster’,’keyslot’,key)
if sv >= slotMin and sv <= slotMax then
redis.call(‘set’,key, ‘222’)
end
end