本文整理汇总了Java中org.springframework.cache.ehcache.EhCacheFactoryBean类的典型用法代码示例。如果您正苦于以下问题:Java EhCacheFactoryBean类的具体用法?Java EhCacheFactoryBean怎么用?Java EhCacheFactoryBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EhCacheFactoryBean类属于org.springframework.cache.ehcache包,在下文中一共展示了EhCacheFactoryBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
this.blockingDhtCache = new BlockingDhtCache();
EhCacheFactoryBean ehCacheFactoryBean = new EhCacheFactoryBean();
ehCacheFactoryBean.setCacheName("unittest");
ehCacheFactoryBean.afterPropertiesSet();
this.cache = (Cache) ehCacheFactoryBean.getObject();
this.blockingDhtCache.setCache(this.cache);
this.dhtClientFactory = mock(DhtClientFactory.class);
this.blockingDhtCache.setDhtClientFactory(this.dhtClientFactory);
this.id = mock(PId.class);
when(this.id.toStringFull()).thenReturn("" + System.currentTimeMillis());
this.piEntity = mock(PiEntity.class);
this.blockingReader = mock(BlockingDhtReader.class);
when(this.dhtClientFactory.createBlockingReader()).thenReturn(this.blockingReader);
this.blockingWriter = mock(BlockingDhtWriter.class);
when(this.dhtClientFactory.createBlockingWriter()).thenReturn(this.blockingWriter);
}
示例2: testThatCacheDoesExpire
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Ignore("because this is just testing ehcache which hopefully works anyhow")
@Test
public void testThatCacheDoesExpire() throws Exception {
// setup
int ttl = 2;
EhCacheFactoryBean ehCacheFactoryBean = new EhCacheFactoryBean();
ehCacheFactoryBean.setCacheName("unittest1");
ehCacheFactoryBean.setTimeToIdle(ttl);
ehCacheFactoryBean.setTimeToLive(ttl);
ehCacheFactoryBean.afterPropertiesSet();
this.cache = (Cache) ehCacheFactoryBean.getObject();
this.blockingDhtCache.setCache(this.cache);
when(this.blockingReader.get(id)).thenReturn(piEntity);
// act
PiEntity result = this.blockingDhtCache.get(id);
assertEquals(this.piEntity, result);
Thread.sleep(ttl * 2 * 1000);
result = this.blockingDhtCache.get(id);
assertEquals(this.piEntity, result);
// assert
verify(this.blockingReader, times(2)).get(id);
}
示例3: ehcacheTicketsCache
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Lazy
@Autowired
@Bean
public EhCacheFactoryBean ehcacheTicketsCache(@Qualifier("cacheManager") final CacheManager manager) {
final EhcacheProperties ehcacheProperties = casProperties.getTicket().getRegistry().getEhcache();
final EhCacheFactoryBean bean = new EhCacheFactoryBean();
bean.setCacheName(ehcacheProperties.getCacheName());
bean.setCacheEventListeners(Collections.singleton(ticketRMISynchronousCacheReplicator()));
bean.setTimeToIdle(ehcacheProperties.getCacheTimeToIdle());
bean.setTimeToLive(ehcacheProperties.getCacheTimeToLive());
bean.setCacheManager(manager);
bean.setBootstrapCacheLoader(ticketCacheBootstrapCacheLoader());
bean.setDiskExpiryThreadIntervalSeconds(ehcacheProperties.getDiskExpiryThreadIntervalSeconds());
bean.setEternal(ehcacheProperties.isEternal());
bean.setMaxEntriesLocalHeap(ehcacheProperties.getMaxElementsInMemory());
bean.setMaxEntriesInCache(ehcacheProperties.getMaxElementsInCache());
bean.setMaxEntriesLocalDisk(ehcacheProperties.getMaxElementsOnDisk());
bean.setMemoryStoreEvictionPolicy(ehcacheProperties.getMemoryStoreEvictionPolicy());
final PersistenceConfiguration c = new PersistenceConfiguration();
c.strategy(ehcacheProperties.getPersistence());
c.setSynchronousWrites(ehcacheProperties.isSynchronousWrites());
bean.persistence(c);
return bean;
}
示例4: ehcache
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Bean
public Ehcache ehcache(){
EhCacheFactoryBean cacheFactoryBean = new EhCacheFactoryBean();
cacheFactoryBean.setCacheManager(cacheManager());
cacheFactoryBean.setCacheName("aclCache");
cacheFactoryBean.setMaxBytesLocalHeap("1M");
cacheFactoryBean.setMaxEntriesLocalHeap(0L);
cacheFactoryBean.afterPropertiesSet();
return cacheFactoryBean.getObject();
}
示例5: clusterEhcache
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Bean
public EhCacheFactoryBean clusterEhcache() {
EhCacheFactoryBean factory = new EhCacheFactoryBean();
factory.setCacheName("clusterCache");
factory.setCacheManager(cacheManager);
return factory;
}
示例6: alarmEhcache
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Bean
public EhCacheFactoryBean alarmEhcache(CacheManager cacheManager) {
EhCacheFactoryBean factory = new EhCacheFactoryBean();
factory.setCacheName("alarmCache");
factory.setCacheManager(cacheManager);
return factory;
}
示例7: commandTagEhcache
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Bean
public EhCacheFactoryBean commandTagEhcache(CacheManager cacheManager) {
EhCacheFactoryBean factory = new EhCacheFactoryBean();
factory.setCacheName("commandCache");
factory.setCacheManager(cacheManager);
return factory;
}
示例8: deviceEhcache
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Bean
public EhCacheFactoryBean deviceEhcache(CacheManager cacheManager) {
EhCacheFactoryBean factory = new EhCacheFactoryBean();
factory.setCacheName("deviceCache");
factory.setCacheManager(cacheManager);
return factory;
}
示例9: processEhcache
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Bean
public EhCacheFactoryBean processEhcache(CacheManager cacheManager) {
EhCacheFactoryBean factory = new EhCacheFactoryBean();
factory.setCacheName("processCache");
factory.setCacheManager(cacheManager);
return factory;
}
示例10: deviceClassEhcache
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Bean
public EhCacheFactoryBean deviceClassEhcache(CacheManager cacheManager) {
EhCacheFactoryBean factory = new EhCacheFactoryBean();
factory.setCacheName("deviceClassCache");
factory.setCacheManager(cacheManager);
return factory;
}
示例11: dataTagEhcache
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Bean
public EhCacheFactoryBean dataTagEhcache(CacheManager cacheManager) {
EhCacheFactoryBean factory = new EhCacheFactoryBean();
factory.setCacheName("tagCache");
factory.setCacheManager(cacheManager);
return factory;
}
示例12: ruleTagEhcache
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Bean
public EhCacheFactoryBean ruleTagEhcache(CacheManager cacheManager) {
EhCacheFactoryBean factory = new EhCacheFactoryBean();
factory.setCacheName("ruleCache");
factory.setCacheManager(cacheManager);
return factory;
}
示例13: controlTagEhcache
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Bean
public EhCacheFactoryBean controlTagEhcache(CacheManager cacheManager) {
EhCacheFactoryBean factory = new EhCacheFactoryBean();
factory.setCacheName("controlCache");
factory.setCacheManager(cacheManager);
return factory;
}
示例14: equipmentEhcache
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Bean
public EhCacheFactoryBean equipmentEhcache(CacheManager cacheManager) {
EhCacheFactoryBean factory = new EhCacheFactoryBean();
factory.setCacheName("equipmentCache");
factory.setCacheManager(cacheManager);
return factory;
}
示例15: subEquipmentEhcache
import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入依赖的package包/类
@Bean
public EhCacheFactoryBean subEquipmentEhcache(CacheManager cacheManager) {
EhCacheFactoryBean factory = new EhCacheFactoryBean();
factory.setCacheName("subEquipmentCache");
factory.setCacheManager(cacheManager);
return factory;
}