基于redis和ehcache的兩級(jí)緩存組件,支持spring-boot,使用方便,有管理頁(yè)面。
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
@SpringBootApplication @EnableAspectJAutoProxy public class Application { public static void main(String[] agrs){ SpringApplication.run(Application.class,agrs); } }
classpath:config.properties
@Cache( preload = true,//是否需要緩存預(yù)熱,會(huì)在系統(tǒng)啟動(dòng)時(shí)自已加載,支持特殊場(chǎng)景 preloadParameters = {"param1", "param2"},//加載方法參數(shù),目前只支持String expiredTime = 60,//緩存有效時(shí)間,單位秒 cleanTimeExpressions = "0 15 10 ? ",//緩存定時(shí)清除時(shí)間表達(dá)式,如:每天10點(diǎn)15分觸發(fā) cacheCleans={//依賴清除bean定義,當(dāng)該方法被調(diào)用時(shí)清除當(dāng)前緩存,可定義多個(gè) @CacheClean( beanName="couriersService6",//bean名稱 methodName="updateCourierPwd"http://方法名稱 ) } ) public User getUserById(){...}
可以直接使用cn.uncode.cache.CacheUtils工具類。
以spring-boot方式啟動(dòng)cn.uncode.cache.springboot.Application類,訪問(wèn)http://localhost:8808/static/index.html
作者:冶衛(wèi)軍(ywj_316@qq.com,微信:yeweijun)
技術(shù)支持QQ群:47306892
Copyright 2018 www.uncode.cn
本項(xiàng)目使用了部分開(kāi)源項(xiàng)目代碼,保留了原作者的名稱和所有內(nèi)容,同時(shí)向作者致敬。
更多建議: