Class LuaScriptExecutor

java.lang.Object
com.reve.balancemanager.util.LuaScriptExecutor

public class LuaScriptExecutor extends Object
Contains the helper functions of the project to execute lua script
  • Constructor Details

    • LuaScriptExecutor

      public LuaScriptExecutor()
  • Method Details

    • loadLuaScript

      public static String loadLuaScript(String fileName)
      This is to load the lua script in our java program.
      Parameters:
      fileName - The file that will be loaded.
      Returns:
      A String which contains every line of the specified file.
    • execute

      public static String execute(String luaFileName, redis.clients.jedis.JedisCluster jedisCluster, String[] keys, String[] args)
      generic execute method that can evaluate given luaFile with its keys and args.
      Parameters:
      luaFileName - The lua script file to be executed
      jedisCluster - Redis cluster where the script is intended to be executed
      keys - given keys for script file
      args - given args for script file
      Returns:
    • incrementBalance

      public static String incrementBalance(redis.clients.jedis.JedisCluster jedisCluster, String leaseKey, String balanceField, String amount) throws Exception
      increment redis balance.
      Parameters:
      jedisCluster -
      leaseKey -
      balanceField -
      amount - would be negative to decrease redis balance.
      Returns:
      Throws:
      Exception
    • insertBMid

      public static String insertBMid(redis.clients.jedis.JedisCluster jedisCluster, String leaseKey, String bmIdField, String bmIdentifier) throws Exception
      insert bmId field into redis.
      Parameters:
      jedisCluster -
      leaseKey -
      bmIdField -
      bmIdentifier -
      Returns:
      Throws:
      Exception
    • removeBMid

      public static String removeBMid(redis.clients.jedis.JedisCluster jedisCluster, String leaseKey, String bmIdField, String bmIdentifier) throws Exception
      remove BMid field value.
      Parameters:
      jedisCluster -
      leaseKey -
      bmIdField -
      bmIdentifier -
      Returns:
      Throws:
      Exception