Redis en autonome Redis

1. Utilisation de Redis pour le cache de données

La classe Departement reste la même que dans le premier exemple.

Le lanceur :

@SpringBootApplication  
@EnableCaching  
public class Ex3CacheRedis implements CommandLineRunner {  
 
  private static final Logger LOGGER = 
LoggerFactory.getLogger(Ex3CacheRedis.class);  
 
  public static void main(String[] args) {  
    SpringApplication.run(Ex3CacheRedis.class, args);  
  }  
 
  @Autowired  
  private DepartementRepository departementRepository;  
 
  @Override  
  public void run(String... args) throws Exception {  
    departementRepository.cacheEvict();  
 
    LOGGER.info("27->{}", departementRepository.getByCode("27")); 
    LOGGER.info("44->{}", departementRepository.getByCode("44")); 
    LOGGER.info("51->{}", departementRepository.getByCode("51")); 
 
    LOGGER.info("27->{}", departementRepository.getByCode("27")); 
    LOGGER.info("44->{}", departementRepository.getByCode("44")); 
    LOGGER.info("51->{}", departementRepository.getByCode("51")); 
 
 ...
couv_EP4JASP.png

Découvrez 

le livre :

Aussi inclus dans nos :

Précédent
GemFire en tant que base de données NoSQL
Suivant
MongoDB