List of usage examples for org.apache.ibatis.mapping CacheBuilder CacheBuilder
public CacheBuilder(String id)
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 v a 2s. 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.ibatis.sqlmap.engine.builder.XmlSqlMapParser.java
License:Apache License
@NodeEvent("/sqlMap/cacheModel") public void sqlMapcacheModel(XNode context) throws Exception { String id = applyNamespace(context.getStringAttribute("id")); String type = context.getStringAttribute("type"); Boolean readOnly = context.getBooleanAttribute("readOnly", true); Boolean serialize = context.getBooleanAttribute("serialize", true); Class clazz = config.getTypeAliasRegistry().resolveAlias(type); cacheBuilder = new CacheBuilder(id); cacheBuilder.addDecorator(clazz);// w w w .ja va2 s.c o m //LOCAL_READ_WRITE (serializable=false, readOnly=false) //SHARED_READ_ONLY (serializable=false, readOnly=true) //SHARED_READ_WRITE (serializable=true, readOnly=false) if (serialize) { if (readOnly) { cacheBuilder.readWrite(false); } else { cacheBuilder.readWrite(true); } } else { if (readOnly) { cacheBuilder.readWrite(false); } else { cacheBuilder = null; } } }
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 ww. j a va 2 s .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(); }