当前位置: 首页>>代码示例>>Java>>正文


Java MemoryStoreEvictionPolicy类代码示例

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


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

示例1: EhCacheWrapper

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的package包/类
/**
 * http://www.ehcache.org/documentation/2.8/code-samples.html#creating-caches-programmatically
 */
EhCacheWrapper(String cacheName) {
    AppConfiguration.Cache config = AppConfiguration.CONFIG.getCache();

    // Create a Cache specifying its configuration
    cache = new Cache(
            new CacheConfiguration(cacheName, config.getMaxSize())
                    .timeToLiveSeconds(TimeUnit.MINUTES.toSeconds(config.getLifeTime()))
                    .eternal(false)
                    .persistence(new PersistenceConfiguration().strategy(Strategy.NONE))
                    .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.FIFO)
    );

    // The cache is not usable until it has been added
    manager.addCache(cache);
}
 
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:19,代码来源:EhCacheWrapper.java

示例2: init

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的package包/类
@Override
public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
  NonVersionedRedisSecuritySource source = new NonVersionedRedisSecuritySource(getRedisConnector().getJedisPool(), getRedisPrefix());
  SecuritySource rawSource = source;
  
  if ((getCacheManager() != null) && (getLruCacheElements() > 0)) {
    Cache cache = new Cache("NonVersionedRedisSecuritySource", getLruCacheElements(), MemoryStoreEvictionPolicy.LRU, false, null, true, -1L, -1L, false, -1L, null);
    getCacheManager().addCache(cache);
    rawSource = new NonVersionedEHCachingSecuritySource(source, cache);
  }
  
  String rawClassifier = getCachingClassifier() != null ? getCachingClassifier() : getClassifier();
  
  ComponentInfo sourceInfo = new ComponentInfo(SecuritySource.class, rawClassifier);
  sourceInfo.addAttribute(ComponentInfoAttributes.LEVEL, 1);
  sourceInfo.addAttribute(ComponentInfoAttributes.REMOTE_CLIENT_JAVA, RemoteSecuritySource.class);
  repo.registerComponent(sourceInfo, rawSource);

  ComponentInfo redisInfo = new ComponentInfo(NonVersionedRedisSecuritySource.class, getClassifier());
  redisInfo.addAttribute(ComponentInfoAttributes.LEVEL, 1);
  repo.registerComponent(redisInfo, source);
  
  if (isPublishRest()) {
    repo.getRestComponents().publish(sourceInfo, new DataSecuritySourceResource(rawSource));
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:27,代码来源:NonVersionedRedisSecuritySourceComponentFactory.java

示例3: setCacheValue

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的package包/类
public void setCacheValue(String cacheName, String keyName, Collection<Attribute> attrs, int tti, int ttl) {
  CacheManager manager = Context.getInstance().getCacheManager();
  Cache cache = manager.getCache(cacheName);
  if (cache == null) {      
    cache = new Cache(
        new CacheConfiguration(cacheName, 1000)
          .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU)
          .eternal(false)
          .timeToLiveSeconds(60)
          .timeToIdleSeconds(60)
          .diskExpiryThreadIntervalSeconds(120)
          .persistence(new PersistenceConfiguration().strategy(Strategy.LOCALTEMPSWAP)));
    manager.addCache(cache);
  }            
  cache.put(new net.sf.ehcache.Element(keyName, attrs, false, tti, ttl));
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:17,代码来源:WebApp.java

示例4: getOrCreateCache

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的package包/类
private Cache getOrCreateCache() {
	// Create a singleton CacheManager using defaults
	CacheManager manager = CacheManager.create();
	// Create a Cache specifying its configuration
	Cache c = manager.getCache(CACHE_name);
	if (c == null) {
		c = new Cache(new CacheConfiguration(CACHE_name,
				CACHE_maxEntriesLocalHeap)
				.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU)
				.eternal(true)
				.persistence(
						new PersistenceConfiguration()
								.strategy(Strategy.LOCALTEMPSWAP)));
		manager.addCache(c);
	}
	return c;
}
 
开发者ID:namsor,项目名称:rapidminer-onomastics-extension,代码行数:18,代码来源:ExtractOriginOperator.java

示例5: initCacheEhcacheBigMemory

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的package包/类
/**
 * Inits the cache ehcache big memory.
 */
@SuppressWarnings("deprecation")
 private static void initCacheEhcacheBigMemory() {
	// Create a CacheManager using defaults
	sEhcacheManager = CacheManager.create();

	// Create a Cache specifying its configuration.

	sEhcacheCache = new Cache(new CacheConfiguration("test", 10000)
			.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU)
			.overflowToDisk(false).eternal(false).timeToLiveSeconds(6000)
			.timeToIdleSeconds(6000).diskPersistent(false)
			.diskExpiryThreadIntervalSeconds(0).overflowToOffHeap(true)
			.maxMemoryOffHeap(sBigMemorySize));
	sEhcacheManager.addCache(sEhcacheCache);

}
 
开发者ID:VladRodionov,项目名称:bigbase,代码行数:20,代码来源:PerfTest.java

示例6: initCacheEhcache

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的package包/类
/**
 * Inits the cache ehcache.
 */
@SuppressWarnings("deprecation")
 private static void initCacheEhcache() {
	// Create a CacheManager using defaults
	sEhcacheManager = CacheManager.create();

	// Create a Cache specifying its configuration.

	sEhcacheCache = new Cache(new CacheConfiguration("test",
			(int) sCacheItemsLimit).memoryStoreEvictionPolicy(
			MemoryStoreEvictionPolicy.LRU).overflowToDisk(false).eternal(
			false).timeToLiveSeconds(6000).timeToIdleSeconds(6000)
			.diskPersistent(false).diskExpiryThreadIntervalSeconds(0));
	sEhcacheManager.addCache(sEhcacheCache);

}
 
开发者ID:VladRodionov,项目名称:bigbase,代码行数:19,代码来源:PerfTest.java

示例7: LocalCacheManager

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的package包/类
public LocalCacheManager(String name, int max, int exptime, boolean copyOnRead, boolean copyOnWrite) {
	this.cache = CacheManager.getInstance().getCache(name);
	if (cache == null) {
		CacheConfiguration config =
						new CacheConfiguration(name, max)
						.copyOnRead(copyOnRead)
						.copyOnWrite(copyOnWrite)
						.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU)
						.eternal(false)
						.timeToLiveSeconds(exptime)
						.timeToIdleSeconds(exptime)
						.diskExpiryThreadIntervalSeconds(60)
						.persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.NONE));
		this.cache = new Cache(config, null, null);
		CacheManager.getInstance().addCache(cache);
		
		if (logger.isInfoEnabled()) {
			logger.info("Arcus k/v local cache is enabled : %s", cache.toString());
		}
	}
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:22,代码来源:LocalCacheManager.java

示例8: open

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的package包/类
public void open() {
	Cache configCache = new Cache(
			getName(),
			getMaxElementsInMemory(),
			MemoryStoreEvictionPolicy.fromString(getMemoryStoreEvictionPolicy()),
			isOverflowToDisk(),
			null,
			isEternal(),
			getTimeToLiveSeconds(),
			getTimeToIdleSeconds(),
			isDiskPersistent(),
			getDiskExpiryThreadIntervalSeconds(),
			null,
			null,
			getMaxElementsOnDisk()
			);
	cacheManager=IbisCacheManager.getInstance();
	cache = cacheManager.addCache(configCache);
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:20,代码来源:EhCache.java

示例9: createCacheConfiguration

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的package包/类
protected CacheConfiguration createCacheConfiguration(int _maxElements) {
  MemoryStoreEvictionPolicy _policy = MemoryStoreEvictionPolicy.LRU;
  switch (algorithm) {
    case CLOCK: _policy = MemoryStoreEvictionPolicy.CLOCK; break;
  }
  CacheConfiguration c = new CacheConfiguration(CACHE_NAME, _maxElements)
    .memoryStoreEvictionPolicy(_policy)
    .eternal(true)
    .diskExpiryThreadIntervalSeconds(0)
    .persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.NONE));
  if (withExpiry) {
    c.setEternal(false);
    c.setTimeToLiveSeconds(5 * 60);
  }
  return c;
}
 
开发者ID:cache2k,项目名称:cache2k-benchmark,代码行数:17,代码来源:EhCache2Factory.java

示例10: RealCache

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的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");
}
 
开发者ID:ina-foss,项目名称:afp-api-client,代码行数:14,代码来源:AFPDataGrabberCache.java

示例11: afterPropertiesSet

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void afterPropertiesSet() throws Exception {
    Cache.ID = key + "." + Dates.newDateStringOfFormatDateTimeSSSNoneSpace();
    Cache.HOST = Utils.getLocalHostIP();
    Cache.CACHE_STORE = key + spliter + "cache" + spliter + "store";
    Cache.CACHE_STORE_SYNC = Cache.CACHE_STORE + spliter + "sync";
    if (this.localEnabled) {
        Configuration configuration = new Configuration();
        configuration.setName(Cache.ID);
        configuration.setMaxBytesLocalHeap(localMaxBytesLocalHeap);
        configuration.setMaxBytesLocalDisk(localMaxBytesLocalDisk);
        // DiskStore
        // 每次启动设置新的文件地址,以避免重启期间一级缓存未同步,以及单机多应用启动造成EhcacheManager重复的问题.
        DiskStoreConfiguration dsc = new DiskStoreConfiguration();
        dsc.setPath(localStoreLocation + Cache.ID);
        configuration.diskStore(dsc);
        // DefaultCache
        CacheConfiguration defaultCacheConfiguration = new CacheConfiguration();
        defaultCacheConfiguration.setEternal(false);
        defaultCacheConfiguration.setOverflowToDisk(true);
        defaultCacheConfiguration.setDiskPersistent(false);
        defaultCacheConfiguration.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU);
        defaultCacheConfiguration.setDiskExpiryThreadIntervalSeconds(localDiskExpiryThreadIntervalSeconds);
        // 默认false,使用引用.设置为true,避免外部代码修改了缓存对象.造成EhCache的缓存对象也随之改变
        // 但是设置为true后,将引起element的tti不自动刷新.如果直接新建element去覆盖原值.则本地ttl和远程ttl会产生一定的误差.
        // 因此,使用时放弃手动覆盖方式刷新本地tti,当本地tti过期后,自动从Redis中再获取即可.
        defaultCacheConfiguration.copyOnRead(true);
        defaultCacheConfiguration.copyOnWrite(true);
        defaultCacheConfiguration.setTimeToIdleSeconds(localTimeToIdleSeconds);
        defaultCacheConfiguration.setTimeToLiveSeconds(localTimeToLiveSeconds);
        configuration.setDefaultCacheConfiguration(defaultCacheConfiguration);
        configuration.setDynamicConfig(false);
        configuration.setUpdateCheck(false);
        this.cacheManager = new CacheManager(configuration);
        this.cacheSync = new RedisPubSubSync(this);// 使用Redis Topic发送订阅缓存变更消息
    }
}
 
开发者ID:yrain,项目名称:smart-cache,代码行数:39,代码来源:CacheTemplate.java

示例12: createLifeCache

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的package包/类
static Cache createLifeCache(CacheManager manager, String name) {
    return createCache(
            manager,
            name,
            configuration -> configuration.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.FIFO)
                    .timeToLiveSeconds(LIFE_TIME_SEC));
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:8,代码来源:EhcacheHelper.java

示例13: createIdleCache

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的package包/类
static Cache createIdleCache(CacheManager manager, String name) {
    return createCache(
            manager,
            name,
            configuration -> configuration.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.FIFO)
                    .timeToIdleSeconds(IDLE_TIME_SEC));
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:8,代码来源:EhcacheHelper.java

示例14: createEternalCache

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的package包/类
static Cache createEternalCache(CacheManager manager, String name) {
    return createCache(
            manager,
            name,
            configuration -> configuration.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.FIFO)
                    .eternal(true));

}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:9,代码来源:EhcacheHelper.java

示例15: createLifeCache

import net.sf.ehcache.store.MemoryStoreEvictionPolicy; //导入依赖的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;
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_04,代码行数:11,代码来源:EhcacheHelper.java


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