If I have a MySQL table that is not changed very often (once a month) which contains information such as active user accounts for a web service. How safe is it to do something like:
public AccountDao
{
List<Account> accounts;
/*fields*/
public AccountDao()
{
refreshAccounts();
}
public void refreshAccounts()
{
this.accounts = /*call to database to get list of accounts*/
}
public boolean isActiveAccount(String accountId)
{
//logic involving in memory list object above
}
}
I would do this because I have to check a user has an active account for every request to allow access to the web service. This would allow me to avoid one SQL call to the database layer (which is stressed at the moment) on every request. My question is how safe is it to store data like this in production?
By the way, I would refresh the account list whenever a new user account is added via an API call. As stated above, this would happen about once to twice a month.