705 questions
0
votes
0
answers
64
views
Configure EhCache with Spring (JSR 107) exclusively programmatically
I am trying to set up ehcache with Spring. It works on runtime, but after restart the cache in the application is empty. What am I doing wrong?
I can't use the common ehcache.xml.
@Configuration
@...
0
votes
0
answers
28
views
Caching rendered templates in Spring Boot
I'm using the JTE template engine in a Spring Boot application like:
@GetMapping("/")
public String home(Model model) {
List<Product> products = productRepo.findAll();
model....
0
votes
0
answers
50
views
How to avoid a race condition using Infinispan and Spring Cache Annotations
I try to avoid a race condition using Infinispan (v 15.1.5) with the Spring Cache Annotations and Spring Boot (v 3.4.3). Two Threads are calling the @Cacheable and @CacheEvict methods at the same time....
0
votes
1
answer
291
views
Is it possible to enable/disable springboot cache with caffeine via a property?
I would like to enable/disable springboot cache with caffeine cache.
With a property, something like my.property.cache.enabled=true or my.property.cache.enabled=false to enable and disable caching.
...
2
votes
1
answer
295
views
Spring doesn't recommend to annotate interface methods with @Cache* annotation on Spring HttpInterface
I have this simple piece of code, in which I would like to cache a very expensive http call.
@RestController
class ReportController {
@Autowired
ReportService reportService;
@GetMapping("/...
1
vote
0
answers
80
views
How do I version spring cache redis objects?
How do I version spring cache redis objects? I am encountering issues between deploys when the object version changes, and no longer match the cache structure in redis.
AI assistant gives a ...
0
votes
1
answer
53
views
Object became null in @CachePut annotation
For some reason I can see that object was passed not null, but in key expression it is null already.
I am trying to read some data from DB and add it to the cache.
Here are my methods.
public void ...
1
vote
1
answer
79
views
Unable to read custom annotation in spring boot
I have some custom annotation to distinguish the Service classes as
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface DataService {
}
@Retention(RetentionPolicy.RUNTIME)...
1
vote
1
answer
66
views
Annotation @CachePut not working, but method .put does
I tried the annotation @CachePut in the method updateCategoryCacheForCountry and it wasn't working. But
when doing so programatically by getting the cache and using .put it works fine. What could be ...
0
votes
1
answer
219
views
How to validate that you have added @CacheEvict to all the methods that would update a cached value
I have a query in my Spring Boot 3.2 code that is exspensive to run and I would like to cache the value. The query is taking a few component parts and then counting them to return a single value.
For ...
0
votes
1
answer
406
views
Spring boot caching + Caffeine with custom expiration logic
I am doing a sample project for managing some generic background jobs, mainly to practice how to work with cache in Spring Boot.
My key problem is managing retention time for jobs, based on their ...
1
vote
0
answers
240
views
How to default RedisCacheManager to use Jackson annotations used on POJOs for @Cacheable methods
I have this class hierarchy where B & C extends an abstract class A. Within A, I used the typical jackson annotations to tell jackson how to serialize & deserialize the polymorphic structure.
@...
2
votes
0
answers
328
views
Spring boot cache on Response DTO
I have written below function to get All the pokemons.
Now I want to add the functionality to cache the pokemons by id which is coming from the list. I am using Simple cache for Caching.
Dependency:
...
0
votes
0
answers
28
views
Enable cache mechanism for entire application based on flag from properties file [duplicate]
I want to enable/disable spring boot( redis )cache based on the flag set in the properties file.
Suppose I set cacheEnabled=true in the properties file then it should not consider cache mechanism for ...
0
votes
1
answer
683
views
Unable to update already cached list using @CachePut
I am using redis cache in spring boot application. Requirement is - We need data list on certain date filter. So to achieve that I used cacheable annotation.
Now when I run it for first time, it ...
1
vote
0
answers
386
views
Best Practices for Implementing Spring Caching?
Right now, my app is organized like this:
Controller Layer: Handles user requests.
Business Service Layer: Manages data, including caching.
Repository Layer: Deals with data storage.
Code Example:
//...
2
votes
2
answers
9k
views
Caching in Spring Boot with Caffeine
I have this configuration class:
@Configuration
@EnableCaching
public class CacheConfig {
@Bean
@Primary
public CacheManager cacheManager() {
CaffeineCacheManager cacheManager = ...
0
votes
1
answer
593
views
Spring Conditional Caching with Local Variables?
I have a Cacheable method that returns an object containing data from multiple sources.
In case of an error (ex: A source is unavailable), it will return with whatever partial data was retrieved.
...
-1
votes
1
answer
695
views
EHCache 3 not able to enable caching. Getting exception if I used configuration without xml
I am trying to implement EHCache 3 with spring boot 3 without xml configuration. I did below configuration for EHCache 3
@Bean
public CacheManager getCacheManager() {
CacheManager ...
1
vote
1
answer
3k
views
Spring Boot 3: Unable to gracefully fail and recover on Redis connection issue
I have a spring boot API which is using Redis. I'm trying to cover cases whereby when Redis goes down for whatever reason I am able to handle it and more importantly recover and serve from cache again....
0
votes
1
answer
127
views
How to call a method for "value" attribute of cacheable annotation in Java Spring
I have this abstract repository class:
public abstract class FirestoreRepository<T> {
protected Firestore db;
protected FirestoreRepository(Firestore db) {
this.db = db;
}
...
2
votes
0
answers
779
views
Spring cache fails to deserialise empty array
I have following Redis cache setup
private RedisCacheConfiguration redisCacheConfiguration() {
return RedisCacheConfiguration.defaultCacheConfig()
.disableCachingNullValues()
....
0
votes
1
answer
722
views
Why @Cacheable return different result on subsequent calls
I am running Spring Boot version 2.6.14.
Controller
@PostMapping("/v1/books)
public GenericResponse<Book> getBooks(BookRequest request) {
return new GenericResponse<>(
...
1
vote
2
answers
2k
views
CacheManger defined as bean and in application.yaml
In Spring Boot, I would like to use one cache manager defined as bean plus Redis cache defined in application.yaml. But after define cache manager like bean the other one in application.yaml is ...
0
votes
1
answer
109
views
Unable to store and retrieve Spring HATEOAS EntityModel in Redis
I have a use case where we are trying to store and retrieve content from Redis cache. We are using spring-starter-cache for making use of the underlying redis cache storage.
@Bean
public ...