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; private AddressService addressService;
@GetMapping("/address/{id}") @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)); return ResponseEntity.ok(addressService.getAddress(customerId));
} }
@GetMapping("/address2/{id}") @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)); return ResponseEntity.ok(addressService.getAddress2(customerId));
} }
} }

View File

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

View File

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