-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
111 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...is/src/main/java/cn/iocoder/yudao/framework/redis/config/YudaoCacheAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cn.iocoder.yudao.framework.redis.config; | ||
|
||
import org.springframework.boot.autoconfigure.cache.CacheProperties; | ||
import org.springframework.cache.annotation.EnableCaching; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.data.redis.cache.RedisCacheConfiguration; | ||
import org.springframework.data.redis.serializer.RedisSerializationContext; | ||
import org.springframework.data.redis.serializer.RedisSerializer; | ||
|
||
/** | ||
* Cache 配置类,基于 Redis 实现 | ||
*/ | ||
@Configuration | ||
@EnableCaching | ||
public class YudaoCacheAutoConfiguration { | ||
|
||
/** | ||
* RedisCacheConfiguration Bean | ||
* | ||
* 参考 org.springframework.boot.autoconfigure.cache.RedisCacheConfiguration 的 createConfiguration 方法 | ||
*/ | ||
@Bean | ||
@Primary | ||
public RedisCacheConfiguration redisCacheConfiguration(CacheProperties cacheProperties) { | ||
// 设置使用 JSON 序列化方式 | ||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig(); | ||
config = config.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(RedisSerializer.json())); | ||
|
||
// 设置 CacheProperties.Redis 的属性 | ||
CacheProperties.Redis redisProperties = cacheProperties.getRedis(); | ||
if (redisProperties.getTimeToLive() != null) { | ||
config = config.entryTtl(redisProperties.getTimeToLive()); | ||
} | ||
if (redisProperties.getKeyPrefix() != null) { | ||
config = config.prefixCacheNameWith(redisProperties.getKeyPrefix()); | ||
} | ||
if (!redisProperties.isCacheNullValues()) { | ||
config = config.disableCachingNullValues(); | ||
} | ||
if (!redisProperties.isUseKeyPrefix()) { | ||
config = config.disableKeyPrefix(); | ||
} | ||
return config; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
yudao-framework/yudao-spring-boot-starter-redis/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||
cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration | ||
cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration,\ | ||
cn.iocoder.yudao.framework.redis.config.YudaoCacheAutoConfiguration |
1 change: 1 addition & 0 deletions
1
yudao-framework/yudao-spring-boot-starter-redis/《芋道 Spring Boot Cache 入门》.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<http://www.iocoder.cn/Spring-Boot/Cache/?yudao> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/TestDemoController.http
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
### 请求 /infra/test-demo/get 接口 => 成功 | ||
GET {{baseUrl}}/infra/test-demo/get?id=106 | ||
Authorization: Bearer {{token}} | ||
tenant-id: {{adminTenentId}} | ||
|
||
### 请求 /infra/test-demo/update 接口 => 成功 | ||
PUT {{baseUrl}}/infra/test-demo/update | ||
Authorization: Bearer {{token}} | ||
tenant-id: {{adminTenentId}} | ||
Content-Type: application/json | ||
|
||
|
||
{ | ||
"id": 106, | ||
"name": "测试", | ||
"status": "0", | ||
"type": 1, | ||
"category": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/package-info.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters