diff --git a/src/main/java/ee/bitweb/transactions/domain/account/common/AccountCache.java b/src/main/java/ee/bitweb/transactions/domain/account/common/AccountCache.java index c2ddda9..f3f2fac 100644 --- a/src/main/java/ee/bitweb/transactions/domain/account/common/AccountCache.java +++ b/src/main/java/ee/bitweb/transactions/domain/account/common/AccountCache.java @@ -20,6 +20,7 @@ public class AccountCache { // Personcode, List of accounts HashMap> registry = new HashMap<>(); + String[] keys; public void load() { List accounts = accountRepository.findAll(); @@ -30,6 +31,8 @@ public void load() { registry.get(account.getOwner()).add(account); } + + keys = registry.keySet().toArray(new String[0]); } public Account getRandomForPerson(String personCode) { @@ -42,7 +45,6 @@ public Account getRandomForPerson(String personCode) { } public Account getRandom() { - String[] keys = registry.keySet().toArray(new String[0]); String randomKey = keys[random.nextInt(keys.length)]; return getRandomForPerson(randomKey);