汪菘
2 years ago
7 changed files with 3 additions and 116 deletions
@ -1,19 +0,0 @@ |
|||
package org.nl.modules.cache; |
|||
|
|||
import com.alicp.jetcache.Cache; |
|||
import com.alicp.jetcache.anno.CacheType; |
|||
import com.alicp.jetcache.anno.CreateCache; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class BothCacheManager extends NlCacheManager { |
|||
/** |
|||
* 使用 @CreateCache 注解创建Cache实例; |
|||
* 未定义默认值的参数,将使用yml中指定的全局配置; |
|||
* 缓存在 Local,也可以配置成 both 开启两级缓存 |
|||
*/ |
|||
@CreateCache(expire = 5 * 60, cacheType = CacheType.BOTH, localLimit = 10) |
|||
private Cache<Object, Object> defaultCache; |
|||
@CreateCache(expire = 5 * 60, cacheType = CacheType.BOTH, localLimit = 10) |
|||
private Cache<Object, Object> systemCache; |
|||
} |
@ -1,23 +0,0 @@ |
|||
package org.nl.modules.cache; |
|||
|
|||
import com.alicp.jetcache.anno.CacheConsts; |
|||
import com.alicp.jetcache.anno.CacheType; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
@Configuration |
|||
public class CacheConfig { |
|||
@Value("${jetcache.defaultCacheType}") |
|||
private String cacheType; |
|||
|
|||
@Bean(name = "sysCacheManager") |
|||
public NlCacheManager sysCacheManager() { |
|||
CacheConsts.isUndefined(2); |
|||
if (CacheType.BOTH.name().equals(cacheType)) return new BothCacheManager(); |
|||
if (CacheType.LOCAL.name().equals(cacheType)) return new LocalCacheManager(); |
|||
if (CacheType.REMOTE.name().equals(cacheType)) return new RemoteCacheManager(); |
|||
return new LocalCacheManager(); |
|||
} |
|||
|
|||
} |
@ -1,19 +0,0 @@ |
|||
package org.nl.modules.cache; |
|||
|
|||
import com.alicp.jetcache.Cache; |
|||
import com.alicp.jetcache.anno.CacheType; |
|||
import com.alicp.jetcache.anno.CreateCache; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class LocalCacheManager extends NlCacheManager { |
|||
/** |
|||
* 使用 @CreateCache 注解创建Cache实例; |
|||
* 未定义默认值的参数,将使用yml中指定的全局配置; |
|||
* 缓存在 Local,也可以配置成 both 开启两级缓存 |
|||
*/ |
|||
@CreateCache(expire = 5 * 60, cacheType = CacheType.LOCAL, localLimit = 10) |
|||
private Cache<Object, Object> defaultCache; |
|||
@CreateCache(expire = 5 * 60, cacheType = CacheType.LOCAL, localLimit = 10) |
|||
private Cache<Object, Object> systemCache; |
|||
} |
@ -1,13 +0,0 @@ |
|||
package org.nl.modules.cache; |
|||
|
|||
import com.alicp.jetcache.Cache; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public abstract class NlCacheManager { |
|||
private Cache<Object, Object> defaultCache; |
|||
private Cache<Object, Object> systemCache; |
|||
public void test(){ |
|||
System.out.println(this.getClass().getName()); |
|||
} |
|||
} |
@ -1,24 +0,0 @@ |
|||
package org.nl.modules.cache; |
|||
|
|||
import com.alicp.jetcache.Cache; |
|||
import com.alicp.jetcache.anno.CacheType; |
|||
import com.alicp.jetcache.anno.CreateCache; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class RemoteCacheManager extends NlCacheManager { |
|||
/** |
|||
* 使用 @CreateCache 注解创建Cache实例; |
|||
* 未定义默认值的参数,将使用yml中指定的全局配置; |
|||
* 缓存在 Local,也可以配置成 both 开启两级缓存 |
|||
*/ |
|||
@CreateCache(expire = 5 * 60, cacheType = CacheType.REMOTE, localLimit = 10) |
|||
private Cache<Object, Object> defaultCache; |
|||
@CreateCache(expire = 5 * 60, cacheType = CacheType.REMOTE, localLimit = 10) |
|||
private Cache<Object, Object> systemCache; |
|||
|
|||
@Override |
|||
public void test() { |
|||
System.out.println(this.getClass().getName()); |
|||
} |
|||
} |
Loading…
Reference in new issue