2012-06-18 70 views
1

我正在使用Spring + Ehcache緩存層並且它正在工作。但出於某種原因,我想手動操作緩存。Spring + Ehcache:無法從緩存管理器中取回緩存而無需密鑰

@Cacheable(value = "productAll") 
public List<Product> getAllProduct() 

@CacheEvict(value = "product", key = "#product.id") 
public Product saveProduct(Product product) 

@Cacheable(value = "product") 
public Product getProductById(Long id) 

這工作正常,但是當我嘗試手動更新saveProduct函數中的productAll緩存。我沒能獲得高速緩存從高速緩存管理器

Cache cache = cacheManager.getCache("productAll"); 
cache.get(""); 

什麼是我應該在這種情況下使用時,當我們在getProductAll方法緩存沒有提供密鑰的密鑰回來?

回答

1

試試這個:

Cache cache = cacheManager.getCache("productAll"); 
cache.get(0); 
+0

這個沒有工作 – Cshah

0
Cache cache = cacheManager.getCache("productAll"); 
cache.get(0).get();