나는 두 개의 다른 서비스를 autowire하는 Spring에 인터셉터를 가지고있다. 두 서비스 모두 ehcache-spring-annotations 프로젝트의 @Cacheable
태그가 붙은 메소드가 있지만 cacheNames
은 다릅니다.@Cachable 주석이 달린 메서드가 EHCache로 결과를 캐시하지 않는 이유는 무엇입니까?
public class MenuInterceptor extends HandlerInterceptorAdapter {
@Autowired
private EventService eventService;
@Autowired
private OrganisationInfoService orgService;
@Override
public final void postHandle(HttpServletRequest request,
HttpServletResponse response,
Object handler,
ModelAndView modelAndView) throws SystemException {
eventService.getFolderEventsForUser(123);
orgService.getOrgCustomProfile("abc");
}
@Service
public class EventServiceImpl implements EventService {
@Override
@Cacheable(cacheName = "ecomOrders")
public Collection<FolderEventBean> getFolderEventsForUser(long loginId) throws SystemException {
@Service("organisationInfoService")
public class OrganisationInfoServiceImpl implements OrganisationInfoService {
@Override
@Cacheable(cacheName="orgProfile")
public OrgCustomProfileBean getOrgCustomProfile(String orgHierarchyString) throws ServiceException {
응용 프로그램을 실행할 때 한 메서드는 결과에 EHCache를 사용하지만 다른 메서드는 사용하지 않습니다. EventServiceImpl.getFolderEvnetsForUser
은 그렇지 않지만 OrganisationInfoSericeImpl.getOrgCustomProfile()
캐시는 올바르게 캐시됩니다. 누군가 제발 말해 줄래?
두 서비스 모두 동일한 캐시를 사용하려고했지만 여전히 그 중 하나만 작동합니다. 난으로 Ehcache 스프링 - 주석 DEBUG 온하고, 시동시 두 방법 모두를 등록
[DEBUG] 8시 9분 1초() 속성 CACHE 의뢰 방법 'getFolderEventsForUser'를 가산 : CacheableAttributeImpl [캐시 = [이름 = ecomOrders 상태 = STATUS_ALIVE 이터널 = 거짓 overflowToDisk = false maxElementsOnDisk = 0 memoryStoreEvictionPolicy = LRU timeToLiveSeconds = 300 timeToIdleSeconds = 0 diskPersistent = false diskExpiryThreadIntervalSeconds = 120 cacheEventListeners : net.sf.ehcache.statistics.LiveCacheStatisticsWrapper hitCount = 0 memoryStoreHitCount = 0 diskStoreHitCount = 0 missCountNotFound = 0 missCountExpired = 0], cacheKeyGenerator = HashCodeCacheKeyGenerator [includeMethod = true, includeParameterTypes = true, useReflection = false, checkforCycle S = 거짓, entryFactory = NULL, exceptionCache = NULL, parameterMask = ParameterMask [마스크 = [] [] com.googlecode.ehcache.annotations.impl.CacheAttributeSourceImpl.getMethodAttribute (CacheAttributeSourceImpl.java:174)에서
[DEBUG] 08:09:01() 캐시 속성 권고 : CacheableAttributeImpl [캐시 = [이름 = orgProfile 상태 = STATUS_ALIVE 이터널 = 거짓 overflowToDisk = false maxElementsInMemory = 200 maxElementsOnDisk = 0 memoryStoreEvictionPolicy = LRU timeToLiveSeconds = 86400 timeToIdleSeconds = 0 diskPersistent = false diskExpiryThreadIntervalSeconds = 120 cacheEventListeners : net.sf.ehcache.statistics.LiveCacheStatisticsWrapper hitCount = 0 memoryStoreHitCount = 0 diskStoreHitCount = 0 missCountNotFound = 0 missCountExpired = 0], cacheKeyGenerator = HashCodeCacheKeyGenerator [includeMethod = true, useParameterTypes = true, useRef com.googlecode.ehcache.annotations.impl.CacheAttributeSourceImpl.getMethodAttribute (CacheAttributeSourceImpl.java:174)에서 parameter_task = false, checkforCycles = false], entryFactory = null, 예외 캐시 = null, 매개 변수 마스크 = 매개 변수 마스크 [ 인터셉터는 autowire가 서비스를 호출 할 때
, 그 중 하나는 캐시 :
[DEBUG] 8시 9분 19초 (UNIQUE_ID) 호출을위한 생성 키 '-1668638847278617'ReflectiveMethodInvocation : 추상적 공개 no.finntech.base.modules.organisation.support.OrgCustomProfileBean no.finntech.service.organisation.OrganisationInfoService.getOrgCustomProfile (java.lang.String) throws no.finntech.service.ServiceEx 선거; 대상은 [no.finntech.service.organisation.impl.OrganisationInfoServiceImpl] [URI :/finn/minfinn/myitems/list, 원격 IP : 127.0.0.1, 참조 자 :, 사용자 에이전트 : Mozilla/5.0 (Windows NT 6.1 ; WOW64; RV : 6.0.2) 도마뱀/com.googlecode.ehcache.annotations.interceptor.EhCacheInterceptor.generateCacheKey의 파이어 폭스 20,100,101/6.0.2 (EhCacheInterceptor.java:272)
EDIT : I 정상적으로 아마도 두 서비스가 서로 다른 모듈에 정의되어 있다고 언급 할 수 있습니다.
둘 다 각각의 인터페이스를 통해 호출됩니다. – Nicolai
흠, 첫 번째 캐시에는 다른 캐시 (86400 초)와 비교하여 300 초의 timeToLive 값이 있습니다. 즉, 캐시 된 오브젝트는 마지막 액세스 시간과 상관없이 5 분 후에 축출됩니다. 따라서 메소드가 주어진 loginId에 대해서만 거의 호출되지 않으면 상황이 캐시되지 않은 것처럼 보일 것입니다. 이유가 있을까요? – Paolo
현재로서는 이것을 테스트하고 캐시 된 것인지 확인하고 있습니다. 전화는 서로 몇 초 안에 이루어집니다. 캐시 프록시는 EventService에 절대 사용되지 않으므로 일종의 설치/구성 문제가 있어야합니다. – Nicolai