Redis is an open source (BSD licensed), memory-stored data structure server that can be used as a database, cache, and Message Queuing agent.
Sometimes, in order to improve the performance of the entire Web site, the data that is frequently accessed is cached at development time, which can improve the efficiency of data loading when the data interface is called.
This article will integrate Redis in the boot project, caching common data to REDIS servers and improving the concurrency of common services.
Project Environment:
jdk1.8
maven3.5
Spring Boot 2.0.4.RELEASE
Spring-boot-starter-data-redis 2.0.4.RELEASE
Redis3.2
I. Installing Redis
Follow "Terry's private Tutorial" public number reply Redis get
Unzip to local open Redis-cli.exe run after download
After a successful run, you can view it through the Redis Desktop Manager connection
Two. Integrated Redis
This project caches data in Redis when invoking weather interface data
Specific implementation:
Introduction of stringredistemplate, increased operation on Redis servers
Set Cache time
redis is stored in key-value format, so calling This method will call the address as key, call data value, each call is first to determine if there is a key in Redis, if there is this key, Direct else will pull the data out,
Re-fetch the data if it does not exist and initialize it to Redis
Third, the results of the operation
Logs allow you to discover that data is being cached in the Redis server
through Redis Desktop Manager View
Integrated Redis success, if you have questions, please follow the public number "Terry Private tutorial" message
Springboot Integrated Redis First practice