Questions tagged [spring-cache]

Spring cache provides a Cache and CacheManager abstraction with several implementations including support for ehcache and JSR-107 providers. It also applies caching to Java methods, reducing thus the number of executions based on the information available in the cache. Both declarative annotation-based caching and aspect-oriented caching are supported.

Spring Framework provides support for transparently adding caching into an existing Spring application. Similar to the transaction support, the caching abstraction allows consistent use of various caching solutions with minimal impact on the code.

To use the cache abstraction, the developer needs to take care of two aspects:

  • caching declaration - identify the methods that need to be cached and their policy
  • cache configuration - the backing cache where the data is stored and read from

Cache configuration

Spring provides provides several storages integration. To use them, one needs to simply declare an appropriate CacheManager - an entity that controls and manages Caches and can be used to retrieve these for storage.

Support for simple in-memory map, ehcache, guava and JSR-107 compliant caches are available out of the box.

Useful links:

687 questions
0
votes
1 answer

ehcache generates empty data file

I want to use data caching with ehcache in my portlet. I use Spring MVC and liferay portal. If I want to use Cacheable annotation, empty data file is generated. SocialGraphUI-portlet.xml
Matt
  • 8,195
  • 31
  • 115
  • 225
0
votes
1 answer

infinispan hot rod delay

We are using infinispan hot rod in our application. Some times the retrieval from cache takes more time .This is not happening consistently . Most of the time it takes 6m sec but at times it takes very long ( 200 msec ) . The size of the object…
lives
  • 1,243
  • 5
  • 25
  • 61
0
votes
1 answer

Why do spring framework reference doc missing context-support in their diagram

The Diagram [2.1. Overview of the Spring Framework] in Spring Framework reference 4.1.4 which is updated since last doc but it is missing spring-context-support from it. In the diagram they mentioned context ,do that represents…
Sankalp
  • 2,030
  • 7
  • 30
  • 41
0
votes
1 answer

Spring Abstraction Cache in OSGi Environment

I have problem making Spring Cache working in OSGi Environment. Maybe you can show me what i am missing. I have configured Spring Cache successfully to work during tests like @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations =…
Deo
  • 138
  • 1
  • 2
  • 8
0
votes
1 answer

@cacheEvict not working while calling the method from different controller

In spring application we have two controllers i.e. controller1, controller2 and one services i.e. service1 i want to use method caching and for that i have configured spring cache. i am caching method named method1 in service1 with @Cacheable(value…
murtaza.webdev
  • 3,523
  • 4
  • 22
  • 32
0
votes
1 answer

CacheEvict from Iterable collection

I have 2 method like this : first, i'm get users deposit @Override @Transactional @Cacheable(value = "deposits") public Set getUserDeposit() { User user = userRepository.findOneByUsername( …
Benjamin
  • 531
  • 2
  • 6
  • 18
0
votes
1 answer

How to implement CacheLoader so that @Cacheable key is read

In attempting to implment my own cache loader using inline refresh. This cache loaded is using RefreshAheadCacheFactory as described…
blue-sky
  • 51,962
  • 152
  • 427
  • 752
0
votes
1 answer

LazyInitializationException when trying to access detached objects left around in Redis by RedisCacheManager

I use Spring data Redis in order to cache serialized JPA entities in Redis using org.springframework.data.redis.cache.RedisCacheManager Here is the method: @Override @Cacheable(value = MapCacheConfiguration.DATABASE_CACHE_NAME, key =…
balteo
  • 23,602
  • 63
  • 219
  • 412
0
votes
1 answer

Using CouchbaseCacheManager and setting TTL

Is there a way to specify different TTL for different CouchbaseCache objects in CouchBaseCacheManager? @Cacheable("mycache") public List findMyObjectsById(long id) { return myrepo.findById(id); } How I make that List expire in cache…
vladsfl
  • 617
  • 8
  • 18
0
votes
0 answers

Cannot add Spring Cache advice to method - internalCacheAdvisor is created in same batch as cachable annotated bean

We have refactored some parts of our application, and after that, methods annotated with spring cachable stopped being cached although the class containing the cached method was not touched. After some debugging, we can see that after refactoring…
Andreas Lundgren
  • 12,043
  • 3
  • 22
  • 44
0
votes
0 answers

What is the default cache key?

We have been using following code in production for quite some time now: @Override @Transactional(readOnly = true) @Cacheable("WIDGET_SERVICE_CACHE") public List findAllWidgets() { return…
Stijn Geukens
  • 15,454
  • 8
  • 66
  • 101
0
votes
0 answers

Spring Autowire CacheManager

Trying to Autowire CacheManager and it throws Null Pointer. Essentially, like to use Spring's cache manager while actual implementation is by ehcache. The idea is to swap the actual cache provider in future that way writing to spring's interface.…
user1516100
0
votes
1 answer

Fine-tuning and monitoring a Spring cache backed by a ConcurrentMapCache

I have set up a Spring cache manager backed by a ConcurrentMapCache for my application. I am seeking for ways to monitor the cache and especially make sure the data in cache fits in memory. I considered using jvisualvm for that purpose but there…
balteo
  • 23,602
  • 63
  • 219
  • 412
0
votes
1 answer

Configure singleton CacheManager for multiple web applications with Spring Caching

I have multiple web applications deployed in Tomcat and service jar shared in TOMCAT_HOME/lib/ext. All of the application are using Spring, and in the service jar I have beans, annotated with Spring 3.1 Caching annotations . I am using Ehcache…
0
votes
1 answer

Spring cache not working with EHCache+JCache

I'm trying to integration the ehcache implementation of jcache to work with spring. So I have a facade defined like this: @Component(value = "sampleFacade") @CacheDefaults(cacheName = "default") public class SampleFacadeImpl implements…
Petar Tahchiev
  • 4,336
  • 4
  • 35
  • 48
1 2 3
45
46