最近做的一个项目,融合了Spring Boot,Mybatis Plus , Shiro ,Redis,fastdfs ,数据库使用的是mysql,以druid作为连接池,这里只谈谈项目中redis缓存的基本使用方法。
redis的引入:
1.8
1.4.2
org.apache.shiro
shiro-spring
${shiro.version}
org.springframework.boot
spring-boot-starter-data-redis
org.crazycake
shiro-redis
3.2.3
application.yml配置redis的参数
RedisConfig配置类:(实际上并没有使用这个配置类,项目运行前我注释掉了)
/**
* 设置redis的序列化规则
*/
@Configuration
public classRedisConfig {
@Bean
publicRedisCacheConfiguration redisCacheConfiguration(CacheProperties cacheProperties) {
CacheProperties.Redis redisProperties = cacheProperties.getRedis();
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
config = config.ser