Java Code Examples for net.sf.ehcache.CacheManager#cacheExists()

The following examples show how to use net.sf.ehcache.CacheManager#cacheExists() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EHCacheProvider.java    From pentaho-reporting with GNU Lesser General Public License v2.1 7 votes vote down vote up
public ResourceDataCache createDataCache() {
  try {
    final CacheManager manager = getCacheManager();
    synchronized( manager ) {
      if ( manager.cacheExists( DATA_CACHE_NAME ) == false ) {
        final Cache libloaderCache = new Cache( DATA_CACHE_NAME,   // cache name
          500,         // maxElementsInMemory
          false,       // overflowToDisk
          false,       // eternal
          600,         // timeToLiveSeconds
          600,         // timeToIdleSeconds
          false,       // diskPersistent
          120 );        // diskExpiryThreadIntervalSeconds
        manager.addCache( libloaderCache );
        return new EHResourceDataCache( libloaderCache );
      } else {
        return new EHResourceDataCache( manager.getCache( DATA_CACHE_NAME ) );
      }
    }
  } catch ( CacheException e ) {
    logger.debug( "Failed to create EHCache libloader-data cache", e );
    return null;
  }
}
 
Example 2
Source File: EHCacheProvider.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public ResourceBundleDataCache createBundleDataCache() {
  try {
    final CacheManager manager = getCacheManager();
    synchronized( manager ) {
      if ( manager.cacheExists( BUNDLES_CACHE_NAME ) == false ) {
        final Cache libloaderCache = new Cache( BUNDLES_CACHE_NAME,   // cache name
          500,         // maxElementsInMemory
          false,       // overflowToDisk
          false,       // eternal
          600,         // timeToLiveSeconds
          600,         // timeToIdleSeconds
          false,       // diskPersistent
          120 );        // diskExpiryThreadIntervalSeconds
        manager.addCache( libloaderCache );
        return new EHResourceBundleDataCache( libloaderCache );
      } else {
        return new EHResourceBundleDataCache( manager.getCache( BUNDLES_CACHE_NAME ) );
      }
    }
  } catch ( CacheException e ) {
    logger.debug( "Failed to create EHCache libloader-bundles cache", e );
    return null;
  }
}
 
Example 3
Source File: EHCacheProvider.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public ResourceFactoryCache createFactoryCache() {
  try {
    final CacheManager manager = getCacheManager();
    synchronized( manager ) {
      if ( manager.cacheExists( FACTORY_CACHE_NAME ) == false ) {
        final Cache libloaderCache = new Cache( FACTORY_CACHE_NAME,   // cache name
          500,         // maxElementsInMemory
          false,       // overflowToDisk
          false,       // eternal
          600,         // timeToLiveSeconds
          600,         // timeToIdleSeconds
          false,       // diskPersistent
          120 );        // diskExpiryThreadIntervalSeconds
        manager.addCache( libloaderCache );
        return new EHResourceFactoryCache( libloaderCache );
      } else {
        return new EHResourceFactoryCache( manager.getCache( FACTORY_CACHE_NAME ) );
      }
    }
  } catch ( CacheException e ) {
    logger.debug( "Failed to create EHCache libloader-factory cache", e );
    return null;
  }
}
 
Example 4
Source File: PipelineSqlMapDao.java    From gocd with Apache License 2.0 5 votes vote down vote up
private static Ehcache createCacheIfRequired(String cacheName) {
    final CacheManager instance = CacheManager.newInstance(new Configuration().name(cacheName));
    synchronized (instance) {
        if (!instance.cacheExists(cacheName)) {
            instance.addCache(new Cache(cacheConfiguration(cacheName)));
        }
        return instance.getCache(cacheName);
    }
}
 
Example 5
Source File: JobInstanceSqlMapDao.java    From gocd with Apache License 2.0 5 votes vote down vote up
private static Ehcache createCacheIfRequired(String cacheName) {
    final CacheManager instance = CacheManager.newInstance(new Configuration().name(cacheName));
    synchronized (instance) {
        if (!instance.cacheExists(cacheName)) {
            instance.addCache(new net.sf.ehcache.Cache(cacheConfiguration(cacheName)));
        }
        return instance.getCache(cacheName);
    }
}