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
2 answers

@Cacheable : how to pass a new attribute that can be used in my own KeyGenerator?

I need your expertise :) I'm working on a application where method calls on a service need to be authenticated. That means I want each method call to be cached with a key containing the username (to avoid for an unauthorized user to retrieve…
lboix
  • 969
  • 12
  • 14
0
votes
1 answer

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

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…
csf
  • 529
  • 1
  • 4
  • 16
0
votes
1 answer

property causes error when tomcat 6 starts

We using spring 3.2.3 in a jsf-based web app. I'm tasked with implementing spring cache WITHOUT using annotations. here's my cache-context:
Vuzi
  • 185
  • 2
  • 4
  • 13
0
votes
0 answers

infinispan unmarshall cache key from DB

We would like to view the keys stored in the infinispan cache. We have configured JdbcStringBasedCacheStore and the key and value are stored in DB as well. When we select the keys from cache table , it is in byte[]. Tried using jboss unmarshaler ,…
lives
  • 1,243
  • 5
  • 25
  • 61
-1
votes
2 answers

Static Analysis tool to catch self-invocation bypassing Spring cache @Cacheable method

I understand that this is because of the way proxies are created for handling caching, transaction related functionality in Spring. And the way to fix it is use AspectJ but I donot want to take that route cause it has its own problems. Can I detect…
Sabya
  • 197
  • 4
  • 17
-1
votes
1 answer

Using CachePut and Cacheable

I have two methods as below .One is annotated with @CachePut and another is annotated with @Cacheable.Both of them uses the same key . Based on some of the answers from other posts I figured that @cacheput replaces the value. If that is the case ,…
rookie
  • 386
  • 6
  • 19
-1
votes
1 answer

SpringBoot 2.1.4.RELEASE not to cache null value in @Cacheable annotation

I have an SpringBoot 2.1.4.RELEASE app. with a repository: @Repository public interface PercentageAlertXMenuRepository extends CrudRepository { @Cacheable("percentageAlertXMenu", unless="#result == null") …
Nuñito Calzada
  • 4,394
  • 47
  • 174
  • 301
-1
votes
1 answer

GemfireTemplate with ClientRegionShortcut.CACHING_PROXY_HEAP_LRU doesn't cache locally

clientCache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU) works as expected when used with a spring-cache GemfireCacheManager and caches data locally. However when the same settings is used in conjunction with…
Divs
  • 1,578
  • 2
  • 24
  • 51
-1
votes
1 answer

spring hazelcast cache cluster showing warning

I have micro service architecture and all the micro services are using the same database. Now i want to have distributed cache in my architecture. For the moment i choose Hazelnut for distributed. As a start i put the following configuration in all…
Saurabh Kumar
  • 16,353
  • 49
  • 133
  • 212
-1
votes
1 answer

RedisCacheManager autowired in code but not working as expected

I am caching data by using @Cacheable(value="bus_availability", key="#sourceCity") spring annotation in Redis using spring. But whenever trying to access it using RedisCacheManager I not getting results. Like redisCacheManager.getCacheNames()…
Yogesh Funde
  • 767
  • 6
  • 13
-1
votes
1 answer

Blocking cache support

Spring Cache abstraction doesn't support blocking cache, meaning a cache that when you do a read operation for the same key at the same time on multiple threads, the cacheable method would be invoked only once. Guava cache supports that feature out…
mike27
  • 965
  • 3
  • 12
  • 22
-1
votes
1 answer

Spring Cache: Using memcached as a distributed cache

For a number of java services we're using AWS ElastiCache as a distributed cache integrated by Spring Cache abstraction and spymemcached. In one service I see the behaviour that i get a diffent type of result than I expect, leading to a…
user655145
1 2 3
45
46