# xredis-spring-boot-start **Repository Path**: xingdeng_admin/xredis-spring-boot-start ## Basic Information - **Project Name**: xredis-spring-boot-start - **Description**: redis组件操作start - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-09-12 - **Last Updated**: 2024-09-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # xredis-spring-boot-start #### 介绍 redis组件操作start #### 软件架构 软件架构说明 springboot starter #### 使用说明 1. pom.xml中引入对应的依赖 ``` cn.xing.middleware xredis-spring-boot-start 0.0.1-SNAPSHOT ``` 2. 添加配置 ``` # Redis 配置 redis: # Redis 服务器地址 address: redis://localhost:6389 # Redis 密码(如果没有设置密码,可以省略此行) password: 123456 # 连接池最大连接数 pool-size: 64 # 最小空闲连接数 min-idle: 24 # 连接超时时间(毫秒) connect-timeout: 5000 # 命令等待超时(毫秒) timeout: 3000 ``` 3. 使用注解 @CacheableRedis(key="key",expireTime=3600) 其中key是指缓存到redis中的key,expireTime是设置的过期时间, 1.当是单个参数时候,可以参考: ``` @CacheableRedis(key = "'user:' + #id", expireTime = 3600) public User getUserById(Long id) { // 从数据库中获取用户 return “查询数据”; } ``` 2. 当是对象参数时候,参考: ``` @CacheableRedis(key = "'user:' + #userQuery.id + ':' + #userQuery.name", expireTime = 3600) public User getUserByQuery(UserQuery userQuery) { // 从数据库中获取用户 return userDao.queryUserInfoByUserId(new User(userQuery.getId()+"")); } ``` ``` public class UserQuery { private Long id; private String name; // getters and setters } ``` #### 参与贡献 #### 特技