• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SelfPopulatingCache类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.sf.ehcache.constructs.blocking.SelfPopulatingCache的典型用法代码示例。如果您正苦于以下问题:Java SelfPopulatingCache类的具体用法?Java SelfPopulatingCache怎么用?Java SelfPopulatingCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SelfPopulatingCache类属于net.sf.ehcache.constructs.blocking包,在下文中一共展示了SelfPopulatingCache类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getObjectType

import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; //导入依赖的package包/类
/**
 * Predict the particular {@code Ehcache} implementation that will be returned from
 * {@link #getObject()} based on logic in {@link #createCache()} and
 * {@link #decorateCache(Ehcache)} as orchestrated by {@link #afterPropertiesSet()}.
 */
@Override
public Class<? extends Ehcache> getObjectType() {
	if (this.cache != null) {
		return this.cache.getClass();
	}
	if (this.cacheEntryFactory != null) {
		if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) {
			return UpdatingSelfPopulatingCache.class;
		}
		else {
			return SelfPopulatingCache.class;
		}
	}
	if (this.blocking) {
		return BlockingCache.class;
	}
	return Cache.class;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:EhCacheFactoryBean.java


示例2: testEhCacheFactoryBeanWithSelfPopulatingCache

import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; //导入依赖的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


示例3: getObjectType

import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; //导入依赖的package包/类
/**
 * Predict the particular {@code Ehcache} implementation that will be returned from
 * {@link #getObject()} based on logic in {@link #createCache()} and
 * {@link #decorateCache(Ehcache)} as orchestrated by {@link #afterPropertiesSet()}.
 */
public Class<? extends Ehcache> getObjectType() {
	if (this.cache != null) {
		return this.cache.getClass();
	}
	if (this.cacheEntryFactory != null) {
		if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) {
			return UpdatingSelfPopulatingCache.class;
		}
		else {
			return SelfPopulatingCache.class;
		}
	}
	if (this.blocking) {
		return BlockingCache.class;
	}
	return Cache.class;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:23,代码来源:EhCacheFactoryBean.java


示例4: testEhCacheFactoryBeanWithSelfPopulatingCache

import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; //导入依赖的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


示例5: createLoadingCache

import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; //导入依赖的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


示例6: decorateCache

import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; //导入依赖的package包/类
/**
 * Decorate the given Cache, if necessary.
 * @param cache the raw Cache object, based on the configuration of this FactoryBean
 * @return the (potentially decorated) cache object to be registered with the CacheManager
 */
protected Ehcache decorateCache(Ehcache cache) {
	if (this.cacheEntryFactory != null) {
		if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) {
			return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) this.cacheEntryFactory);
		}
		else {
			return new SelfPopulatingCache(cache, this.cacheEntryFactory);
		}
	}
	if (this.blocking) {
		return new BlockingCache(cache);
	}
	return cache;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:EhCacheFactoryBean.java


示例7: AbstractEHCachingMaster

import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; //导入依赖的package包/类
/**
 * Creates an instance over an underlying source specifying the cache manager.
 *
 * @param name          the cache name, not empty
 * @param underlying    the underlying source, not null
 * @param cacheManager  the cache manager, not null
 */
public AbstractEHCachingMaster(final String name, final AbstractChangeProvidingMaster<D> underlying, final CacheManager cacheManager) {
  ArgumentChecker.notEmpty(name, "name");
  ArgumentChecker.notNull(underlying, "underlying");
  ArgumentChecker.notNull(cacheManager, "cacheManager");

  _underlying = underlying;
  _cacheManager = cacheManager;

  // Load cache configuration
  if (cacheManager.getCache(name + CACHE_NAME_SUFFIX) == null) {
    // If cache config not found, set up programmatically
    s_logger.warn("Could not load a cache configuration for " + name + CACHE_NAME_SUFFIX
                + ", building a default configuration programmatically instead");
    getCacheManager().addCache(new Cache(tweakCacheConfiguration(new CacheConfiguration(name + CACHE_NAME_SUFFIX,
                                                                                        10000))));
  }
  _uidToDocumentCache = new SelfPopulatingCache(_cacheManager.getCache(name + CACHE_NAME_SUFFIX),
                                                new UidToDocumentCacheEntryFactory<>(_underlying));
  getCacheManager().replaceCacheWithDecoratedCache(_cacheManager.getCache(name + CACHE_NAME_SUFFIX),
                                                   getUidToDocumentCache());

  // Listen to change events from underlying, clean this cache accordingly and relay events to our change listeners
  _changeManager = new BasicChangeManager();
  _changeListener = new ChangeListener() {
    @Override
    public void entityChanged(ChangeEvent event) {
      final ObjectId oid = event.getObjectId();
      final Instant versionFrom = event.getVersionFrom();
      final Instant versionTo = event.getVersionTo();
      cleanCaches(oid, versionFrom, versionTo);
      _changeManager.entityChanged(event.getType(), event.getObjectId(),
          event.getVersionFrom(), event.getVersionTo(), event.getVersionInstant());
    }
  };
  underlying.changeManager().addChangeListener(_changeListener);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:44,代码来源:AbstractEHCachingMaster.java


示例8: decorateCache

import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; //导入依赖的package包/类
/**
 * Decorate the given Cache, if necessary.
 * <p>The default implementation simply returns the given cache object as-is.
 *
 * @param cache the raw Cache object, based on the configuration of this FactoryBean
 * @param model the model containing the name of the cache to retrieve
 * @return the (potentially decorated) cache object to be registered with the CacheManager
 */
protected Ehcache decorateCache(Cache cache, EhCacheCachingModel model) {
	if (model.getCacheEntryFactory() != null) {
		if (model.getCacheEntryFactory() instanceof UpdatingCacheEntryFactory) {
			return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) model.getCacheEntryFactory());
		} else {
			return new SelfPopulatingCache(cache, model.getCacheEntryFactory());
		}
	}
	if (model.isBlocking()) {
		return new BlockingCache(cache);
	}
	return cache;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:22,代码来源:EhCacheFacade.java


示例9: createInMemoryCache

import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; //导入依赖的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


示例10: createCache

import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; //导入依赖的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


示例11: FrontCacheUpdater

import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; //导入依赖的package包/类
public FrontCacheUpdater(SelfPopulatingCache back) {
    backCache = back;
}
 
开发者ID:framegrace,项目名称:beume,代码行数:4,代码来源:FrontCacheUpdater.java


示例12: MyDataAccessClass

import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; //导入依赖的package包/类
public MyDataAccessClass(Ehcache cache)
{
    cache.registerCacheWriter(new MyCacheWriter());
    this.cache = new SelfPopulatingCache(cache,new MyCacheEntryFactory());
}
 
开发者ID:yaohuiwu,项目名称:CAM,代码行数:6,代码来源:MyDataAccessClass.java


示例13: EhCacheCache

import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; //导入依赖的package包/类
/**
 * Create new cache.
 *
 * @param cache Cache where computed values are stored.
 * @param parser Parser to compute concrete {@link ReadableUserAgent} instances.
 */
public EhCacheCache(Ehcache cache, UserAgentStringParser parser) {
	super(parser);
	this.cache = new SelfPopulatingCache(cache, new EhCacheEntryFactory(parser));
}
 
开发者ID:mjeanroy,项目名称:springmvc-uadetector,代码行数:11,代码来源:EhCacheCache.java



注:本文中的net.sf.ehcache.constructs.blocking.SelfPopulatingCache类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java S08PacketPlayerPosLook类代码示例发布时间:2022-05-22
下一篇:
Java EndpointState类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap