Commit 8c959f39 authored by Matija Obreza's avatar Matija Obreza

Merge branch 'cacheable-classpk' into 'master'

@Cacheable getClassPk

See merge request genesys-pgr/application-blocks!63
parents 3aa4884c d6c0215d
......@@ -23,6 +23,7 @@ import org.genesys.blocks.persistence.ClassPKRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
......@@ -51,6 +52,7 @@ public class ClassPKServiceImpl implements ClassPKService {
*/
@Override
@Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRES_NEW)
@Cacheable(cacheNames = { "classPk" }, unless = "#result == null")
public ClassPK getClassPk(final Class<?> class1) {
final ClassPK classPk = classPkRepository.getByClassname(class1.getName());
if (classPk != null) {
......
......@@ -24,6 +24,7 @@ import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCache;
import org.springframework.cache.support.NoOpCacheManager;
import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
......@@ -73,9 +74,7 @@ public class ApplicationConfig {
*/
@Bean
public CacheManager cacheManager() {
final SimpleCacheManager cacheManager = new SimpleCacheManager();
cacheManager.setCaches(Arrays.asList(new ConcurrentMapCache("default")));
return cacheManager;
return new NoOpCacheManager();
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment