Search code examples
spring-bootcachinginfinispan

Using @Cacheable Spring annotation and manually add to Infinispan Cache


I am trying to load my cache off of a cold start, prior to application startup. This would be done so values are available as soon as a user accesses a server, rather than having to hit my database.

@Cacheable functionality from Spring all works great, the problem is how I manually store objects in the Cache so that they can be read when the function is executed.

Spring is storing these objects in bytes, somehow -- and I need to mimic this while I manually load the cache. I'm just trying to figure out how they process the return objects, in the function, to store into the cache in a key,val pair.


Solution

  • I was able to solve this problem by storing values as a string key and object value -- which works wonderfully with Spring @Cacheable annotations. Objects are casted into the return types by Spring if they are found within the cache.