Slide 1

Slide 1 text

Turbinando Microsserviços com Distributed Cache

Slide 2

Slide 2 text

Qual papel da Tecnologia no Negócio?

Slide 3

Slide 3 text

Automatizar o processo operacional?

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Gerir os dados e oferecer inteligência no processo de decisão?

Slide 6

Slide 6 text

Auxiliar o processo de crescimento do negócio

Slide 7

Slide 7 text

O meu pedido já chegou?

Slide 8

Slide 8 text

RESTAURANTE MENU

Slide 9

Slide 9 text

RESTAURANTE MENU R$ 30.00

Slide 10

Slide 10 text

RESTAURANTE MENU R$ 30.00 R$ 45.99

Slide 11

Slide 11 text

RESTAURANTE MENU R$ 30.00 R$ 45.99 R$ 27.50

Slide 12

Slide 12 text

RESTAURANTE MENU R$ 30.00 R$ 45.99 R$ 27.50 R$ 65.98

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Formas de Pagamento

Slide 20

Slide 20 text

Formas de Pagamento

Slide 21

Slide 21 text

Formas de Pagamento

Slide 22

Slide 22 text

Formas de Pagamento

Slide 23

Slide 23 text

Como implementamos a consulta de formas de pagamento em comum com Spring Boot?

Slide 24

Slide 24 text

@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); } }

Slide 25

Slide 25 text

@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); } }

Slide 26

Slide 26 text

@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); } }

Slide 27

Slide 27 text

@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); } }

Slide 28

Slide 28 text

@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); } }

Slide 29

Slide 29 text

@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); } }

Slide 30

Slide 30 text

@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); } }

Slide 31

Slide 31 text

@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); } }

Slide 32

Slide 32 text

@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); } }

Slide 33

Slide 33 text

@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); } }

Slide 34

Slide 34 text

@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); } }

Slide 35

Slide 35 text

@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); } }

Slide 36

Slide 36 text

@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); } }

Slide 37

Slide 37 text

@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); } }

Slide 38

Slide 38 text

@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); } }

Slide 39

Slide 39 text

@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); } }

Slide 40

Slide 40 text

@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); } }

Slide 41

Slide 41 text

@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); } }

Slide 42

Slide 42 text

@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); } }

Slide 43

Slide 43 text

@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); } }

Slide 44

Slide 44 text

@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); } }

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

Database

Slide 52

Slide 52 text

Database

Slide 53

Slide 53 text

Database

Slide 54

Slide 54 text

Aumento no tempo de resposta

Slide 55

Slide 55 text

O que é Caching?

Slide 56

Slide 56 text

980.999.810-49 João Lucas Chave Valor

Slide 57

Slide 57 text

980.999.810-49 João Lucas 871.711.760-70 Maria Fernanda Chave Valor

Slide 58

Slide 58 text

980.999.810-49 João Lucas 871.711.760-70 Maria Fernanda 549.254.550-79 Arthur Souza Chave Valor

Slide 59

Slide 59 text

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

Slide 60

Slide 60 text

Como Implementar a camada de cache em Aplicações Spring Boot?

Slide 61

Slide 61 text

Criamos um CacheService? p/ gerenciar um HashMap

Slide 62

Slide 62 text

E os acessos de simultâneos?

Slide 63

Slide 63 text

ConcurrentHashMap

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

Servidor Heap Memory

Slide 66

Slide 66 text

Database Servidor Heap Memory

Slide 67

Slide 67 text

Database Servidor Heap Memory REQUEST

Slide 68

Slide 68 text

Database Servidor Heap Memory REQUEST SELECT e.* FROM Entity e WHERE e.id=:id

Slide 69

Slide 69 text

Database Servidor Heap Memory REQUEST SELECT e.* FROM Entity e WHERE e.id=:id RESPONSE

Slide 70

Slide 70 text

Database Servidor Heap Memory REQUEST RESPONSE SELECT e.* FROM Entity e WHERE e.id=:id RESPONSE

Slide 71

Slide 71 text

Depois...

Slide 72

Slide 72 text

Database Servidor Heap Memory

Slide 73

Slide 73 text

Database Servidor Heap Memory Local Caching

Slide 74

Slide 74 text

Database Servidor Heap Memory REQUEST Local Caching

Slide 75

Slide 75 text

Database Servidor Heap Memory REQUEST SELECT e.* FROM Entity e WHERE e.id=:id Local Caching

Slide 76

Slide 76 text

Database Servidor Heap Memory REQUEST SELECT e.* FROM Entity e WHERE e.id=:id RESPONSE Local Caching

Slide 77

Slide 77 text

Database Servidor Heap Memory REQUEST SELECT e.* FROM Entity e WHERE e.id=:id RESPONSE Local Caching

Slide 78

Slide 78 text

Database Servidor Heap Memory REQUEST RESPONSE SELECT e.* FROM Entity e WHERE e.id=:id RESPONSE Local Caching

Slide 79

Slide 79 text

Database Servidor Heap Memory Local Caching

Slide 80

Slide 80 text

Database Servidor Heap Memory REQUEST Local Caching

Slide 81

Slide 81 text

Database Servidor Heap Memory REQUEST Local Caching Cache.get(key)

Slide 82

Slide 82 text

Database Servidor Heap Memory REQUEST RESPONSE Local Caching Cache.get(key)

Slide 83

Slide 83 text

Existe uma forma mais elegante?

Slide 84

Slide 84 text

Spring Caching

Slide 85

Slide 85 text

@EnableCaching @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }

Slide 86

Slide 86 text

@EnableCaching @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }

Slide 87

Slide 87 text

@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); } }

Slide 88

Slide 88 text

@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); } }

Slide 89

Slide 89 text

public interface FormaDePagamentoRepository extends JpaRepository { @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 findFormaDePagamentoEmComumEntre(Long usuarioId, Long restauranteId); }

Slide 90

Slide 90 text

public interface FormaDePagamentoRepository extends JpaRepository { @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 findFormaDePagamentoEmComumEntre(Long usuarioId, Long restauranteId); }

Slide 91

Slide 91 text

public interface FormaDePagamentoRepository extends JpaRepository { @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 findFormaDePagamentoEmComumEntre(Long usuarioId, Long restauranteId); }

Slide 92

Slide 92 text

public interface FormaDePagamentoRepository extends JpaRepository { @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 findFormaDePagamentoEmComumEntre(Long usuarioId, Long restauranteId); }

Slide 93

Slide 93 text

Como o servidor se comporta com Caching Local?

Slide 94

Slide 94 text

Cache João BD

Slide 95

Slide 95 text

Cache João BD HTTP GET /formas-de- pagamento?usuarioId=1&restauranteId =1

Slide 96

Slide 96 text

Cache João BD HTTP GET /formas-de- pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1)

Slide 97

Slide 97 text

Cache João null BD HTTP GET /formas-de- pagamento?usuarioId=1&restauranteId =1 cache.get(formas-pagamento-1- 1)

Slide 98

Slide 98 text

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)

Slide 99

Slide 99 text

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)

Slide 100

Slide 100 text

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)

Slide 101

Slide 101 text

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

Slide 102

Slide 102 text

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

Slide 103

Slide 103 text

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

Slide 104

Slide 104 text

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

Slide 105

Slide 105 text

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

Slide 106

Slide 106 text

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

Slide 107

Slide 107 text

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

Slide 108

Slide 108 text

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

Slide 109

Slide 109 text

E...

Slide 110

Slide 110 text

Como o servidor se comporta com aumento de acessos simultâneos?

Slide 111

Slide 111 text

Servidor Local Caching Heap Memory Database REQUEST RESPONSE

Slide 112

Slide 112 text

Servidor Local Caching Heap Memory Database REQUEST RESPONSE

Slide 113

Slide 113 text

Servidor Local Caching Heap Memory Database REQUEST RESPONSE

Slide 114

Slide 114 text

Servidor Local Caching Heap Memory Database REQUEST RESPONSE

Slide 115

Slide 115 text

Servidor Local Caching Heap Memory Database REQUEST RESPONSE

Slide 116

Slide 116 text

Database REQUEST RESPONSE Servidor Local Caching Heap Memory

Slide 117

Slide 117 text

Servidor Local Caching Heap Memory Database REQUEST RESPONSE

Slide 118

Slide 118 text

No content

Slide 119

Slide 119 text

No content

Slide 120

Slide 120 text

Turbinando Microsserviços com Distributed Cache

Slide 121

Slide 121 text

NÃO POSSUI POLÍTICA DE INVALIDAÇÃO

Slide 122

Slide 122 text

EHCache, Guava e Caffeine

Slide 123

Slide 123 text

spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre caffeine.spec: maximumSize = 100000, expireAfterWrite = 4h application.yaml

Slide 124

Slide 124 text

spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre caffeine.spec: maximumSize = 100000, expireAfterWrite = 4h application.yaml

Slide 125

Slide 125 text

spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre caffeine.spec: maximumSize = 100000, expireAfterWrite = 4h application.yaml

Slide 126

Slide 126 text

spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre caffeine.spec: maximumSize = 100000, expireAfterWrite = 4h application.yaml

Slide 127

Slide 127 text

spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre caffeine.spec: maximumSize = 100000, expireAfterWrite = 4h application.yaml

Slide 128

Slide 128 text

Time To Live (TTL)

Slide 129

Slide 129 text

Servidor Heap Memory Local Caching Time to live (TTL) 0 min

Slide 130

Slide 130 text

Servidor Heap Memory Local Caching Time to live (TTL) 20 min

Slide 131

Slide 131 text

Servidor Heap Memory Local Caching Time to live (TTL) 40 min

Slide 132

Slide 132 text

Servidor Heap Memory Local Caching Time to live (TTL) 1h 00 min

Slide 133

Slide 133 text

Servidor Heap Memory Local Caching Time to live (TTL) 1h 20 min

Slide 134

Slide 134 text

Servidor Heap Memory Local Caching Time to live (TTL) 1h 40 min

Slide 135

Slide 135 text

Servidor Heap Memory Local Caching Time to live (TTL) 2h 00 min

Slide 136

Slide 136 text

Servidor Heap Memory Local Caching Time to live (TTL) 2h 20 min

Slide 137

Slide 137 text

Servidor Heap Memory Local Caching Time to live (TTL) 2h 40 min

Slide 138

Slide 138 text

Servidor Heap Memory Local Caching Time to live (TTL) 3h 00 min

Slide 139

Slide 139 text

Servidor Heap Memory Local Caching Time to live (TTL) 3h 20 min

Slide 140

Slide 140 text

Servidor Heap Memory Local Caching Time to live (TTL) 3h 40 min

Slide 141

Slide 141 text

Servidor Heap Memory Local Caching Time to live (TTL) 4h 00 min

Slide 142

Slide 142 text

Servidor Heap Memory Local Caching Time to live (TTL)

Slide 143

Slide 143 text

E Se?

Slide 144

Slide 144 text

No content

Slide 145

Slide 145 text

No content

Slide 146

Slide 146 text

Como funciona em Ambientes Clusterizados?

Slide 147

Slide 147 text

Servidor B Servidor A

Slide 148

Slide 148 text

Servidor B Servidor A repository.findFormasPagamentoComumEntre(1,1)

Slide 149

Slide 149 text

Servidor B Servidor A repository.findFormasPagamentoComumEntre(1,1) dados

Slide 150

Slide 150 text

Servidor B Servidor A repository.findFormasPagamentoComumEntre(1,1) dados Cache.put(key,dados)

Slide 151

Slide 151 text

Servidor B Servidor A repository.findFormasPagamentoComumEntre(1,1) dados repository.findFormasPagamentoComumEntre(1,1) Cache.put(key,dados)

Slide 152

Slide 152 text

Servidor B Servidor A repository.findFormasPagamentoComumEntre(1,1) dados repository.findFormasPagamentoComumEntre(1,1) dados Cache.put(key,dados)

Slide 153

Slide 153 text

Servidor B Servidor A repository.findFormasPagamentoComumEntre(1,1) dados repository.findFormasPagamentoComumEntre(1,1) dados repository.addFormaDePagamentoParaUsuadrio(1,6) Cache.put(key,dados)

Slide 154

Slide 154 text

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)

Slide 155

Slide 155 text

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)

Slide 156

Slide 156 text

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)

Slide 157

Slide 157 text

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)

Slide 158

Slide 158 text

Cache Distribuído

Slide 159

Slide 159 text

No content

Slide 160

Slide 160 text

spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre caffeine.spec: maximumSize = 100000, expireAfterWrite = 4h application.yaml

Slide 161

Slide 161 text

spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre type: redis application.yaml

Slide 162

Slide 162 text

Configurar as Politicas do Redis

Slide 163

Slide 163 text

@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() { return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } }

Slide 164

Slide 164 text

@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() { return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } }

Slide 165

Slide 165 text

@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() { return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } }

Slide 166

Slide 166 text

@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() { return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } }

Slide 167

Slide 167 text

@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() { return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } }

Slide 168

Slide 168 text

@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() { return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } }

Slide 169

Slide 169 text

@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() { return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } }

Slide 170

Slide 170 text

@Configuration public class RedisCacheConfig { @Bean public RedisCacheConfiguration defaultCacheConfiguration() { return RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofHours(4))// 4 horas .disableCachingNullValues() .serializeValuesWith(fromSerializer(new GenericJackson2JsonRedisSerializer())); } }

Slide 171

Slide 171 text

BD Servidor A Servidor B Cache

Slide 172

Slide 172 text

BD cache.get(formas-pagamento-1-1) Servidor A Servidor B Cache

Slide 173

Slide 173 text

null BD cache.get(formas-pagamento-1-1) Servidor A Servidor B Cache

Slide 174

Slide 174 text

null BD cache.get(formas-pagamento-1-1) Servidor A Servidor B repository.findFormasPagamentoComum Entre(1,1) Cache

Slide 175

Slide 175 text

null BD dados cache.get(formas-pagamento-1-1) Servidor A Servidor B repository.findFormasPagamentoComum Entre(1,1) Cache

Slide 176

Slide 176 text

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

Slide 177

Slide 177 text

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

Slide 178

Slide 178 text

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

Slide 179

Slide 179 text

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

Slide 180

Slide 180 text

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

Slide 181

Slide 181 text

Servidor A Servidor B Servidor E Servidor C Servidor F Servidor D Cluster Database

Slide 182

Slide 182 text

Servidor A Servidor B Servidor E Servidor C Servidor F Servidor D Cluster Database

Slide 183

Slide 183 text

Servidor A Servidor B Servidor E Servidor C Servidor F Servidor D Cluster Database

Slide 184

Slide 184 text

Servidor A Servidor B Servidor E Servidor C Servidor F Servidor D Cluster Database

Slide 185

Slide 185 text

Servidor A Servidor B Servidor E Servidor C Servidor F Servidor D Cluster Database

Slide 186

Slide 186 text

Servidor A Servidor B Servidor E Servidor C Servidor F Servidor D Cluster Database

Slide 187

Slide 187 text

No content

Slide 188

Slide 188 text

E...

Slide 189

Slide 189 text

Se for possível cachear pequena parte dos dados quentes?

Slide 190

Slide 190 text

Como continuar escalando?

Slide 191

Slide 191 text

Near Cache

Slide 192

Slide 192 text

Database Servidor Heap Memory Servidor Heap Memory Servidor Heap Memory CLUSTER SERVER

Slide 193

Slide 193 text

Database Servidor Heap Memory Servidor Heap Memory Servidor Heap Memory CLUSTER SERVER

Slide 194

Slide 194 text

Database Servidor Heap Memory Local Hazel Cache Servidor Heap Memory Local Hazel Cache Servidor Heap Memory Local Hazel Cache CLUSTER SERVER

Slide 195

Slide 195 text

cache: name: forma_de_pagamento_entre spring: ## # Spring Caching ## cache: cache-names: forma_de_pagamento_entre type: redis application.yaml

Slide 196

Slide 196 text

cache: name: forma_de_pagamento_entre spring: ## # demais configurações omitidas ## cache: cache-names: forma_de_pagamento_entre type: redis application.yaml

Slide 197

Slide 197 text

cache: name: forma_de_pagamento_entre spring: ## # demais configurações omitidas ## cache: cache-names: forma_de_pagamento_entre type: redis application.yaml

Slide 198

Slide 198 text

Habilitando o Near Cache

Slide 199

Slide 199 text

@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; } }

Slide 200

Slide 200 text

@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; } }

Slide 201

Slide 201 text

@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; } }

Slide 202

Slide 202 text

@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; } }

Slide 203

Slide 203 text

@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; } }

Slide 204

Slide 204 text

@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; } }

Slide 205

Slide 205 text

@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; } }

Slide 206

Slide 206 text

@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; } }

Slide 207

Slide 207 text

@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; } }

Slide 208

Slide 208 text

@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; } }

Slide 209

Slide 209 text

@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; } }

Slide 210

Slide 210 text

@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; } }

Slide 211

Slide 211 text

@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; } }

Slide 212

Slide 212 text

@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; } }

Slide 213

Slide 213 text

@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; } }

Slide 214

Slide 214 text

BD Servidor Local HazelCache Cache

Slide 215

Slide 215 text

BD Servidor Local HazelCache Cache cache.get(formas-pagamento-1-1)

Slide 216

Slide 216 text

BD Servidor Local HazelCache Cache cache.get(formas-pagamento-1-1) null

Slide 217

Slide 217 text

BD cache.get(formas-pagamento-1-1) Servidor Local HazelCache Cache cache.get(formas-pagamento-1-1) null

Slide 218

Slide 218 text

null BD cache.get(formas-pagamento-1-1) Servidor Local HazelCache Cache cache.get(formas-pagamento-1-1) null

Slide 219

Slide 219 text

null BD cache.get(formas-pagamento-1-1) Servidor Local HazelCache repository.findFormasPagamentoComum Entre(1,1) Cache cache.get(formas-pagamento-1-1) null

Slide 220

Slide 220 text

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

Slide 221

Slide 221 text

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

Slide 222

Slide 222 text

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)

Slide 223

Slide 223 text

Servidor A Servidor B Servidor E Servidor C Servidor F Servidor D Cluster Database

Slide 224

Slide 224 text

Servidor A Servidor B Servidor E Servidor C Servidor F Servidor D Cluster Database

Slide 225

Slide 225 text

No content

Slide 226

Slide 226 text

CONCLUINDO

Slide 227

Slide 227 text

Cache Local

Slide 228

Slide 228 text

Cache Distribuído

Slide 229

Slide 229 text

Near Cache

Slide 230

Slide 230 text

OBRIGADO! @JORDIHOFC