use of net.sf.ehcache.CacheManager in project trainning by fernandotomasio.
the class IndicadoresMapFindAllInterceptor 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("indicadoresMap");
if (element == null) {
result = invocation.proceed();
cache.put(new Element("indicadoresMap", result));
} else {
result = element.getValue();
System.out.println("Não foi no banco");
}
return result;
}
use of net.sf.ehcache.CacheManager in project trainning by fernandotomasio.
the class PessoaFindInterceptor 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("pessoasCache");
Long pessoaId = (Long) invocation.getArguments()[0];
Element element = cache.get(pessoaId);
if (element == null) {
result = invocation.proceed();
cache.put(new Element(pessoaId, result));
} else {
result = element.getValue();
}
return result;
}
use of net.sf.ehcache.CacheManager in project trainning by fernandotomasio.
the class TreinamentoSolicitadoFindAllInterceptor 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("treinamentosSolicitados");
if (element == null) {
result = invocation.proceed();
cache.put(new Element("treinamentosSolicitados", result));
return result;
} else {
return element.getValue();
}
}
use of net.sf.ehcache.CacheManager in project trainning by fernandotomasio.
the class PessoaUpdateInterceptor method invoke.
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
Object result = null;
CacheManager cacheManager = CacheManager.create(new ClassPathResource("echache.xml").getInputStream());
Cache uniqueCache = cacheManager.getCache("pessoasCache");
Cache collectionsCache = cacheManager.getCache("colecoesCache");
PessoaDTO pessoa = (PessoaDTO) invocation.getArguments()[0];
if (pessoa != null) {
Element uniqueElement = uniqueCache.get(pessoa.getId());
if (uniqueElement != null) {
uniqueCache.remove(pessoa.getId());
}
}
Element collectionElement = collectionsCache.get("pessoas");
if (collectionElement != null) {
collectionsCache.remove("pessoas");
}
result = invocation.proceed();
return result;
}
use of net.sf.ehcache.CacheManager in project trainning by fernandotomasio.
the class AtividadesEnsinoCacheAdvice method clearChacheTurmas.
private void clearChacheTurmas(String key) throws IOException {
CacheManager cacheManager = CacheManager.create(new ClassPathResource("echache.xml").getInputStream());
Cache cache1 = cacheManager.getCache("turmas-efetivas-cache");
cache1.remove(key);
}
Aggregations