Skip to content

Commit

Permalink
🐛 Fixing a bug. @CacheEvict 功能与原版有出入 #5
Browse files Browse the repository at this point in the history
  • Loading branch information
pig777 committed Nov 5, 2020
1 parent d822268 commit c50935f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<dependency>
<groupId>com.pig4cloud.plugin</groupId>
<artifactId>multilevel-cache-spring-boot-starter</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<version>2.3.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.pig4cloud.plugin</groupId>
<artifactId>multilevel-cache-spring-boot-starter</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
<name>multilevel-cache-spring-boot-starter</name>
<description>support L1 caffeine and L2 redis cache</description>
<url>https://pig4cloud.com</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class MultilevelCacheAutoConfiguration {
@ConditionalOnBean(RedisTemplate.class)
public RedisCaffeineCacheManager cacheManager(
CacheConfigProperties cacheConfigProperties,
RedisTemplate<Object, Object> redisTemplate) {
return new RedisCaffeineCacheManager(cacheConfigProperties, redisTemplate);
RedisTemplate<Object, Object> stringKeyRedisTemplate) {
return new RedisCaffeineCacheManager(cacheConfigProperties, stringKeyRedisTemplate);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.support.AbstractValueAdaptingCache;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

Expand Down Expand Up @@ -166,6 +167,8 @@ protected Object lookup(Object key) {
return value;
}

// 避免自动一个 RedisTemplate 覆盖失效
stringKeyRedisTemplate.setKeySerializer(new StringRedisSerializer());
value = stringKeyRedisTemplate.opsForValue().get(cacheKey);

if (value != null) {
Expand Down

0 comments on commit c50935f

Please sign in to comment.