How to use cache writer and cache loader in case of Ehcache server - ehcache

I have used cache-as-sor usage pattern of Ehcache in my web application. now i want to use ehcahe as separate application so i have used cache server. so how to use cache writer and cache loader in case of ehcache server.
In short i want to use method like cache.getWithLoader() and cache.putWithWriter().

As the cache server does not expose these methods, you may be able to handle this by configuring Ehcache in the cache server to use decorated caches that would transform standard get and put into calling into getWithLoader and putWithWriter instead.

Related

Accessing the objects currently in Hazelcast Cache in Spring Boot

I want to access all the object present in Hazelcast cache through the cache manager and check them. How do I do it?
After autowiring the cacheManager, what needs to be done next?
Read the documentation here: http://docs.hazelcast.org/docs/3.10/manual/html-single/index.html#hazelcast-jcache
You can use standard get or getAll methods.
Alternatively, use IMap and you can run queries.

Custom Cache Implementation in Ignite

I had a small query over Apache Ignite. Can we have a custom implementation of cache in to store the in-memory state? & where can we plugin the custom implementation.
For eg,
Currently, by default we have IgniteCache for cache management. Can we have something like MyCache for management of cache with the method signatures being the same just the storage technique being different?
Thank you.

Is Spring Cache clusterable?

I've got an application that uses Spring Cache (Ehcache), but now we need to add a 2nd node (same application). Can the cache be shared between the nodes or each with their own instance but synched?
Or do I need to look at a different solution?
Thanks.
That depends on your cache implementation - not on Spring, which only provides an abstract caching API. You are using EhCache as your caching implementation, which comes with a Terracotta server for basic clustering support and is open source. See http://www.ehcache.org/documentation/3.1/clustered-cache.html#clustering-concepts for more details

Spring cache of two Grails applications in the same machine (different Jetty server)

Hi I have one Grails application, it uses Spring cache. I want to clone it (say APP_A and APP_B) and deploy on separate it as each access different DB and has some different configuration.
Currently I have two copy of Jetty servers (JETTY_A, JETTY_B. different port). I put APP_A in Jetty_A and APP_B in Jetty_B.
I'm not familiar with Spring cache.
Is this deployment save? I mean, will there be any mix of cache between both? Because both using the same code base. So, the cache will use the same key name.
#cacheable("someCache")
SpringCache uses EHCache under the covers. The caches are in-process caches and they do not affect caches running in other processes on the same machine, unless you had explicitly configured distributed caching.
As #KenLiu said in his answer, Spring Cache is strictly in-process when using EHCache as it's cache provider. Since you are working with Grails, however, there are better alternatives that will require only minimal changes.
The Grails Cache Plugin is a offers a Spring Cache API-compatible cache abstraction over a number of (plugable) cache providers, including some, like the Redis provider, that allow you to cache between processes (and entire machines) very easily.

Is there a provider agnostic way of getting up to date cache statistics in Spring framework?

Spring provides a useful feature of Cache Abstraction
But what I could not find is a provider agnostic way to get live cache statistics. Essentially I just want to show a list of all the cache names and their corresponding keys with the count of hits, misses, and sizes (in kb) either on a web page or via JMX. I know Ehcache does provide this feature and if I use ehcache API inside the code I can get it (have already used it in the past). But I believe using Ehcache API inside the code takes away the whole notion of the Spring framework's cache abstraction.
The only common, provider-agnostic thing you have is CacheManager interface, which provides the following method:
Collection<String> getCacheNames()
It returns a collection of the caches known by the cache manager.

Resources