Package com.reve.balancemanager.db
Class BalanceTable
java.lang.Object
com.reve.balancemanager.db.BalanceTable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet all the account id fromCLIENT_BALANCE_TABLEwhich are active.static doublegetMysqlBalance(long accountId) If the given accountId is not present in redis then it will be loaded from mysql database and be saved in redis cluster.static voidloadMysqlBalance(Map<Long, Double> balanceMap) Load the full list of client and their balance from mysqlCLIENT_BALANCE_TABLEtable into the given map.static booleansetMysqlBalance(long accountId, double balance, double credit) If the given accountId is not present in redis then it will be loaded from mysql database and be saved in redis cluster.
-
Field Details
-
CLIENT_BALANCE_TABLE
MySQL table name where balance information can be found- See Also:
-
BALANCE_FIELD
Redis cluster balance field constant key.- See Also:
-
-
Constructor Details
-
BalanceTable
public BalanceTable()
-
-
Method Details
-
getMysqlBalance
public static double getMysqlBalance(long accountId) If the given accountId is not present in redis then it will be loaded from mysql database and be saved in redis cluster.- Parameters:
accountId- Account ID for which balance information will be loaded into redis.- Returns:
- Total available balance in mysql that can be used in calling or other purpose. = (cbBalance + cbCreditLimit - cbThresholdAmount)
-
setMysqlBalance
public static boolean setMysqlBalance(long accountId, double balance, double credit) If the given accountId is not present in redis then it will be loaded from mysql database and be saved in redis cluster.- Parameters:
accountId- Account ID for which balance information will be loaded into redis.balance- Amount to be set inBALANCE_FIELDinCLIENT_BALANCE_TABLEtablecredit- Amount to be set inCREDIT_FIELDinCLIENT_BALANCE_TABLEtable- Returns:
- Total available balance in mysql that can be used in calling or other purpose. = (cbBalance + cbCreditLimit - cbThresholdAmount)
-
loadMysqlBalance
Load the full list of client and their balance from mysqlCLIENT_BALANCE_TABLEtable into the given map.- Parameters:
balanceMap- ClientID vs usable balance map, which will be updated according toCLIENT_BALANCE_TABLE
-
getAllAccounts
Get all the account id fromCLIENT_BALANCE_TABLEwhich are active.- Returns:
- the list of account id
-