Search in sources :

Example 1 with BlockingCache

use of net.sf.ehcache.constructs.blocking.BlockingCache in project cloudstack by apache.

the class EhcacheLimitStore method setCache.

public void setCache(Ehcache cache) {
    BlockingCache ref;
    if (!(cache instanceof BlockingCache)) {
        ref = new BlockingCache(cache);
        cache.getCacheManager().replaceCacheWithDecoratedCache(cache, new BlockingCache(cache));
    } else {
        ref = (BlockingCache) cache;
    }
    this.cache = ref;
}
Also used : BlockingCache(net.sf.ehcache.constructs.blocking.BlockingCache)

Example 2 with BlockingCache

use of net.sf.ehcache.constructs.blocking.BlockingCache 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();
    }
}
Also used : BlockingCache(net.sf.ehcache.constructs.blocking.BlockingCache) CacheManager(net.sf.ehcache.CacheManager) Ehcache(net.sf.ehcache.Ehcache) Test(org.junit.Test)

Aggregations

BlockingCache (net.sf.ehcache.constructs.blocking.BlockingCache)2 CacheManager (net.sf.ehcache.CacheManager)1 Ehcache (net.sf.ehcache.Ehcache)1 Test (org.junit.Test)1