ページの先頭行へ戻る
Interstage Business Application Server オープンJavaフレームワークユーザーズガイド
FUJITSU Software

3.1.16 Cache機能サポート

何度も呼び出され、かつ毎回同じ値を返すメソッドに対してCache機能を使用すると、アプリケーションの性能を向上させることができます。

アプリケーションのクラスに@Cacheableアノテーションを追記します。

@Cacheable(value = "Employees")
public String[] execDaoSelect();
@CacheEvict(value = "Employees", condition="#Employee!= null", allEntries = true)
public boolean execDaoDelete(String Employee);

bean定義ファイルに、<cache>タグとcacheManagerを定義します。

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:cache="http://www.springframework.org/schema/cache"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">

<cache:annotation-driven />

...

<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">

<property name="caches">

<set>

<bean class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean" p:name="default"/>

<bean class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean" p:name="Employees"/>

</set>

</property>

</bean>

</beans>