Skip to content

tony mybatis cache

徐植君 edited this page Dec 5, 2021 · 1 revision

mybatis的二级缓存快速启动器,目前实现了redis和j2cache,未来将提供更多缓存实现

1 使用方式

1.1 导入依赖

<dependency>
    <groupId>com.tony</groupId>
    <artifactId>tony-mybatis-cache-spring-boot-starter</artifactId>
    <version>${tony-starter.version}</version>
</dependency>

1.2 打开mybatis二级缓存开关

<setting name="cacheEnabled" value="true"/>

1.3 指定缓存方式

@CacheNamespace(implementation = RedisCacheAdapter.class, eviction = RedisCacheAdapter.class)
public interface UserMapper extends BaseMapper<User> {

}
Clone this wiki locally