Uncode-Cache使用文檔

2018-07-18 09:30 更新

uncode-cache

基于redis和ehcache的兩級(jí)緩存組件,支持spring-boot,使用方便,有管理頁(yè)面。

功能概述

  1. 統(tǒng)一注解支持
  2. 可以設(shè)置緩存定時(shí)自動(dòng)更新時(shí)間
  3. 可以緩存預(yù)熱
  4. 可以設(shè)置緩存依賴消除
  5. 可以添加監(jiān)聽(tīng),使用實(shí)現(xiàn)命中率、讀/寫耗時(shí)等

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啟動(dòng)類

@SpringBootApplication
@EnableAspectJAutoProxy
public class Application {
    public static void main(String[] agrs){
        SpringApplication.run(Application.class,agrs);
    }
}

spring配置

 
     
     
         
            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工具類。

管理頁(yè)面

以spring-boot方式啟動(dòng)cn.uncode.cache.springboot.Application類,訪問(wèn)http://localhost:8808/static/index.html

輸入圖片說(shuō)明

關(guān)于

作者:冶衛(wèi)軍(ywj_316@qq.com,微信:yeweijun)

技術(shù)支持QQ群:47306892

Copyright 2018 www.uncode.cn

特別說(shuō)明

本項(xiàng)目使用了部分開(kāi)源項(xiàng)目代碼,保留了原作者的名稱和所有內(nèi)容,同時(shí)向作者致敬。


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)