Share
Turbinando Microsserviços com Distributed Cache
Talk apresentada na #DevConf2023 em 27/05/2023
Talk apresentada no #SouJavaNaCampus em 27/07/2023 disponivel em: https://www.youtube.com/live/8qJqbrwtZr8?feature=share&t=61
Hoje é comum que boa parte das empresas estejam preocupadas em como aumentar o desempenho de seus serviços. Já que cada vez mais vivenciamos uma crescente demanda por featues que processam grande volume de dados ou exigem integração com diversos sistemas. Uma das abordagens mais comuns para aumento de performance é armazenar temporariamente informações que são utilizadas frequentemente em um servidor de cache local afim de acelerar o consumo das mesmas.
No entanto, o uso exclusivo de cache local pode levar a problemas como a inconsistência de dados quando trabalhamos em ambientes clusterizados, já que cada servidor não compartilham recursos entre-si. Então nesta talk iremos explorar como extrair o máximo das ferramentas de cachê distribuido e entender os tradeoffs de cada estratégia.
Jordi Henrique Silva
Transcript
230 slides
-
Como implementamos a consulta de formas de pagamento em comum
com Spring Boot? -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
SELECT f.* FROM usuario_forma_de_pagamento u INNER JOIN forma_de_pagamento f ON
f.id = u.forma_de_pagamento_id INNER JOIN restaurante_forma_de_pagamento r ON f.id = r.forma_de_pagamento_id WHERE u.usuario_id = :usuarioId AND r.restaurante_id = :restauranteId -
980.999.810-49 João Lucas 871.711.760-70 Maria Fernanda 549.254.550-79 Arthur Souza 682.248.740-95
Antonella Alves Chave Valor -
Database Servidor Heap Memory REQUEST SELECT e.* FROM Entity e
WHERE e.id=:id RESPONSE -
Database Servidor Heap Memory REQUEST RESPONSE SELECT e.* FROM Entity
e WHERE e.id=:id RESPONSE -
Database Servidor Heap Memory REQUEST SELECT e.* FROM Entity e
WHERE e.id=:id Local Caching -
Database Servidor Heap Memory REQUEST SELECT e.* FROM Entity e
WHERE e.id=:id RESPONSE Local Caching -
Database Servidor Heap Memory REQUEST SELECT e.* FROM Entity e
WHERE e.id=:id RESPONSE Local Caching -
Database Servidor Heap Memory REQUEST RESPONSE SELECT e.* FROM Entity
e WHERE e.id=:id RESPONSE Local Caching -
@EnableCaching @SpringBootApplication public class Application { public static void main(String[]
args) { SpringApplication.run(Application.class, args); } } -
@EnableCaching @SpringBootApplication public class Application { public static void main(String[]
args) { SpringApplication.run(Application.class, args); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
@RestController public class ConsultaFormasDePagamentoController { @Autowired private UsuarioRepository usuarioRepository; @Autowired
private RestauranteRepository restauranteRepository; @Autowired private FormaDePagamentoRepository formaDePagamentoRepository; @Transactional(readOnly = true) @GetMapping("/api/v1/formas-de-pagamento") public ResponseEntity<?> consultarFormasDePagamentoEmComum( @RequestParam(required = true) Long usuarioId, @RequestParam(required = true) Long restauranteId){ if (usuarioRepository.existsById(usuarioId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Usuario não cadastrado"); } if (restauranteRepository.existsById(restauranteId)) { throw new ResponseStatusException(UNPROCESSABLE_ENTITY, "Restaurante não cadastrado"); } var formasPagamentoComum = formaDePagamentoRepository.findFormaDePagamentoEmComumEntre(usuarioId, restauranteId) .stream() .map(FormaDePagamentoResponse::new) .toList(); return ResponseEntity.ok(formasPagamentoComum); } } -
public interface FormaDePagamentoRepository extends JpaRepository<FormaDePagamento, Long> { @Cacheable( value =
"forma_de_pagamento_entre", key = "T(java.util.Objects).hash(#usuarioId,#restauranteId)“ ) @Query(nativeQuery = true, value = """ SELECT f.* FROM usuario_forma_de_pagamentos u INNER JOIN forma_de_pagamento f ON f.id = u.forma_de_pagamentos_id INNER JOIN restaurante_forma_de_pagamentos r ON f.id = r.forma_de_pagamentos_id WHERE u.usuario_id = :usuarioId AND r.restaurante_id = :restauranteId """) List<FormaDePagamento> findFormaDePagamentoEmComumEntre(Long usuarioId, Long restauranteId); } -
public interface FormaDePagamentoRepository extends JpaRepository<FormaDePagamento, Long> { @Cacheable( value =
"forma_de_pagamento_entre", key = "T(java.util.Objects).hash(#usuarioId,#restauranteId)" ) @Query(nativeQuery = true, value = """ SELECT f.* FROM usuario_forma_de_pagamentos u INNER JOIN forma_de_pagamento f ON f.id = u.forma_de_pagamentos_id INNER JOIN restaurante_forma_de_pagamentos r ON f.id = r.forma_de_pagamentos_id WHERE u.usuario_id = :usuarioId AND r.restaurante_id = :restauranteId """) List<FormaDePagamento> findFormaDePagamentoEmComumEntre(Long usuarioId, Long restauranteId); } -
public interface FormaDePagamentoRepository extends JpaRepository<FormaDePagamento, Long> { @Cacheable( value =
"forma_de_pagamento_entre", key = "T(java.util.Objects).hash(#usuarioId,#restauranteId)" ) @Query(nativeQuery = true, value = """ SELECT f.* FROM usuario_forma_de_pagamentos u INNER JOIN forma_de_pagamento f ON f.id = u.forma_de_pagamentos_id INNER JOIN restaurante_forma_de_pagamentos r ON f.id = r.forma_de_pagamentos_id WHERE u.usuario_id = :usuarioId AND r.restaurante_id = :restauranteId """) List<FormaDePagamento> findFormaDePagamentoEmComumEntre(Long usuarioId, Long restauranteId); } -
public interface FormaDePagamentoRepository extends JpaRepository<FormaDePagamento, Long> { @Cacheable( value =
"forma_de_pagamento_entre", key = "T(java.util.Objects).hash(#usuarioId,#restauranteId)" ) @Query(nativeQuery = true, value = """ SELECT f.* FROM usuario_forma_de_pagamentos u INNER JOIN forma_de_pagamento f ON f.id = u.forma_de_pagamentos_id INNER JOIN restaurante_forma_de_pagamentos r ON f.id = r.forma_de_pagamentos_id WHERE u.usuario_id = :usuarioId AND r.restaurante_id = :restauranteId """) List<FormaDePagamento> findFormaDePagamentoEmComumEntre(Long usuarioId, Long restauranteId); } -
Cache João repository.findFormasPagamentoComumEn tre(1,1); null BD HTTP GET /formas-de- pagamento?usuarioId=1&restauranteId
=1 cache.get(formas-pagamento-1- 1) -
Cache João repository.findFormasPagamentoComumEn tre(1,1); null dados BD HTTP GET /formas-de-
pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) -
Cache João repository.findFormasPagamentoComumEn tre(1,1); null dados BD HTTP GET /formas-de-
pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) cache.put(formas-pagamento-1- 1,dados) -
Cache João repository.findFormasPagamentoComumEn tre(1,1); null dados BD HTTP GET /formas-de-
pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) cache.put(formas-pagamento-1- 1,dados) dados -
Cache João repository.findFormasPagamentoComumEn tre(1,1); null dados BD HTTP GET /formas-de-
pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) cache.put(formas-pagamento-1- 1,dados) dados dados -
Cache Miss Cache João repository.findFormasPagamentoComumEn tre(1,1); null dados BD HTTP
GET /formas-de- pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) cache.put(formas-pagamento-1- 1,dados) dados dados -
Cache Miss Cache João repository.findFormasPagamentoComumEn tre(1,1); null dados BD HTTP
GET /formas-de- pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) cache.put(formas-pagamento-1- 1,dados) dados HTTP GET /formas-de- pagamento?usuarioId=1&restauranteId =1 dados -
Cache Miss Cache João repository.findFormasPagamentoComumEn tre(1,1); null dados BD HTTP
GET /formas-de- pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) cache.put(formas-pagamento-1- 1,dados) dados HTTP GET /formas-de- pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) dados -
Cache Miss Cache João repository.findFormasPagamentoComumEn tre(1,1); null dados BD HTTP
GET /formas-de- pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) cache.put(formas-pagamento-1- 1,dados) dados HTTP GET /formas-de- pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) dados dados -
Cache Miss Cache João repository.findFormasPagamentoComumEn tre(1,1); null dados BD HTTP
GET /formas-de- pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) cache.put(formas-pagamento-1- 1,dados) dados HTTP GET /formas-de- pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) dados dados dados -
Cache Hit Cache Miss Cache João repository.findFormasPagamentoComumEn tre(1,1); null dados
BD HTTP GET /formas-de- pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) cache.put(formas-pagamento-1- 1,dados) dados HTTP GET /formas-de- pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1) dados dados dados -
spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre caffeine.spec:
maximumSize = 100000, expireAfterWrite = 4h application.yaml -
spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre caffeine.spec:
maximumSize = 100000, expireAfterWrite = 4h application.yaml -
spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre caffeine.spec:
maximumSize = 100000, expireAfterWrite = 4h application.yaml -
spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre caffeine.spec:
maximumSize = 100000, expireAfterWrite = 4h application.yaml -
spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre caffeine.spec:
maximumSize = 100000, expireAfterWrite = 4h application.yaml -
Servidor B Servidor A repository.findFormasPagamentoComumEntre(1,1) dados repository.findFormasPagamentoComumEntre(1,1) dados repository.addFormaDePagamentoParaUsuadrio(1,6) 1
ROW Insert Cache.put(key,dados) Cache.put(key,dados) -
Servidor B Servidor A repository.findFormasPagamentoComumEntre(1,1) dados repository.findFormasPagamentoComumEntre(1,1) dados repository.addFormaDePagamentoParaUsuadrio(1,6) 1
ROW Insert Cache.put(key,dados) Cache.put(key,dados) -
Servidor B Servidor A repository.findFormasPagamentoComumEntre(1,1) dados repository.findFormasPagamentoComumEntre(1,1) dados repository.addFormaDePagamentoParaUsuadrio(1,6) 1
ROW Insert Cache.put(key,dados) Cache.put(key,dados) -
spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre caffeine.spec:
maximumSize = 100000, expireAfterWrite = 4h application.yaml -
spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre type:
redis application.yaml -
@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() {
return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } } -
@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() {
return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } } -
@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() {
return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } } -
@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() {
return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } } -
@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() {
return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } } -
@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() {
return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } } -
@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() {
return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } } -
@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() {
return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } } -
null BD cache.put(formas-pagamento- 1-1,dados) dados cache.get(formas-pagamento-1-1) Servidor A Servidor B
repository.findFormasPagamentoComum Entre(1,1) Cache -
Cache Miss null BD cache.put(formas-pagamento- 1-1,dados) dados cache.get(formas-pagamento-1-1) Servidor A
Servidor B repository.findFormasPagamentoComum Entre(1,1) Cache -
Cache Miss null BD cache.put(formas-pagamento- 1-1,dados) dados cache.get(formas-pagamento-1-1) Servidor A
Servidor B repository.findFormasPagamentoComum Entre(1,1) cache.get(formas-pagamento-1-1) Cache -
Cache Miss null BD cache.put(formas-pagamento- 1-1,dados) dados cache.get(formas-pagamento-1-1) dados Servidor
A Servidor B repository.findFormasPagamentoComum Entre(1,1) cache.get(formas-pagamento-1-1) Cache -
Cache Hit Cache Miss null BD cache.put(formas-pagamento- 1-1,dados) dados cache.get(formas-pagamento-1-1)
dados Servidor A Servidor B repository.findFormasPagamentoComum Entre(1,1) cache.get(formas-pagamento-1-1) Cache -
Servidor A Servidor B Servidor E Servidor C Servidor F
Servidor D Cluster Database -
Servidor A Servidor B Servidor E Servidor C Servidor F
Servidor D Cluster Database -
Servidor A Servidor B Servidor E Servidor C Servidor F
Servidor D Cluster Database -
Servidor A Servidor B Servidor E Servidor C Servidor F
Servidor D Cluster Database -
Servidor A Servidor B Servidor E Servidor C Servidor F
Servidor D Cluster Database -
Servidor A Servidor B Servidor E Servidor C Servidor F
Servidor D Cluster Database -
Database Servidor Heap Memory Local Hazel Cache Servidor Heap Memory
Local Hazel Cache Servidor Heap Memory Local Hazel Cache CLUSTER SERVER -
cache: name: forma_de_pagamento_entre spring: ## # Spring Caching ## cache:
cache-names: forma_de_pagamento_entre type: redis application.yaml -
cache: name: forma_de_pagamento_entre spring: ## # demais configurações omitidas ##
cache: cache-names: forma_de_pagamento_entre type: redis application.yaml -
cache: name: forma_de_pagamento_entre spring: ## # demais configurações omitidas ##
cache: cache-names: forma_de_pagamento_entre type: redis application.yaml -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
@Configuration public class HazelCastCacheConfig { @Value("${cache.name}") private String cacheName; private
final int FOUR_HOURS = 14400;// 4 horas @Bean ClientConfig config() { ClientConfig clientConfig = new ClientConfig(); clientConfig.addNearCacheConfig(nearCacheConfig()); return clientConfig; } private NearCacheConfig nearCacheConfig() { NearCacheConfig nearCacheConfig = new NearCacheConfig(); nearCacheConfig.setName(cacheName); nearCacheConfig.setTimeToLiveSeconds(FOUR_HOURS); // 4 horas return nearCacheConfig; } } -
null BD dados cache.get(formas-pagamento-1-1) Servidor Local HazelCache repository.findFormasPagamentoComum Entre(1,1) Cache
cache.get(formas-pagamento-1-1) null -
null BD cache.put(formas-pagamento- 1-1,dados) dados cache.get(formas-pagamento-1-1) Servidor Local HazelCache repository.findFormasPagamentoComum
Entre(1,1) Cache cache.get(formas-pagamento-1-1) null -
null BD cache.put(formas-pagamento- 1-1,dados) dados cache.get(formas-pagamento-1-1) Servidor Local HazelCache repository.findFormasPagamentoComum
Entre(1,1) Cache cache.get(formas-pagamento-1-1) null cache.put(formas-pagamento-1- 1,dados) -
Servidor A Servidor B Servidor E Servidor C Servidor F
Servidor D Cluster Database -
Servidor A Servidor B Servidor E Servidor C Servidor F
Servidor D Cluster Database