-
-
Save pmuir/3c553ceef722c2e21c0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ApplicationScoped | |
public class CountryService { | |
private @Inject Cache<String, Country> cache; | |
private @Inject Self<CountryService> self; | |
public Country getByIsoA3(String isoA3) { | |
Country ctry = cache.get(isoA3); | |
if (ctry == null) { | |
ctry = self.get().fillCacheFromDb(isoA3); | |
} | |
return ctry; | |
} | |
@Transactional | |
Country fillCacheFromDb(String isoA3) { | |
transactionally load from db... | |
and fill cache | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment