Example usage for org.apache.http.impl.client.cache.ehcache EhcacheHttpCacheStorage EhcacheHttpCacheStorage

List of usage examples for org.apache.http.impl.client.cache.ehcache EhcacheHttpCacheStorage EhcacheHttpCacheStorage

Introduction

In this page you can find the example usage for org.apache.http.impl.client.cache.ehcache EhcacheHttpCacheStorage EhcacheHttpCacheStorage.

Prototype

public EhcacheHttpCacheStorage(Ehcache cache, CacheConfig config) 

Source Link

Document

Constructs a storage backend using the provided Ehcache with the given configuration options.

Usage

From source file:org.esigate.cache.EhcacheCacheStorage.java

@Override
public void init(Properties properties) {
    String cacheName = Parameters.EHCACHE_CACHE_NAME_PROPERTY.getValue(properties);
    String configurationFileName = Parameters.EHCACHE_CONFIGURATION_FILE_PROPERTY.getValue(properties);
    // Loaded from the Classpath, default will use /ehcache.xml or if not found /ehcache-failsafe.xml
    CacheManager cacheManager = CacheManager.create(configurationFileName);
    Ehcache ehcache = cacheManager.getEhcache(cacheName);
    if (ehcache == null) {
        cacheManager.addCache(cacheName);
        ehcache = cacheManager.getEhcache(cacheName);
    }//from   w  w w.j a  v a2s.  c om
    CacheConfig cacheConfig = CacheConfigHelper.createCacheConfig(properties);
    setImpl(new EhcacheHttpCacheStorage(ehcache, cacheConfig));
}