Redis Cache Usage
1. Introduction of dependencies (may have been introduced): Spring-boot-starter-cache
2. Configure the Spring:redis:host/port/password in the Application.yml configuration file to connect to the Redis library
3. Add annotations to the main launcher: @EnableChaching
4. Add annotations to the method that requires caching:@Cacheable (cachename= "". key= "")
5. The outermost object of the return page needs to be serialized: Implement Interface serializable
6. Use the Generateserialversionuid plugin to generate unique IDs for objects that need to be serialized (using shortcut keys)
Redis Cache Update
Method One: Add annotations to the method that needs to update the cache:@CachePut (cachename= "". key= "")
Note: Sometimes the returned data is not in JSON format but in view format, when serialization fails, and this method cannot be used
Method Two: Add a note to the method that needs to delete the cache:@CacheEvict (cachename= "". key= "")
Springboot-redis Cache