私はehcacheで作業しています。Spring @Service メソッドをキャッシュしています:
@Service( value = "dataServicesManager" )
@Transactional
public class DataServicesManager implements IDataServicesManager{
@Autowired
private IDataDAO dataDAO;
@Override
@Cacheable( value = "alldatas" )
public List<Data> getAllDatas(Integer param) {
// my logic
return results;
}
// others services
}
Spring 構成スニペットは次のとおりです。
<cache:annotation-driven/>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcache"/>
</bean>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="WEB-INF/ehcache.xml"/>
<property name="shared" value="true"/>
</bean>
これが私のehcache構成です。
<ehcache xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true" monitoring="autodetect" dynamicConfig="true">
<diskStore path="C:/TEMP/ehcache"/>
<defaultCache eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="1200"
overflowToDisk="true"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120" />
<cache name="alldatas" maxEntriesLocalHeap="10000" eternal="false"
timeToIdleSeconds="21600" timeToLiveSeconds="21600" memoryStoreEvictionPolicy="LRU">
</cache>
</ehcache>
Spring @Controller からサービス メソッド getAllDatas を呼び出すと、メソッドがキャッシュされ、2 回目の呼び出しでキャッシュ内の結果ストアが取得されます。私が理解していないのは<diskStore path="C:/TEMP/ehcache"/>
、ehcache.xml で指定が見つからないことです。だから私は2つの質問があります:
質問 1:「C:/TEMP/ehcache」ディレクトリが作成されないのはなぜですか?
質問 2:サービスの結果はどこにキャッシュされますか?