0
使用org.springframework.cache.ehcache.EhCacheCacheManager &假设我有方法:拉单个对象了springframework的的Ehcache名单
@Cacheable("imageData") // add key = xyz here?
public List<ImageData> getProductIdAndColorCodeForSkus(List<Integer> skus) {
thread sleep
...do some stuff...
return listOfImageData;
}
,我已经打这个方法用的SKU {111111,111222 }。我后来想拉一个的ImageData对象从缓存中,例如:
Cache imageDataCache = cacheManager.getCache("imageData");
imageDataCache.get(key, ImageData.class) // what do I use for key?
我已经试过
new Integer(111111)
但是这将返回一个空的结果。我也尝试过在那个sku的列表中传递。
另外,我知道这两个ImageData都被缓存,并且可以单独检索,因为当我使用单个sku:111111或111222的列表第二次调用此方法时,不会发生线程睡眠。