Fix formatting
This commit is contained in:
parent
52bd7fb2b6
commit
f06b1f6296
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue