Blame view

src/rdsscripts/insertEmail.lua 1.09 KB
314bc5df   zhengshouren   提交服务器初始代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  local con1 = KEYS[4] or ""
  local con2 = KEYS[5] or ""
  local con3 = KEYS[6] or ""
  local att1 = KEYS[7] or ""
  local att2 = KEYS[8] or ""
  local att3 = KEYS[9] or ""
  local title = KEYS[10] or ""
  local content = KEYS[11] or ""
  local attachments = KEYS[12] or ""
  
  -- local roleInfo = redis.call("HGET", string.format("role:%d", KEYS[1]), "delete")
  
  -- if tonumber(roleInfo) == 1 then return end
  
  local id = redis.call("HINCRBY", string.format("role:%d:autoincr", KEYS[1]), "email", 1)
  redis.call("LPUSH", string.format("role:%d:emailIds", KEYS[1]), id)
  local deleteIds = redis.call("LRANGE", string.format("role:%d:emailIds", KEYS[1]), 50, -1)
  for _, deleteId in ipairs(deleteIds) do
  	redis.call("DEL", string.format("email:%d:%d", KEYS[1], deleteId))
  end
  
  redis.call("LTRIM", string.format("role:%d:emailIds", KEYS[1]), 0, 49)
  redis.call("HMSET", string.format("email:%d:%d", KEYS[1], id), "id", tostring(id), "emailId", KEYS[2],
  	"status", "0", "createtime", KEYS[3],
  	"con1", con1, "con2", con2, "con3", con3,
  	"att1", att1, "att2", att2, "att3", att3, 
  	"title", title, "content", content, "attachments", attachments)