У меня есть два кешированных метода:
@Cacheable(value = CacheName.CACHE_STATIC, key="'getImageUserLayer'.concat(':').concat(#layerId)")
public byte[] getImageUserLayer(int layerId) {
и
@Cacheable(value = CacheName.CACHE_STATIC, key="'getLastModifiedUserLayer'.concat(':').concat(#layerId)")
@Override
public String getLastModifiedUserLayer(int layerId) {
также у меня есть метод для удаления элемента:
@Caching(evict = {
@CacheEvict(value = CacheName.CACHE_STATIC, key = "'getImageUserLayer'.concat(':').concat(#layerId)"),
@CacheEvict(value = CacheName.CACHE_STATIC, key = "'getLastModifiedUserLayer'.concat(':').concat(#layerId)")
})
public void updateLayer(UserLayer layer, int layerId) {
Почему после вызова updateLayer (5510461), я получаю следующее странное поведение:
2020-02-10 16:47:07.065 [http-nio-8080-exec-9] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:4900061' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
2020-02-10 16:48:32.695 [http-nio-8080-exec-7] TRACE o.s.c.i.CacheInterceptor - Invalidating cache key [getImageUserLayer:5510461] for operation Builder[public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)] caches=[cacheStatic] | key=''getImageUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='',false,false on method public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)
2020-02-10 16:48:32.701 [http-nio-8080-exec-7] TRACE o.s.c.i.CacheInterceptor - Invalidating cache key [getLastModifiedUserLayer:5510461] for operation Builder[public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='',false,false on method public void com.prognoz.smkoob.data.dao.meta.UserLayerServiceImpl.updateLayer(com.prognoz.smkoob.domain.UserLayer.UserLayer,int)
2020-02-10 16:48:33.591 [http-nio-8080-exec-4] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:5510461' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
2020-02-10 16:48:33.591 [http-nio-8080-exec-4] TRACE o.s.c.i.CacheInterceptor - No cache entry for key 'getLastModifiedUserLayer:5510461' in cache(s) [cacheStatic]
2020-02-10 16:48:33.909 [http-nio-8080-exec-3] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:4900061' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
2020-02-10 16:48:33.909 [http-nio-8080-exec-3] TRACE o.s.c.i.CacheInterceptor - No cache entry for key 'getLastModifiedUserLayer:4900061' in cache(s) [cacheStatic]
2020-02-10 16:48:33.909 [http-nio-8080-exec-8] TRACE o.s.c.i.CacheInterceptor - No cache entry for key 'getLastModifiedUserLayer:5129071' in cache(s) [cacheStatic]
2020-02-10 16:48:33.910 [http-nio-8080-exec-8] TRACE o.s.c.i.CacheInterceptor - Computed cache key 'getLastModifiedUserLayer:5129071' for operation Builder[public java.lang.String com.prognoz.smkoob.data.dao.ImageServiceImpl.getLastModifiedUserLayer(int)] caches=[cacheStatic] | key=''getLastModifiedUserLayer'.concat(':').concat(#layerId)' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
Почему это также делает недействительными другие ключи ??? Например, 4900061.
мой ehcache. xml:
<cache name="cacheStatic"
maxBytesLocalHeap="128M"
maxBytesLocalDisk="2G"
eternal="false"
timeToLiveSeconds="7200"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<persistence strategy="localTempSwap"/>
</cache>