spring-cache

How to handle code when memchache is not working(simple-spring-memcached)

给你一囗甜甜゛ 提交于 2019-12-25 05:07:19
问题 Thanks to the 'Getting started guide' in ‘simple-spring-memcached’ I manage to get memcached working in my project using ‘Spring 3.1’ example in in the guide , Im using ‘spymemcached’ as the provider . All working well when memcached server is up and running. However, when memcache server is not accessible (deliberately shut down for testing) underline code doesn’t work and application wont execute simply throwing runtime exception ,stating that unable to connect to memcache server and

How to handle code when memchache is not working(simple-spring-memcached)

浪尽此生 提交于 2019-12-25 05:07:15
问题 Thanks to the 'Getting started guide' in ‘simple-spring-memcached’ I manage to get memcached working in my project using ‘Spring 3.1’ example in in the guide , Im using ‘spymemcached’ as the provider . All working well when memcached server is up and running. However, when memcache server is not accessible (deliberately shut down for testing) underline code doesn’t work and application wont execute simply throwing runtime exception ,stating that unable to connect to memcache server and

Spring : Spring-cache not working

為{幸葍}努か 提交于 2019-12-24 13:06:12
问题 I am working on a Spring-MVC application. After the profiler went through the backend, I noticed that getCurrentlyAuthenticatedUser() is an hotspot. For the reason I thought of using cache. Unfortunately it is not working. Once the user logs in, I am getting null user, even though the user is logged in. What is going wrong. Ofcourse when I remove the @Cacheable annotation and config from XML, everything works fine. Any help would be nice. PersonServiceImpl : @Service @Transactional public

Spring Caching not working for findAll method

﹥>﹥吖頭↗ 提交于 2019-12-21 05:12:13
问题 I have recently started working on caching the result from a method. I am using @Cacheable and @CachePut to implement the desired the functionality. But somehow, the save operation is not updating the cache for findAll method. Below is the code snippet for the same: @RestController @RequestMapping(path = "/test/v1") @CacheConfig(cacheNames = "persons") public class CacheDemoController { @Autowired private PersonRepository personRepository; @Cacheable @RequestMapping(method = RequestMethod.GET

How update/remove an item already cached within a collection of items

六月ゝ 毕业季﹏ 提交于 2019-12-21 04:13:29
问题 I am working with Spring and EhCache I have the following method @Override @Cacheable(value="products", key="#root.target.PRODUCTS") public Set<Product> findAll() { return new LinkedHashSet<>(this.productRepository.findAll()); } I have other methods working with @Cacheable and @CachePut and @CacheEvict. Now, imagine the database returns 100 products and they are cached through key="#root.target.PRODUCTS" , then other method would insert - update - deleted an item into the database. Therefore

How update/remove an item already cached within a collection of items

元气小坏坏 提交于 2019-12-21 04:13:03
问题 I am working with Spring and EhCache I have the following method @Override @Cacheable(value="products", key="#root.target.PRODUCTS") public Set<Product> findAll() { return new LinkedHashSet<>(this.productRepository.findAll()); } I have other methods working with @Cacheable and @CachePut and @CacheEvict. Now, imagine the database returns 100 products and they are cached through key="#root.target.PRODUCTS" , then other method would insert - update - deleted an item into the database. Therefore

spring-boot-devtools causing ClassCastException while getting from cache.

為{幸葍}努か 提交于 2019-12-18 13:25:10
问题 I am facing issue while getting value from cache. java.lang.RuntimeException: java.lang.ClassCastException: com.mycom.admin.domain.User cannot be cast to com.mycom.admin.domain.User Cache Configuration @Configuration @EnableCaching @AutoConfigureAfter(value = { MetricsConfiguration.class, DatabaseConfiguration.class }) @Profile("!" + Constants.SPRING_PROFILE_FAST) public class MemcachedCacheConfiguration extends CachingConfigurerSupport { private final Logger log = LoggerFactory.getLogger

Spring Batch With Annotation and Caching

纵饮孤独 提交于 2019-12-18 09:36:24
问题 Does anyone have good example of Spring Batch (Using Annotation) to cache a reference table which will be accessible to processor ? I just need a simple cache, run a query which returns some byte[] and keep it in memory till the time job is executing. Appreciate any help on this topic. Thanks ! 回答1: A JobExecutionListener can be used to populate the cache with reference data before the job is executed and clear the cache after the job is finished. Here is an example: import org

How to have multiple cache manager configuration in spring cache java

有些话、适合烂在心里 提交于 2019-12-17 17:53:11
问题 I want to have multiple spring cache managers configured in my web-application and I would be able to use different cache manager at various places in my project. Is there any way to do this. 回答1: There are several ways you can do this and the right answer depends on your usage of the cache. You have a "main" cache manager If you use CacheManager A for 90% of your use case and B for 10% I'd advise to create a default CacheManager for A (you'll need to specify it via a CacheConfigurerSupport

Spring Cache with collection of items/entities

两盒软妹~` 提交于 2019-12-17 09:43:52
问题 I am using Spring Cache, where I pass in a collection of keys, and the return is a list of entities. I would like to have the caching framework understand that each element in the return list is to be cached with the corresponding code. At the moment, it seems that the key is the whole list, and if I am missing a key in the subsequent call, it'll try to reload the whole collection again. @Override @Cacheable(value = "countries") public List<Country> getAll(List<String>codes) { return