Fix formatting

This commit is contained in:
Michael Pratt 2020-06-13 12:33:48 -06:00
parent 52bd7fb2b6
commit f06b1f6296
3 changed files with 7 additions and 14 deletions

View File

@ -13,14 +13,12 @@ public class AddressController
private AddressService addressService;
@GetMapping("/address/{id}")
public ResponseEntity<String> getAddress(@PathVariable("id") long customerId)
{
public ResponseEntity<String> getAddress(@PathVariable("id") long customerId) {
return ResponseEntity.ok(addressService.getAddress(customerId));
}
@GetMapping("/address2/{id}")
public ResponseEntity<String> getAddress2(@PathVariable("id") long customerId)
{
public ResponseEntity<String> getAddress2(@PathVariable("id") long customerId) {
return ResponseEntity.ok(addressService.getAddress2(customerId));
}
}

View File

@ -19,17 +19,14 @@ public class AddressService
private CacheManager cacheManager;
@Cacheable(cacheNames = "addresses")
public String getAddress(long customerId)
{
public String getAddress(long customerId) {
LOG.info("Method getAddress is invoked for customer {}", customerId);
return "123 Main St";
}
public String getAddress2(long customerId)
{
if(cacheManager.getCache("addresses2").get(customerId) != null)
{
public String getAddress2(long customerId) {
if(cacheManager.getCache("addresses2").get(customerId) != null) {
return cacheManager.getCache("addresses2").get(customerId).get().toString();
}

View File

@ -13,15 +13,13 @@ import java.util.concurrent.TimeUnit;
@Configuration
public class CaffeineConfiguration {
@Bean
public Caffeine caffeineConfig()
{
public Caffeine caffeineConfig() {
return Caffeine.newBuilder()
.expireAfterWrite(60, TimeUnit.MINUTES);
}
@Bean
public CacheManager cacheManager(Caffeine caffeine)
{
public CacheManager cacheManager(Caffeine caffeine) {
CaffeineCacheManager caffeineCacheManager = new CaffeineCacheManager();
caffeineCacheManager.getCache("addresses");
caffeineCacheManager.setCaffeine(caffeine);