複数のメソッドを持つサービスがあり、Spring@Cacheable
アノテーションを使用してそれらをキャッシュしようとしています。メソッドパラメーターとして配列を使用するメソッドがキャッシュされていないことを除いて、すべて正常に機能します。配列が異なる値を保持できることを考えると、これはある程度理にかなっていますが、それでも可能だと思います。
次のメソッドがキャッシュされます。
@Cacheable("myCache")
public Collection<Building> findBuildingByCode(String buildingCode) {...}
@Cacheable("myCache")
public Collection<Building> getBuildings() {...}
ただし、findBuildingByCode
メソッドを次のいずれかに変更すると、キャッシュされません。
@Cacheable("myCache")
public Collection<Building> findBuildingByCode(String[] buildingCode) {...}
@Cacheable("myCache")
public Collection<Building> findBuildingByCode(String... buildingCode) {...}
関連するSpring xml構成は次のとおりです。
<!-- Cache beans -->
<cache:annotation-driven/>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
p:cache-manager-ref="ehcache" />
<!-- EhCache library setup -->
<bean id="ehcache"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" />
Ehcache構成:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
updateCheck="false">
<diskStore path="java.io.tmpdir/ehcache" />
<!-- Default settings -->
<defaultCache eternal="false" maxElementsInMemory="1"
overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
timeToLiveSeconds="100" memoryStoreEvictionPolicy="LRU" />
<!-- Other caches -->
<cache name="myCache" eternal="false" maxElementsInMemory="500"
overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
timeToLiveSeconds="43200" memoryStoreEvictionPolicy="LRU" />
</ehcache>
これは既知の機能ですか、それともバグですか?