Commit d6c0215d authored by Matija Obreza's avatar Matija Obreza

@Cacheable ClassPKServiceImpl#getClassPk()

- Improves performance of many methods
parent 3aa4884c
...@@ -23,6 +23,7 @@ import org.genesys.blocks.persistence.ClassPKRepository; ...@@ -23,6 +23,7 @@ import org.genesys.blocks.persistence.ClassPKRepository;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
...@@ -51,6 +52,7 @@ public class ClassPKServiceImpl implements ClassPKService { ...@@ -51,6 +52,7 @@ public class ClassPKServiceImpl implements ClassPKService {
*/ */
@Override @Override
@Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRES_NEW) @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRES_NEW)
@Cacheable(cacheNames = { "classPk" }, unless = "#result == null")
public ClassPK getClassPk(final Class<?> class1) { public ClassPK getClassPk(final Class<?> class1) {
final ClassPK classPk = classPkRepository.getByClassname(class1.getName()); final ClassPK classPk = classPkRepository.getByClassname(class1.getName());
if (classPk != null) { if (classPk != null) {
......
...@@ -24,6 +24,7 @@ import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; ...@@ -24,6 +24,7 @@ import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCache; import org.springframework.cache.concurrent.ConcurrentMapCache;
import org.springframework.cache.support.NoOpCacheManager;
import org.springframework.cache.support.SimpleCacheManager; import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
...@@ -73,9 +74,7 @@ public class ApplicationConfig { ...@@ -73,9 +74,7 @@ public class ApplicationConfig {
*/ */
@Bean @Bean
public CacheManager cacheManager() { public CacheManager cacheManager() {
final SimpleCacheManager cacheManager = new SimpleCacheManager(); return new NoOpCacheManager();
cacheManager.setCaches(Arrays.asList(new ConcurrentMapCache("default")));
return cacheManager;
} }
/** /**
......
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