# matrix-cache **Repository Path**: sintrue/matrix-cache ## Basic Information - **Project Name**: matrix-cache - **Description**: a multilevel cache - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-01-13 - **Last Updated**: 2025-12-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # matrix-cache A transparent multilevel cache framework based on spring cache. # Maven依赖 ## 配置repository 因SNAPSHOT版本未同步至中央仓库,故需配置如下仓库 ```xml matrix-snapshot https://s01.oss.sonatype.org/content/repositories/snapshots/ true always ``` ## Maven依赖 ```xml wang.liangchen.matrix.cache matrix-cache-sdk-spring-boot-starter 3.0.0-SNAPSHOT ``` ## 其它可选依赖 组件引用到的依赖项,部分为provided依赖,需要根据实际的使用场景自行引入 ### 仅使用Caffeine本地缓存 ```xml com.github.ben-manes.caffeine caffeine ``` ### 仅使用Redis分布式缓存 ```xml org.springframework.boot spring-boot-starter-data-redis-reactive ``` ### 使用多级缓存 ```xml com.github.ben-manes.caffeine caffeine org.springframework.boot spring-boot-starter-data-redis-reactive ``` ### Redis使用Protostuff序列化 ```xml io.protostuff protostuff-runtime io.protostuff protostuff-core ``` # 使用方式 ## 启用多级缓存 使用注解@EnableMatrixCaching启用多级缓存 ```java @EnableMatrixCaching public class ApplicatonConfiguration {} ``` ## 注解式 完全兼容Spring原生注解,增强使用@CacheExpire注解指定Cache级别的过期时间 ### Spring原生注解 ```java import java.util.concurrent.TimeUnit; public class ExampleClass{ @Cacheable(value = "CacheObject") // 使用该注解为Cache指定过期时间 @CacheExpire(ttl = 5, timeUnit = TimeUnit.SECONDS) public String exampleMethod(){} } ``` ## 编程式 ```java public class ExampleClass { @Inject private MultilevelCacheManager matrixCacheManager; } ```