Tag Archives: mybatis

[자작] MyBatis EHCache 를 필요에 따라 statement 별로 제거하기

By | 4월 29, 2020

import java.util.List; import org.apache.ibatis.cache.CacheKey; import lombok.extern.slf4j.Slf4j; import net.sf.ehcache.Cache; import net.sf.ehcache.CacheManager; /** * MyBatis EHCache 관련 유틸 클래스 * * – mapperId + statementId 에 대하여 exactly equals 가 아니라 contains 임에 주의 * * @author STEVE */ @Slf4j public class MyBatisCacheUtil { /** * MyBatis 쿼리 캐시 제거 * * @param mapperId (e.g. “com.example.repository.UserRepository”) *… Read More »

MyBatis에 EHCache 적용하기

By | 4월 28, 2020

1. pom.xml <dependency> <groupId>org.mybatis.caches</groupId> <artifactId>mybatis-ehcache</artifactId> <version>1.2.1</version> </dependency>   2. MyBatis 각 mapper xml <?xml version=”1.0″ encoding=”UTF-8″?> <!DOCTYPE mapper PUBLIC “-//mybatis.org//DTD Mapper 3.0//EN” “http://mybatis.org/dtd/mybatis-3-mapper.dtd”> <mapper namespace=”com.tachyon.api.repository.NewsRepository”> <!– MyBatis ehcache 설정 – http://mybatis.org/ehcache-cache/ –> <cache type=”org.mybatis.caches.ehcache.EhcacheCache”> <!– <cache type=”org.mybatis.caches.ehcache.EhBlockingCache”> –><!– blocking cache를 사용할 경우 –> <property name=”timeToIdleSeconds” value=”3600″/><!–1 hour–> <property name=”timeToLiveSeconds” value=”3600″/><!–1 hour–> <property name=”maxEntriesLocalHeap” value=”1000″/> <property… Read More »