use of net.sf.ehcache.CacheManager in project trainning by fernandotomasio.
the class TurmaPlanejadaFindAllInterceptor method invoke.
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
Object result = null;
CacheManager cacheManager = CacheManager.create(new ClassPathResource("echache.xml").getInputStream());
Cache cache = cacheManager.getCache("colecoesCache");
Element element = cache.get("turmasPlanejadas");
if (element == null) {
result = invocation.proceed();
cache.put(new Element("turmasPlanejadas", result));
} else {
result = element.getValue();
}
return result;
}
use of net.sf.ehcache.CacheManager in project activemq-artemis by apache.
the class InMemoryDirectoryServiceFactory method init.
/**
* {@inheritDoc}
*/
@Override
public void init(String name) throws Exception {
if ((directoryService == null) || directoryService.isStarted()) {
return;
}
directoryService.setInstanceId(name);
// instance layout
InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name);
if (instanceLayout.getInstanceDirectory().exists()) {
try {
FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory());
} catch (IOException e) {
LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e);
}
}
directoryService.setInstanceLayout(instanceLayout);
// EhCache in disabled-like-mode
Configuration ehCacheConfig = new Configuration();
CacheConfiguration defaultCache = new CacheConfiguration("default", 1).eternal(false).timeToIdleSeconds(30).timeToLiveSeconds(30).overflowToDisk(false);
ehCacheConfig.addDefaultCache(defaultCache);
CacheService cacheService = new CacheService(new CacheManager(ehCacheConfig));
directoryService.setCacheService(cacheService);
// Init the schema
// SchemaLoader loader = new SingleLdifSchemaLoader();
SchemaLoader loader = new JarLdifSchemaLoader();
SchemaManager schemaManager = new DefaultSchemaManager(loader);
schemaManager.loadAllEnabled();
ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry();
for (LdapComparator<?> comparator : comparatorRegistry) {
if (comparator instanceof NormalizingComparator) {
((NormalizingComparator) comparator).setOnServer();
}
}
directoryService.setSchemaManager(schemaManager);
InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager);
SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
schemaPartition.setWrappedPartition(inMemorySchemaPartition);
directoryService.setSchemaPartition(schemaPartition);
List<Throwable> errors = schemaManager.getErrors();
if (errors.size() != 0) {
throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
}
// Init system partition
Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), directoryService.getDnFactory(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system"));
systemPartition.setSchemaManager(directoryService.getSchemaManager());
partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100);
directoryService.setSystemPartition(systemPartition);
directoryService.startup();
}
use of net.sf.ehcache.CacheManager in project Gemma by PavlidisLab.
the class CacheKey method afterPropertiesSet.
@Override
public void afterPropertiesSet() {
CacheManager cacheManager = this.cacheManagerFactory.getObject();
int maxElements = Settings.getInt("gemma.cache.vectors.maxelements", ProcessedDataVectorCacheImpl.VECTOR_CACHE_DEFAULT_MAX_ELEMENTS);
int timeToLive = Settings.getInt("gemma.cache.vectors.timetolive", ProcessedDataVectorCacheImpl.VECTOR_CACHE_DEFAULT_TIME_TO_LIVE);
int timeToIdle = Settings.getInt("gemma.cache.vectors.timetoidle", ProcessedDataVectorCacheImpl.VECTOR_CACHE_DEFAULT_TIME_TO_IDLE);
boolean overFlowToDisk = Settings.getBoolean("gemma.cache.vectors.usedisk", ProcessedDataVectorCacheImpl.VECTOR_CACHE_DEFAULT_OVERFLOW_TO_DISK);
boolean terracottaEnabled = Settings.getBoolean("gemma.cache.clustered", true);
boolean eternal = Settings.getBoolean("gemma.cache.vectors.eternal", ProcessedDataVectorCacheImpl.VECTOR_CACHE_DEFAULT_ETERNAL) && timeToLive == 0;
boolean diskPersistent = Settings.getBoolean("gemma.cache.diskpersistent", true) && !terracottaEnabled;
this.cache = CacheUtils.createOrLoadCache(cacheManager, ProcessedDataVectorCacheImpl.VECTOR_CACHE_NAME, terracottaEnabled, maxElements, overFlowToDisk, eternal, timeToIdle, timeToLive, diskPersistent);
}
use of net.sf.ehcache.CacheManager in project Gemma by PavlidisLab.
the class GeneTestedInCacheImpl method afterPropertiesSet.
@Override
public void afterPropertiesSet() {
CacheManager cacheManager = cacheManagerFactory.getObject();
assert cacheManager != null;
// Other settings just use the gene2gene ones.
int timeToLive = Settings.getInt("gemma.cache.gene2gene.timetolive", GeneTestedInCacheImpl.GENE_COEXPRESSIONTESTED_CACHE_DEFAULT_TIME_TO_LIVE);
int timeToIdle = Settings.getInt("gemma.cache.gene2gene.timetoidle", GeneTestedInCacheImpl.GENE_COEXPRESSIONTESTED_CACHE_DEFAULT_TIME_TO_IDLE);
boolean overFlowToDisk = Settings.getBoolean("gemma.cache.gene2gene.usedisk", GeneTestedInCacheImpl.GENE_COEXPRESSIONTESTED_CACHE_DEFAULT_OVERFLOW_TO_DISK);
boolean eternal = Settings.getBoolean("gemma.cache.gene2gene.eternal", GeneTestedInCacheImpl.GENE_COEXPRESSIONTESTED_CACHE_DEFAULT_ETERNAL) && timeToLive == 0;
boolean terracottaEnabled = Settings.getBoolean("gemma.cache.clustered", false);
boolean diskPersistent = Settings.getBoolean("gemma.cache.diskpersistent", false) && !terracottaEnabled;
this.cache = CacheUtils.createOrLoadCache(cacheManager, GeneTestedInCacheImpl.GENE_COEXPRESSIONTESTED_CACHE_NAME, terracottaEnabled, GeneTestedInCacheImpl.GENE_COEXPRESSIONTESTED_CACHE_DEFAULT_MAX_ELEMENTS, overFlowToDisk, eternal, timeToIdle, timeToLive, diskPersistent);
}
use of net.sf.ehcache.CacheManager in project Mycat-Server by MyCATApache.
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);
}
}
Aggregations