List of usage examples for org.apache.ibatis.mapping CacheBuilder build
public Cache build()
From source file:com.badminton.interceptors.mySqlHelper.pagehelper.cache.SimpleCache.java
License:Open Source License
public SimpleCache(Properties properties, String prefix) { CacheBuilder cacheBuilder = new CacheBuilder("SQL_CACHE"); String typeClass = properties.getProperty(prefix + ".typeClass"); if (StringUtil.isNotEmpty(typeClass)) { try {/*from w w w .j a va 2 s. co m*/ cacheBuilder .implementation((Class<? extends org.apache.ibatis.cache.Cache>) Class.forName(typeClass)); } catch (ClassNotFoundException e) { cacheBuilder.implementation(PerpetualCache.class); } } else { cacheBuilder.implementation(PerpetualCache.class); } String evictionClass = properties.getProperty(prefix + ".evictionClass"); if (StringUtil.isNotEmpty(evictionClass)) { try { cacheBuilder.addDecorator( (Class<? extends org.apache.ibatis.cache.Cache>) Class.forName(evictionClass)); } catch (ClassNotFoundException e) { cacheBuilder.addDecorator(FifoCache.class); } } else { cacheBuilder.addDecorator(FifoCache.class); } String flushInterval = properties.getProperty(prefix + ".flushInterval"); if (StringUtil.isNotEmpty(flushInterval)) { cacheBuilder.clearInterval(Long.parseLong(flushInterval)); } String size = properties.getProperty(prefix + ".size"); if (StringUtil.isNotEmpty(size)) { cacheBuilder.size(Integer.parseInt(size)); } cacheBuilder.properties(properties); CACHE = cacheBuilder.build(); }
From source file:com.sinotopia.mybatis.pagehelper.cache.SimpleCache.java
License:Open Source License
public SimpleCache(Properties properties, String prefix) { CacheBuilder cacheBuilder = new CacheBuilder("SQL_CACHE"); String typeClass = properties.getProperty(prefix + ".typeClass"); if (StringUtil.isNotEmpty(typeClass)) { try {//from w w w .j av a 2s .c o m cacheBuilder .implementation((Class<? extends org.apache.ibatis.cache.Cache>) Class.forName(typeClass)); } catch (ClassNotFoundException e) { cacheBuilder.implementation(PerpetualCache.class); } } else { cacheBuilder.implementation(PerpetualCache.class); } String evictionClass = properties.getProperty(prefix + ".evictionClass"); if (StringUtil.isNotEmpty(evictionClass)) { try { cacheBuilder.addDecorator( (Class<? extends org.apache.ibatis.cache.Cache>) Class.forName(evictionClass)); } catch (ClassNotFoundException e) { cacheBuilder.addDecorator(FifoCache.class); } } else { cacheBuilder.addDecorator(FifoCache.class); } String flushInterval = properties.getProperty(prefix + ".flushInterval"); if (StringUtil.isNotEmpty(flushInterval)) { cacheBuilder.clearInterval(Long.parseLong(flushInterval)); } String size = properties.getProperty(prefix + ".size"); if (StringUtil.isNotEmpty(size)) { cacheBuilder.size(Integer.parseInt(size)); } cacheBuilder.properties(properties); CACHE = cacheBuilder.build(); }