本文整理汇总了Java中net.sf.ehcache.constructs.blocking.CacheEntryFactory类的典型用法代码示例。如果您正苦于以下问题:Java CacheEntryFactory类的具体用法?Java CacheEntryFactory怎么用?Java CacheEntryFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CacheEntryFactory类属于net.sf.ehcache.constructs.blocking包,在下文中一共展示了CacheEntryFactory类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testEhCacheFactoryBeanWithSelfPopulatingCache
import net.sf.ehcache.constructs.blocking.CacheEntryFactory; //导入依赖的package包/类
@Test
public void testEhCacheFactoryBeanWithSelfPopulatingCache() throws Exception {
EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean();
cacheManagerFb.afterPropertiesSet();
try {
CacheManager cm = cacheManagerFb.getObject();
EhCacheFactoryBean cacheFb = new EhCacheFactoryBean();
cacheFb.setCacheManager(cm);
cacheFb.setCacheName("myCache1");
cacheFb.setCacheEntryFactory(new CacheEntryFactory() {
@Override
public Object createEntry(Object key) throws Exception {
return key;
}
});
assertEquals(cacheFb.getObjectType(), SelfPopulatingCache.class);
cacheFb.afterPropertiesSet();
Ehcache myCache1 = cm.getEhcache("myCache1");
assertTrue(myCache1 instanceof SelfPopulatingCache);
assertEquals("myKey1", myCache1.get("myKey1").getValue());
}
finally {
cacheManagerFb.destroy();
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:EhCacheSupportTests.java
示例2: testEhCacheFactoryBeanWithSelfPopulatingCache
import net.sf.ehcache.constructs.blocking.CacheEntryFactory; //导入依赖的package包/类
public void testEhCacheFactoryBeanWithSelfPopulatingCache() throws Exception {
EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean();
cacheManagerFb.afterPropertiesSet();
try {
CacheManager cm = cacheManagerFb.getObject();
EhCacheFactoryBean cacheFb = new EhCacheFactoryBean();
cacheFb.setCacheManager(cm);
cacheFb.setCacheName("myCache1");
cacheFb.setCacheEntryFactory(new CacheEntryFactory() {
@Override
public Object createEntry(Object key) throws Exception {
return key;
}
});
assertEquals(cacheFb.getObjectType(), SelfPopulatingCache.class);
cacheFb.afterPropertiesSet();
Ehcache myCache1 = cm.getEhcache("myCache1");
assertTrue(myCache1 instanceof SelfPopulatingCache);
assertEquals("myKey1", myCache1.get("myKey1").getValue());
}
finally {
cacheManagerFb.destroy();
}
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:25,代码来源:EhCacheSupportTests.java
示例3: createLoadingCache
import net.sf.ehcache.constructs.blocking.CacheEntryFactory; //导入依赖的package包/类
@Override
public <K, V> LoadingBenchmarkCache<K, V> createLoadingCache(
final Class<K> _keyType, final Class<V> _valueType,
final int _maxElements, final BenchmarkCacheSource<K, V> _source) {
MyLoadingBenchmarkCache c = new MyLoadingBenchmarkCache();
Ehcache ehc = new Cache(createCacheConfiguration(_maxElements));
getManager().addCache(ehc);
int _cpus = Runtime.getRuntime().availableProcessors();
int _stripes = cpuCount2StripeCount(_cpus * 2);
c.cache = new SelfPopulatingCache(ehc,
_stripes,
new CacheEntryFactory() {
@Override
public Object createEntry(final Object key) throws Exception {
return _source.load((K) key);
}
});
c.size = _maxElements;
return c;
}
开发者ID:cache2k,项目名称:cache2k-benchmark,代码行数:21,代码来源:EhCache2Factory.java
示例4: createInMemoryCache
import net.sf.ehcache.constructs.blocking.CacheEntryFactory; //导入依赖的package包/类
public static Ehcache createInMemoryCache(String cacheName, CacheEntryFactory entryFactory, int maxElements) {
CacheManager manager = CacheManager.getInstance();
Ehcache cache = getCache(cacheName);
if (cache == null) {
// Create the cache
cache = new Cache(cacheName,
maxElements,
memoryStoreEvictionPolicy, overflowToDisk,
diskStorePath, eternal, timeToLive,
timeToIdle, diskPersistent,
diskExpiryThreadIntervalSeconds, null);
// Associate the cacheEntryFactory with the cache
SelfPopulatingCache selfPopulatingCache = new SelfPopulatingCache(cache,
entryFactory);
// Add any additional listener properties
if (manager.getCachePeerListener("RMI") != null) {
LOG.info("Setting RMI properties");
Properties properties = new Properties();
properties.put("replicateAsynchronously", "true");
properties.put("replicatePuts", "false");
properties.put("replicateUpdates", "true");
properties.put("replicateRemovals", "true");
properties.put("replicateUpdatesViaCopy", "false");
properties.put("asynchronousReplicationIntervalMillis", "1000");
RMICacheReplicatorFactory factory = new RMICacheReplicatorFactory();
CacheEventListener listener = factory.createCacheEventListener(properties);
selfPopulatingCache.getCacheEventNotificationService().registerListener(listener);
RMIBootstrapCacheLoaderFactory bootstrapFactory = new RMIBootstrapCacheLoaderFactory();
BootstrapCacheLoader bootstrapCacheLoader = bootstrapFactory.createBootstrapCacheLoader(new Properties());
selfPopulatingCache.setBootstrapCacheLoader(bootstrapCacheLoader);
LOG.debug("RMI enabled");
}
// Make the cache available
manager.addCache(selfPopulatingCache);
LOG.info("cache created: " + cache.getName());
}
return cache;
}
开发者ID:Concursive,项目名称:concourseconnect-community,代码行数:39,代码来源:CacheUtils.java
示例5: createCache
import net.sf.ehcache.constructs.blocking.CacheEntryFactory; //导入依赖的package包/类
public static SelfPopulatingCache createCache(String ehcachename, CacheEntryFactory cu) {
Logger.getLogger(SPCacheFactory.class.getName()).log(Level.INFO, "Setting up cache... {0}", ehcachename);
MulticastKeepaliveHeartbeatSender.setHeartBeatInterval(1000);
Logger.getLogger(SPCacheFactory.class.getName()).log(Level.INFO, "Waiting cluster {0}", manager.getName());
SPCacheFactory.waitForClusterMembership(10, TimeUnit.SECONDS, Collections.singleton(ehcachename), manager);
Logger.getLogger(SPCacheFactory.class.getName()).log(Level.INFO, "Cluster connected.");
Cache orig_ehcache = manager.getCache(ehcachename);
if (orig_ehcache == null) {
return null;
}
orig_ehcache.bootstrap();
SelfPopulatingCache ehcache = new SelfPopulatingCache(orig_ehcache, cu);
ehcache.bootstrap();
return ehcache;
}
开发者ID:framegrace,项目名称:beume,代码行数:16,代码来源:SPCacheFactory.java
示例6: getCacheEntryFactory
import net.sf.ehcache.constructs.blocking.CacheEntryFactory; //导入依赖的package包/类
public CacheEntryFactory getCacheEntryFactory() {
return cacheEntryFactory;
}
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:4,代码来源:EhCacheCachingModel.java
示例7: setCacheEntryFactory
import net.sf.ehcache.constructs.blocking.CacheEntryFactory; //导入依赖的package包/类
/**
* Set an EhCache {@link net.sf.ehcache.constructs.blocking.CacheEntryFactory}
* to use for a self-populating cache. If such a factory is specified,
* the cache will be decorated with EhCache's
* {@link net.sf.ehcache.constructs.blocking.SelfPopulatingCache}.
* <p>The specified factory can be of type
* {@link net.sf.ehcache.constructs.blocking.UpdatingCacheEntryFactory},
* which will lead to the use of an
* {@link net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache}.
* <p>Note: Any such self-populating cache is automatically a blocking cache.
* @see net.sf.ehcache.constructs.blocking.SelfPopulatingCache
* @see net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache
* @see net.sf.ehcache.constructs.blocking.UpdatingCacheEntryFactory
*/
public void setCacheEntryFactory(CacheEntryFactory cacheEntryFactory) {
this.cacheEntryFactory = cacheEntryFactory;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:EhCacheFactoryBean.java
示例8: setCacheEntryFactory
import net.sf.ehcache.constructs.blocking.CacheEntryFactory; //导入依赖的package包/类
/**
* Set an EHCache {@link net.sf.ehcache.constructs.blocking.CacheEntryFactory}
* to use for a self-populating cache. If such a factory is specified,
* the cache will be decorated with EHCache's
* {@link net.sf.ehcache.constructs.blocking.SelfPopulatingCache}.
* <p>The specified factory can be of type
* {@link net.sf.ehcache.constructs.blocking.UpdatingCacheEntryFactory},
* which will lead to the use of an
* {@link net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache}.
* <p>Note: Any such self-populating cache is automatically a blocking cache.
*
* @see net.sf.ehcache.constructs.blocking.SelfPopulatingCache
* @see net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache
* @see net.sf.ehcache.constructs.blocking.UpdatingCacheEntryFactory
* @see org.springframework.cache.ehcache.EhCacheFactoryBean#setCacheEntryFactory(net.sf.ehcache.constructs.blocking.CacheEntryFactory)
*/
public void setCacheEntryFactory(CacheEntryFactory cacheEntryFactory) {
this.cacheEntryFactory = cacheEntryFactory;
}
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:20,代码来源:EhCacheCachingModel.java
注:本文中的net.sf.ehcache.constructs.blocking.CacheEntryFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论