Example usage for org.apache.ibatis.mapping CacheBuilder clearInterval

List of usage examples for org.apache.ibatis.mapping CacheBuilder clearInterval

Introduction

In this page you can find the example usage for org.apache.ibatis.mapping CacheBuilder clearInterval.

Prototype

Long clearInterval

To view the source code for org.apache.ibatis.mapping CacheBuilder clearInterval.

Click Source Link

Usage

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 av a 2 s . c om*/
            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  ww  w. j a v  a 2  s  . com*/
            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();
}