Search in sources :

Example 6 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project ORCID-Source by ORCID.

the class OrcidProfileCacheManagerImpl method init.

@PostConstruct
private void init() {
    CacheConfiguration config1 = publicProfileCache.getCacheConfiguration();
    publicProfileCacheTTI = config1.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config1.getTimeToIdleSeconds()) : DEFAULT_TTI;
    publicProfileCacheTTL = config1.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config1.getTimeToLiveSeconds()) : DEFAULT_TTL;
    CacheConfiguration config2 = publicBioCache.getCacheConfiguration();
    publicBioCacheTTI = config2.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config2.getTimeToIdleSeconds()) : DEFAULT_TTI;
    publicBioCacheTTL = config2.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config2.getTimeToLiveSeconds()) : DEFAULT_TTL;
    CacheConfiguration config3 = profileCache.getCacheConfiguration();
    profileCacheTTI = config3.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config3.getTimeToIdleSeconds()) : DEFAULT_TTI;
    profileCacheTTL = config3.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config3.getTimeToLiveSeconds()) : DEFAULT_TTL;
    CacheConfiguration config4 = profileBioAndInternalCache.getCacheConfiguration();
    profileBioAndInternalCacheTTI = config4.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config4.getTimeToIdleSeconds()) : DEFAULT_TTI;
    profileBioAndInternalCacheTTL = config4.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config4.getTimeToLiveSeconds()) : DEFAULT_TTL;
}
Also used : CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) PostConstruct(javax.annotation.PostConstruct)

Example 7 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project ORCID-Source by ORCID.

the class WorkEntityCacheManagerImpl method init.

@PostConstruct
private void init() {
    CacheConfiguration config1 = fullWorkEntityCache.getCacheConfiguration();
    fullWorkEntityCacheTTI = config1.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config1.getTimeToIdleSeconds()) : DEFAULT_TTI;
    fullWorkEntityCacheTTL = config1.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config1.getTimeToLiveSeconds()) : DEFAULT_TTL;
    CacheConfiguration config2 = workLastModifiedCache.getCacheConfiguration();
    workLastModifiedCacheTTI = config2.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config2.getTimeToIdleSeconds()) : DEFAULT_TTI;
    workLastModifiedCacheTTL = config2.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config2.getTimeToLiveSeconds()) : DEFAULT_TTL;
    CacheConfiguration config3 = publicWorkLastModifiedCache.getCacheConfiguration();
    publicWorkLastModifiedCacheTTI = config3.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config3.getTimeToIdleSeconds()) : DEFAULT_TTI;
    publicWorkLastModifiedCacheTTL = config3.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config3.getTimeToLiveSeconds()) : DEFAULT_TTL;
    CacheConfiguration config4 = minimizedWorkEntityCache.getCacheConfiguration();
    minimizedWorkEntityCacheTTI = config4.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config4.getTimeToIdleSeconds()) : DEFAULT_TTI;
    minimizedWorkEntityCacheTTL = config4.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config4.getTimeToLiveSeconds()) : DEFAULT_TTL;
}
Also used : CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) PostConstruct(javax.annotation.PostConstruct)

Example 8 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project Mycat_plus by coderczp.

the class EnchachePooFactory method createCachePool.

@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);
    }
}
Also used : CacheManager(net.sf.ehcache.CacheManager) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Cache(net.sf.ehcache.Cache)

Example 9 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project Mycat_plus by coderczp.

the class TestCachePoolPerformance method createEnCachePool.

public static CachePool createEnCachePool() {
    CacheConfiguration cacheConf = new CacheConfiguration();
    cacheConf.setName("testcache");
    cacheConf.maxBytesLocalHeap(400, MemoryUnit.MEGABYTES).timeToIdleSeconds(3600);
    Cache cache = new Cache(cacheConf);
    CacheManager.create().addCache(cache);
    EnchachePool enCachePool = new EnchachePool(cacheConf.getName(), cache, 400 * 10000);
    return enCachePool;
}
Also used : EnchachePool(io.mycat.cache.impl.EnchachePool) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Cache(net.sf.ehcache.Cache)

Example 10 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project oozie by apache.

the class EhcacheHCatDependencyCache method addMissingDependency.

@Override
public void addMissingDependency(HCatURI hcatURI, String actionID) {
    String serverName = canonicalizeHostname(hcatURI.getServer());
    // Create cache for the server if we don't have one
    Cache missingCache = missingDepsByServer.get(serverName);
    if (missingCache == null) {
        CacheConfiguration clonedConfig = cacheConfig.clone();
        clonedConfig.setName(serverName);
        missingCache = new Cache(clonedConfig);
        Cache exists = missingDepsByServer.putIfAbsent(serverName, missingCache);
        if (exists == null) {
            cacheManager.addCache(missingCache);
            missingCache.getCacheEventNotificationService().registerListener(this);
        } else {
            // discard
            missingCache.dispose();
        }
    }
    // Add hcat uri into the missingCache
    SortedPKV sortedPKV = new SortedPKV(hcatURI.getPartitionMap());
    String partKeys = sortedPKV.getPartKeys();
    String missingKey = hcatURI.getDb() + TABLE_DELIMITER + hcatURI.getTable() + TABLE_DELIMITER + partKeys + TABLE_DELIMITER + sortedPKV.getPartVals();
    boolean newlyAdded = true;
    synchronized (missingCache) {
        Element element = missingCache.get(missingKey);
        if (element == null) {
            WaitingActions waitingActions = new WaitingActions();
            element = new Element(missingKey, waitingActions);
            Element exists = missingCache.putIfAbsent(element);
            if (exists != null) {
                newlyAdded = false;
                waitingActions = (WaitingActions) exists.getObjectValue();
            }
            waitingActions.add(new WaitingAction(actionID, hcatURI.toURIString()));
        } else {
            newlyAdded = false;
            WaitingActions waitingActions = (WaitingActions) element.getObjectValue();
            waitingActions.add(new WaitingAction(actionID, hcatURI.toURIString()));
        }
    }
    // Increment count for the partition key pattern
    if (newlyAdded) {
        String tableKey = canonicalizeHostname(hcatURI.getServer()) + TABLE_DELIMITER + hcatURI.getDb() + TABLE_DELIMITER + hcatURI.getTable();
        synchronized (partKeyPatterns) {
            ConcurrentMap<String, SettableInteger> patternCounts = partKeyPatterns.get(tableKey);
            if (patternCounts == null) {
                patternCounts = new ConcurrentHashMap<String, SettableInteger>();
                partKeyPatterns.put(tableKey, patternCounts);
            }
            SettableInteger count = patternCounts.get(partKeys);
            if (count == null) {
                patternCounts.put(partKeys, new SettableInteger(1));
            } else {
                count.increment();
            }
        }
    }
}
Also used : Element(net.sf.ehcache.Element) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Cache(net.sf.ehcache.Cache)

Aggregations

CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)71 Cache (net.sf.ehcache.Cache)26 CacheManager (net.sf.ehcache.CacheManager)16 Ehcache (net.sf.ehcache.Ehcache)14 Configuration (net.sf.ehcache.config.Configuration)14 Element (net.sf.ehcache.Element)9 PersistenceConfiguration (net.sf.ehcache.config.PersistenceConfiguration)8 DiskStoreConfiguration (net.sf.ehcache.config.DiskStoreConfiguration)6 Test (org.junit.Test)6 Resource (org.springframework.core.io.Resource)6 IOException (java.io.IOException)5 Bean (org.springframework.context.annotation.Bean)5 CachedResource (org.apereo.portal.utils.cache.resource.CachedResource)4 CachingResourceLoaderImpl (org.apereo.portal.utils.cache.resource.CachingResourceLoaderImpl)4 LoadedResource (org.apereo.portal.utils.cache.resource.LoadedResource)4 ResourcesElementsProvider (org.jasig.resourceserver.utils.aggr.ResourcesElementsProvider)4 FileSystemResource (org.springframework.core.io.FileSystemResource)4 FileReader (java.io.FileReader)3 URL (java.net.URL)3 SelfPopulatingCache (net.sf.ehcache.constructs.blocking.SelfPopulatingCache)3