mhgetuser.lua 780 B

123456789101112131415161718192021
  1. local result={}
  2. result.items={}
  3. result.loseItems={}
  4. local k1=KEYS[1] --未格式化key user:%d:info
  5. local k2=KEYS[2] --过期时间
  6. local lose={}
  7. for i = 1, #ARGV do
  8. local k=string.format(k1,ARGV[i])
  9. local v1=redis.call('expire',k,k2)
  10. if v1==0 then
  11. table.insert(result.items,{})
  12. lose[ARGV[i]]=i-1;
  13. else
  14. local info=hgetall(k)
  15. table.insert(result.items,info)
  16. -- local info=redis.call('hmget',k,'uid','nickname','bodytype','face','threads','posts','friends','fans','tfavtimes')
  17. -- table.insert(result.items,{['uid']=info[1],['nickname']=info[2],['bodytype']=info[3],['face']=info[4],['threads']=info[5],['posts']=info[6],['friends']=info[7],['fans']=info[8],['tfavtimes']=info[9]})
  18. end
  19. end
  20. result.loseItems=lose
  21. return cjson.encode(result)