Reputation: 2918
I am using Spring + Ehcache for my cache layer and it is working. But for some reason I wanna manipulate the cache manually.
@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)
This works fine, but when I try to manually update the productAll cache in the saveProduct function. I am not able to get the cache back from the cache manager
Cache cache = cacheManager.getCache("productAll");
cache.get("");
What is the key that I should use in this case, when no key is provided when we cache in the getProductAll method?
Upvotes: 1
Views: 2344
Reputation: 41
None of the above solutions worked for me, but using SimpleKey.EMPTY did:
Cache cache = cacheManager.getCache("productAll");
cache.get(SimpleKey.EMPTY);
From https://www.logicbig.com/tutorials/spring-framework/spring-integration/cache-key-generation.html
Upvotes: 4
Reputation: 149
Cache cache = cacheManager.getCache("productAll");
cache.get(0).get();
Upvotes: 0
Reputation: 2528
Try this one:
Cache cache = cacheManager.getCache("productAll");
cache.get(0);
Upvotes: 1