update 规范设计模式命名
This commit is contained in:
parent
606290e185
commit
46e46e60a6
@ -7,18 +7,18 @@ import org.springframework.cache.Cache;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache 装饰器(用于扩展一级缓存)
|
* Cache 装饰器模式(用于扩展 Caffeine 一级缓存)
|
||||||
*
|
*
|
||||||
* @author LionLi
|
* @author LionLi
|
||||||
*/
|
*/
|
||||||
public class PlusCacheWrapper implements Cache {
|
public class CaffeineCacheDecorator implements Cache {
|
||||||
|
|
||||||
private static final com.github.benmanes.caffeine.cache.Cache<Object, Object>
|
private static final com.github.benmanes.caffeine.cache.Cache<Object, Object>
|
||||||
CAFFEINE = SpringUtils.getBean("caffeine");
|
CAFFEINE = SpringUtils.getBean("caffeine");
|
||||||
|
|
||||||
private final Cache cache;
|
private final Cache cache;
|
||||||
|
|
||||||
public PlusCacheWrapper(Cache cache) {
|
public CaffeineCacheDecorator(Cache cache) {
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
|
|
@ -156,7 +156,7 @@ public class PlusSpringCacheManager implements CacheManager {
|
|||||||
private Cache createMap(String name, CacheConfig config) {
|
private Cache createMap(String name, CacheConfig config) {
|
||||||
RMap<Object, Object> map = RedisUtils.getClient().getMap(name);
|
RMap<Object, Object> map = RedisUtils.getClient().getMap(name);
|
||||||
|
|
||||||
Cache cache = new PlusCacheWrapper(new RedissonCache(map, allowNullValues));
|
Cache cache = new CaffeineCacheDecorator(new RedissonCache(map, allowNullValues));
|
||||||
if (transactionAware) {
|
if (transactionAware) {
|
||||||
cache = new TransactionAwareCacheDecorator(cache);
|
cache = new TransactionAwareCacheDecorator(cache);
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ public class PlusSpringCacheManager implements CacheManager {
|
|||||||
private Cache createMapCache(String name, CacheConfig config) {
|
private Cache createMapCache(String name, CacheConfig config) {
|
||||||
RMapCache<Object, Object> map = RedisUtils.getClient().getMapCache(name);
|
RMapCache<Object, Object> map = RedisUtils.getClient().getMapCache(name);
|
||||||
|
|
||||||
Cache cache = new PlusCacheWrapper(new RedissonCache(map, config, allowNullValues));
|
Cache cache = new CaffeineCacheDecorator(new RedissonCache(map, config, allowNullValues));
|
||||||
if (transactionAware) {
|
if (transactionAware) {
|
||||||
cache = new TransactionAwareCacheDecorator(cache);
|
cache = new TransactionAwareCacheDecorator(cache);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user