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

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

Introduction

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

Prototype

Integer size

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

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 {/*w  w  w  . java2s . 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();
}

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 {//  w w  w.j av  a2s  . 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();
}