dong320

        // Redis中使用Lua脚本校验并减扣库存
        StringBuilder script = new StringBuilder();
        script.append("if (redis.call(\'EXISTS\', KEYS[1]) == 1) then");
        script.append("   if (redis.call(\'GET\', KEYS[1]) - ARGV[1] >=0) then");
        script.append("       redis.call(\'DECRBY\', KEYS[1], ARGV[1]);");
        script.append("       return 1");
        script.append("   else");
        script.append("       return -1;");
        script.append("   end;");
        script.append("end;");
        script.append("return -2;");

 

分类:

技术点:

相关文章:

猜你喜欢
相关资源
相似解决方案