本文整理匯總了Java中net.sf.ehcache.CacheManager.addCache方法的典型用法代碼示例。如果您正苦於以下問題:Java CacheManager.addCache方法的具體用法?Java CacheManager.addCache怎麽用?Java CacheManager.addCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.sf.ehcache.CacheManager
的用法示例。
在下文中一共展示了CacheManager.addCache方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createCachePool
import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
@Override
public CachePool createCachePool(String poolName, int cacheSize,
int expiredSeconds) {
CacheManager cacheManager = CacheManager.create();
Cache enCache = cacheManager.getCache(poolName);
if (enCache == null) {
CacheConfiguration cacheConf = cacheManager.getConfiguration()
.getDefaultCacheConfiguration().clone();
cacheConf.setName(poolName);
if (cacheConf.getMaxEntriesLocalHeap() != 0) {
cacheConf.setMaxEntriesLocalHeap(cacheSize);
} else {
cacheConf.setMaxBytesLocalHeap(String.valueOf(cacheSize));
}
cacheConf.setTimeToIdleSeconds(expiredSeconds);
Cache cache = new Cache(cacheConf);
cacheManager.addCache(cache);
return new EnchachePool(poolName,cache,cacheSize);
} else {
return new EnchachePool(poolName,enCache,cacheSize);
}
}
示例2: verifyEhCacheTicketRegistryWithClearPass
import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
@Test
public void verifyEhCacheTicketRegistryWithClearPass() {
final Cache serviceTicketsCache = new Cache("serviceTicketsCache", 200, false, false, 100, 100);
final Cache ticketGrantingTicketCache = new Cache("ticketGrantingTicketCache", 200, false, false, 100, 100);
final CacheManager manager = new CacheManager(this.getClass().getClassLoader().getResourceAsStream("ehcacheClearPass.xml"));
manager.addCache(serviceTicketsCache);
manager.addCache(ticketGrantingTicketCache);
final Map<String, String> map = new HashMap<>();
final TicketRegistry ticketRegistry = new EhCacheTicketRegistry(serviceTicketsCache, ticketGrantingTicketCache);
final TicketRegistryDecorator decorator = new TicketRegistryDecorator(ticketRegistry, map);
assertNotNull(decorator);
assertEquals(decorator.serviceTicketCount(), 0);
assertEquals(decorator.sessionCount(), 0);
manager.removalAll();
manager.shutdown();
}
示例3: testEhCacheTicketRegistryWithClearPass
import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
@Test
public void testEhCacheTicketRegistryWithClearPass() {
final Cache serviceTicketsCache = new Cache("serviceTicketsCache", 200, false, false, 100, 100);
final Cache ticketGrantingTicketCache = new Cache("ticketGrantingTicketCache", 200, false, false, 100, 100);
final CacheManager manager = new CacheManager(this.getClass().getClassLoader().getResourceAsStream("ehcacheClearPass.xml"));
manager.addCache(serviceTicketsCache);
manager.addCache(ticketGrantingTicketCache);
final Map<String, String> map = new HashMap<String, String>();
final TicketRegistry ticketRegistry = new EhCacheTicketRegistry(serviceTicketsCache, ticketGrantingTicketCache);
final TicketRegistryDecorator decorator = new TicketRegistryDecorator(ticketRegistry, map);
assertNotNull(decorator);
assertEquals(decorator.serviceTicketCount(), 0);
assertEquals(decorator.sessionCount(), 0);
manager.removalAll();
manager.shutdown();
}
示例4: createCachePool
import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
@Override
public CachePool createCachePool(String poolName, int cacheSize,
int expiredSeconds) {
CacheManager cacheManager = CacheManager.create();
Cache enCache = cacheManager.getCache(poolName);
if (enCache == null) {
CacheConfiguration cacheConf = cacheManager.getConfiguration().getDefaultCacheConfiguration().clone();
cacheConf.setName(poolName);
if (cacheConf.getMaxEntriesLocalHeap() != 0) {
cacheConf.setMaxEntriesLocalHeap(cacheSize);
} else {
cacheConf.setMaxBytesLocalHeap(String.valueOf(cacheSize));
}
cacheConf.setTimeToIdleSeconds(expiredSeconds);
Cache cache = new Cache(cacheConf);
cacheManager.addCache(cache);
return new EnchachePool(poolName, cache, cacheSize);
} else {
return new EnchachePool(poolName, enCache, cacheSize);
}
}
示例5: RealCache
import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
public RealCache() {
super();
CacheManager manager = null;
synchronized (RealCache.class) {
manager = CacheManager.getInstance();
if (!manager.cacheExists("AFPDataGrabberCache")) {
Cache cache = new Cache(new CacheConfiguration("AFPDataGrabberCache", 50000).memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU)
.eternal(true).timeToLiveSeconds(0).timeToIdleSeconds(0).persistence(new PersistenceConfiguration().strategy(Strategy.NONE)));
manager.addCache(cache);
}
}
ehcache = manager.getCache("AFPDataGrabberCache");
}
示例6: cacheExposesMetrics
import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
@Test
void cacheExposesMetrics() {
CacheManager cacheManager = CacheManager.newInstance();
cacheManager.addCache("a");
Cache c = cacheManager.getCache("a");
MeterRegistry registry = new SimpleMeterRegistry();
EhCache2Metrics.monitor(registry, c, "ehcache", emptyList());
c.put(new Element("k", "v", 1));
registry.mustFind("ehcache.size").tags("name", "a").gauge();
}
示例7: createCache
import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
private static Cache createCache(CacheManager manager, String name, Consumer<CacheConfiguration> configurationConsumer) {
CacheConfiguration configuration = new CacheConfiguration(name, MAX_ENTRIES);
configurationConsumer.accept(configuration);
Cache cache = new Cache(configuration);
manager.addCache(cache);
return cache;
}
示例8: onSetUpInTransaction
import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
protected void onSetUpInTransaction() {
// make a cache
CacheManager cacheManager = CacheManager.create();
if (! cacheManager.cacheExists("ehcache.sakai.kaltura.entries")) {
cacheManager.addCache("ehcache.sakai.kaltura.entries");
}
Ehcache entriesCache = cacheManager.getCache("ehcache.sakai.kaltura.entries");
// create and setup the object to be tested
external = new ExternalLogicStub();
service = new KalturaAPIService();
service.setExternal(external);
service.setEntriesCache(entriesCache);
service.setOffline(true); // for testing we do not try to fetch real data
// run the init
external.currentUserId = FakeDataPreload.ADMIN_USER_ID; // DEFAULT ADMIN
// UNICON settings for testing
external.config.put("kaltura.partnerid", 166762);
external.config.put("kaltura.adminsecret", "26d08a0ba54c911492bbc7599028295f");
external.config.put("kaltura.secret", "6e4755b613a38b19e4cfb5d7405ed170");
service.testWSInit(); // SPECIAL INIT
service.getKalturaClient();
}
示例9: setUp
import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
// THIS IS EXECUTED BEFORE EACH TEST
// make the caches
CacheManager cacheManager = CacheManager.create();
if (! cacheManager.cacheExists("ehcache.sakai.kaltura.entries")) {
cacheManager.addCache("ehcache.sakai.kaltura.entries");
}
Ehcache entriesCache = cacheManager.getCache("ehcache.sakai.kaltura.entries");
if (! cacheManager.cacheExists("ehcache.sakai.kaltura.cats")) {
cacheManager.addCache("ehcache.sakai.kaltura.cats");
}
Ehcache categoriesCache = cacheManager.getCache("ehcache.sakai.kaltura.cats");
// create and setup the object to be tested
external = new ExternalLogicStub();
kalturaAPIService = new KalturaAPIServiceStub(external, entriesCache, categoriesCache);
kalturaAPIService.setKalturaClippingEnabled(true); // for testing
service = new MediaService();
service.setExternal(external);
service.setKalturaAPIService(kalturaAPIService);
service.setEntriesCache(entriesCache);
service.setForceMediaNameOrdering(false);
// run the init
service.init();
}
示例10: createLifeCache
import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
static Cache createLifeCache(CacheManager manager, String name) {
CacheConfiguration configuration = new CacheConfiguration(name, MAX_ENTRIES);
configuration.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.FIFO)
.timeToLiveSeconds(LIFE_TIME_SEC);
Cache cache = new Cache(configuration);
manager.addCache(cache);
return cache;
}
示例11: createIdleCache
import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
static Cache createIdleCache(CacheManager manager, String name) {
CacheConfiguration configuration = new CacheConfiguration(name, MAX_ENTRIES);
configuration.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.FIFO)
.timeToIdleSeconds(IDLE_TIME_SEC);
Cache cache = new Cache(configuration);
manager.addCache(cache);
return cache;
}
示例12: createEternalCache
import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
static Cache createEternalCache(CacheManager manager, String name) {
CacheConfiguration configuration = new CacheConfiguration(name, MAX_ENTRIES);
configuration.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.FIFO)
.eternal(true);
Cache cache = new Cache(configuration);
manager.addCache(cache);
return cache;
}
示例13: createCache
import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
public static Cache createCache(final CacheManager cacheManager, final Cache cache) throws CacheException {
cacheManager.addCache(cache);
return cacheManager.getCache(cache.getName());
}