• redis脚本


    string lua = @"local counts=redis.call('HLEN',@yhKey) 
    if tonumber(counts)>=tonumber(@places) then
     return 2 
    elseif redis.call('HEXISTS',@yhKey,@bankCard)==1 then
     return 3 
    elseif redis.call('EXISTS',@phone)==1 then
     return 4 
    elseif redis.call('EXISTS',@card)==1 then
     return 5 
    else
     redis.call('SELECT',8)
     local waits=redis.call('DBSIZE')
     if tonumber(counts)+tonumber(waits)<tonumber(@places) then
      redis.call('SETEX',@order,@expiry,@payEnti)
      redis.call('SELECT',7)
      redis.call('SETEX',@phone,@expiry,@payUrl)
      redis.call('SETEX',@card,@expiry,@bankCard)
      return 1 
     else
      return 6
     end 
    end";
    string rr = cache.Do(db => db.ScriptEvaluate(LuaScript.Prepare(lua), new
                        {
                            yhKey = "HROKBank",
                            places = conf.HuaRongPlaces,//名额
                            bankCard = bankCard,
                            card = "HRBank:" + bankCard,
                            phone = "HRPhone:" + user.phoneNo,
                            order = "HROrder:" + OrderNo,
                            expiry = conf.PayTime * 60,//过期时间单位为秒
                            payEnti = JsonConvert.SerializeObject(m),
                            // OrderNo= OrderNo,
                            payUrl = payUrl
                        })).ToString();
  • 相关阅读:
    OpenCV 3.4.0 + Visual Studio 2015开发环境的配置(Windows 10 X64)
    数值分析4
    数值分析3
    数值分析2
    数值分析1
    绪论0.4
    绪论0.3
    绪论0.2
    绪论0.1
    GitHub之起势
  • 原文地址:https://www.cnblogs.com/hllive/p/9446849.html
Copyright © 2020-2023  润新知