एक ही सेम के दूसरे तरीके से कैश्ड विधि को कॉल करने पर स्प्रिंग कैश काम नहीं कर रहा है।
यहाँ मेरी समस्या को स्पष्ट तरीके से समझाने के लिए एक उदाहरण है।
विन्यास:
<cache:annotation-driven cache-manager="myCacheManager" />
<bean id="myCacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="myCache" />
</bean>
<!-- Ehcache library setup -->
<bean id="myCache"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:shared="true">
<property name="configLocation" value="classpath:ehcache.xml"></property>
</bean>
<cache name="employeeData" maxElementsInMemory="100"/>
कैश्ड सेवा:
@Named("aService")
public class AService {
@Cacheable("employeeData")
public List<EmployeeData> getEmployeeData(Date date){
..println("Cache is not being used");
...
}
public List<EmployeeEnrichedData> getEmployeeEnrichedData(Date date){
List<EmployeeData> employeeData = getEmployeeData(date);
...
}
}
परिणाम :
aService.getEmployeeData(someDate);
output: Cache is not being used
aService.getEmployeeData(someDate);
output:
aService.getEmployeeEnrichedData(someDate);
output: Cache is not being used
getEmployeeData
विधि कॉल का उपयोग करता है कैश employeeData
दूसरी कॉल में अपेक्षा के अनुरूप। लेकिन जब getEmployeeData
विधि को AService
कक्षा ( भीतर getEmployeeEnrichedData
) में बुलाया जाता है , तो कैश का उपयोग नहीं किया जा रहा है।
क्या यह है कि स्प्रिंग कैश कैसे काम करता है या मुझे कुछ याद आ रहा है?
someDate
परम के लिए समान मूल्य का उपयोग कर रहे हैं ?