use of net.sf.ehcache.CacheManager in project oc-explorer by devgateway.
the class MarkupCacheService method getReportFromCache.
/**
* Fetch the content of a report from cache
*
* @param outputType
* @param reportName
* @param parameters
* @return
*/
public byte[] getReportFromCache(final String outputType, final String reportName, final String parameters) {
CacheManager cm = CacheManager.getInstance();
// get the reports cache "reportsCache", declared in ehcache.xml
Cache cache = cm.getCache("reportsCache");
String key = createCacheKey(outputType, reportName, parameters);
if (cache.isKeyInCache(key)) {
return (byte[]) cache.get(key).getObjectValue();
}
return null;
}
use of net.sf.ehcache.CacheManager in project hibernate-orm by hibernate.
the class EhcacheStatsImplTest method createCache.
@BeforeClass
public static void createCache() throws Exception {
CacheManager manager = CacheManager.getInstance();
stats = new EhcacheStatsImpl(manager);
}
use of net.sf.ehcache.CacheManager in project spring-framework by spring-projects.
the class EhCacheSupportTests method testEhCacheFactoryBeanWithBlockingCache.
@Test
public void testEhCacheFactoryBeanWithBlockingCache() throws Exception {
EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean();
cacheManagerFb.afterPropertiesSet();
try {
CacheManager cm = cacheManagerFb.getObject();
EhCacheFactoryBean cacheFb = new EhCacheFactoryBean();
cacheFb.setCacheManager(cm);
cacheFb.setCacheName("myCache1");
cacheFb.setBlocking(true);
assertEquals(cacheFb.getObjectType(), BlockingCache.class);
cacheFb.afterPropertiesSet();
Ehcache myCache1 = cm.getEhcache("myCache1");
assertTrue(myCache1 instanceof BlockingCache);
} finally {
cacheManagerFb.destroy();
}
}
use of net.sf.ehcache.CacheManager in project spring-framework by spring-projects.
the class EhCacheSupportTests method testBlankCacheManager.
@Test
public void testBlankCacheManager() throws Exception {
EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean();
cacheManagerFb.setCacheManagerName("myCacheManager");
assertEquals(CacheManager.class, cacheManagerFb.getObjectType());
assertTrue("Singleton property", cacheManagerFb.isSingleton());
cacheManagerFb.afterPropertiesSet();
try {
CacheManager cm = cacheManagerFb.getObject();
assertTrue("Loaded CacheManager with no caches", cm.getCacheNames().length == 0);
Cache myCache1 = cm.getCache("myCache1");
assertTrue("No myCache1 defined", myCache1 == null);
} finally {
cacheManagerFb.destroy();
}
}
use of net.sf.ehcache.CacheManager in project spring-framework by spring-projects.
the class EhCacheCacheTests method setUp.
@Before
public void setUp() {
cacheManager = new CacheManager(new Configuration().name("EhCacheCacheTests").defaultCache(new CacheConfiguration("default", 100)));
nativeCache = new net.sf.ehcache.Cache(new CacheConfiguration(CACHE_NAME, 100));
cacheManager.addCache(nativeCache);
cache = new EhCacheCache(nativeCache);
}
Aggregations