@Cache比spring cache更輕量的緩存,支持單個緩存設置過時時間,能夠根據前綴移除緩存。
採用fastjson序列化與反序列化,以json串存於緩存之中。
icloud-cache能夠快速用於平常的spring boot應用之中。git
數據可視化展現(生產環境不建議使用)web
Redis 客戶端查看redis
使用手冊Maven依賴Cache APIspring
<dependency><groupId>com.gitee.ibyte</groupId><artifactId>icloud-cache</artifactId><version>0.0.2</version></dependency>緩存配置
一、配置redis數據源,application.yml文件json
#redis-cache 相關redis:pool: maxActive: 300 maxIdle: 100 maxWait: 1000host: 127.0.0.1port: 6379password:timeout: 2000# 服務或應用名sysName: icloudenable: truedatabase: 0緩存開啓
二、開啓AOP掃描緩存
@EnableiCloudCache緩存使用
三、在Service上進行@Cache註解或@CacheClear註解mvc
註解說明配置緩存:@Cache清除緩存:@CacheClear
默認key動態表達式說明
輕量管理端
訪問地址:
http://localhost:8080/cache
管理端批量或前綴清除icloud-cache註冊的緩存,同時也能夠快速預覽緩存的數據內容,也能夠對緩存的失效時間進行延長。app
一、在src/main/test中展開的相關示例代碼maven
兼容spring mvc模式CacheTest是核心啓動類ide
service包是緩存調用例子,包含自定義表達式和結果解析、註解的使用
配置文文件
application.properties
redis.pool.maxActive = 300redis.pool.maxIdle = 100redis.pool.maxWait = 1000redis.host = 127.0.0.1redis.port = 6379redis.password = redis.timeout = 2000redis.database = 0redis.sysName = icloudredis.enable = true
applicationContext.xml
<!-- beans 頭部--> xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd" <!-- 開啓AOP配置 --> <aop:aspectj-autoproxy></aop:aspectj-autoproxy><context:component-scan base-package="com.icloud.cache"/><context:annotation-config/>
maven依賴
<properties><!-- spring --><spring.version>4.1.3.RELEASE</spring.version><properties><dependencies><dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version></dependency><dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version></dependency><dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version></dependency><dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version></dependency><dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>${spring.version}</version></dependency><dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version></dependency><dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>${aspectj.version}</version></dependency></dependencies>