uncode-cache 1. application.peroperties2. spring boot启动类 介绍
uncode-cache
基于 redis 和 ehcache 的两级缓存组件,支持spring-boot,使用方便,有管理页面。
功能概述
spring boot
1. application.peroperties
uncode.cache.redisClusteraddress=127.0.0.1:7000;127.0.0.1:7001;127.0.0.1:7002;127.0.0.1:7003;127.0.0.1:7004;127.0.0.1:7005 uncode.cache.redisPoolMaxIdle= uncode.cache.redisPoolMinIdle = uncode.cache.redisPoolMaxTotal= uncode.cache.redisPoolMaxWaitMillis= uncode.cache.redisClusterTimeout= uncode.cache.redisClusterMaxRedirections= uncode.cache.redisClusterPassword uncode.cache.scanPackage=cn.uncode.cache uncode.cache.useLocal=true uncode.cache.openCacheLog=false uncode.cache.storeRegion=uncode-cache-demo
2. spring boot启动类
@SpringBootApplication @EnableAspectJAutoproxy public class Application { public static void main(String[] agrs){ SpringApplication.run(Application.class,agrs); } }
spring配置
<bean id="propertyConfigurer" class="cn.uncode.util.config.UncodePropertyPlaceholderConfigurer"> <property name="ignoreResourceNotFound" value="true" /> <property name="locations"> <list> <value>classpath:config.properties</value> </list> </property> </bean> <!-- 设置代理 --> <aop:aspectj-autoproxy proxy-target-class="true"/> <!-- 配置缓存池 --> <bean id="jedisCluster" class="com.ksudi.proxycache.store.redis.JedisClusterFactory" /> <bean id="cache" class="com.ksudi.proxycache.store.redis.RedisStore"> <property name="jedisCluster" ref="jedisCluster" /> </bean> <!-- 配置缓存代理管理器 --> <bean id="proxyCacheManager" class="com.ksudi.proxycache.ConfigCacheManager" init-method="init"> <!-- 注解的扫描路径 --> <property name="scanPackage" value="com.ksudi.star.service"></property> <property name="cache" ref="cache" /> </bean> <!-- 配置aop缓存处理器 --> <bean class="com.ksudi.proxycache.framework.aop.handle.CacheManagerHandle"> <property name="cacheManager" ref="proxyCacheManager" /> </bean>
核心注解
@Cache( preload = true,//是否需要缓存预热,会在系统启动时自已加载,支持特殊场景 preloadParameters = {"param1", "param2"},//加载方法参数,目前只支持String expiredTime = 60,//缓存有效时间,单位秒 cleanTimeExpressions = "0 15 10 ? * *",//缓存定时清除时间表达式,如:每天10点15分触发 cacheCleans={//依赖清除bean定义,当该方法被调用时清除当前缓存,可定义多个 @CacheClean( beanName="courieRSService6",//bean名称 methodName="updateCourierPwd"//方法名称 ) } ) public User getUserById(){...}
工具类
可以直接使用cn.uncode.cache.CacheUtils工具类。
管理页面
特别说明
本项目使用了部分开源项目代码,保留了原作者的名称和所有内容,同时向作者致敬。
uncode-cache 1. application.peroperties2. spring boot启动类 官网
http://git.oschina.net/uncode/uncode-cache
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。