@Cacheble
は機能しません。私はSpring MVC Projectでehcacheを使用しています。私のサービスはSpring 4とehcache 2.10バージョンを使用してDAOとして動作しています。@CachebaleはEhcacheとSpring MVCで動作しません
アプリ-ctx.xml以下の実装を参照してください - アプリケーションコンテキストXML
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<cache:annotation-driven />
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache.xml"/>
<property name="shared" value="true"/>
</bean>
TelleCallerDashboardService.java
@Service
public class TelleCallerDashboardService extends BaseNamedParameterJdbcDaoSupport {
@Cacheable(value = "timeTrackerDashBoardCountCache", key="#league")
public void timeTrackerDashBoardCount(final TelleCallerDashboardDTO telleCallerDashboardDTO) {
}
の下にサービスクラスを参照してくださいしてください
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true"
monitoring="autodetect"
dynamicConfig="true">
<diskStore path="java.io.tmpdir" />
<cache name="timeTrackerDashBoardCountCache"
maxEntriesLocalHeap="100"
maxEntriesLocalDisk="1000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<persistence strategy="localTempSwap" />
</cache>
</ehcache>
以下ehcache.xmlをご覧ください。
アドバイスをお願いします
方法?また、 '@ Cacheable'は呼び出すメソッドには意味がありません。 –
戻り値の型とキーに入力パラメータの名前、つまりtelleCallerDashboardDTOが必要です。@CacheConfigがありません – Yogi
メソッドtimeTrackerDahshBoardCountは何も返しません。オブジェクトtelleCallerDashboardDTOは呼び出し元のメソッドから渡され、オブジェクトtelleCallerDashboardDTOを使用して値を格納します。データベース。呼び出したメソッドは更新された値を取得します。私は戻り値とkey = telleCallerDashboardDTOでコードをテストします。そして@CacheConfigを追加...ありがとう – giggs