WebPage caching in Hazelcast - caching

We are currently using ehcache : SimplePageCachingFilter to perform webpage caching.
Now we have decided to move on to Hazelcast for our caching and i couldn't find any information related to Web Page caching in HazelCast documentation.
Does Hazel cast support Web Caching?
Any help will be highly appreciated.
Thanks..

Oh yes most definitely.
Hazelcast has many modes of support for web caching...
http://www.hazelcast.org/use-cases/caching/
I assume you are interested in the distributed cache? Hazelcast can be used as a form of elastic Memcached and it supports that protocol natively.
Or you can work more closely with the application and can use it has a Hibernate L2 cache or within spring as a spring cache.
If you explain more about what you're trying to do, it's likely that Hazelcast can be used to achieve that, as Caching is a core use case for Hazelcast.

Related

How can I achieve local caching using Spring boot?

I am trying to setup a spring boot application and looking for options to store the small data in the local cache and then this local cache interacts with Redis server which will be on google cloud platform. This local cache can be shared across multiple nodes. I see Redis pro can help to achieve this but that is not free. Is there any open source option I can use? Or any other way I can set this up in Spring boot? How can I set this local cache which syncs up with the central cache? Any suggestions please?
You can use Redisson https://github.com/redisson/redisson/wiki/14.-Integration-with-frameworks/#1421-spring-cache-local-cache-and-data-partitioning. It's available in the Pro version.
If you would like to implement it by yourself, you would need to implement custom CacheManager that first looks up entries in local cache (implemented likely with something smarter than a HashMap, like Caffeine, if entry not found goes to Redis based CacheManager and then depending on the result puts the data to Caffeine cache.
For storing data in Redis and making sure all nodes are in sync, you can use Redis Pub/Sub mechanism to notify each connected node to update local cache.
Spring Boot for Apache Geode (SBDG) offers client-side caching, or what is commonly referred to as "Near Caching". See here.
HISTORY
Apache Geode is an open source software (OSS), In-Memory Data Grid (IMDG) technology, having an Apache 2 License. Indeed, it can be much more than a cache if need be, but fits perfectly well in the caching use case, at any layer in the application architecture (Web, Service, Data).
The commercial version of Apache Geode is VMware Tanzu GemFire, built on Apache Geode source with support from VMware, if needed. But, to use Apache Geode, is completely free.
In fact, the original Spring Cache Abstraction was inspired by Costin Leau's development (original lead & creator) of Spring Data GemFire, which has been replaced by Spring Data for Apache Geode (SDG), to focus on the OSS offering. (See here/alt-here, then here, as well as from Boot).
SBDG is an extension of SDG to give users of Apache Geode (or alternatively, VMware Tanzu GemFire) a proper and first-class experience using Apache Geode in a Spring context, and specifically with Spring Boot features (e.g. auto-configuration). That is, SBDG is a special extension of Spring Boot catered specifically to Apache Geode to handle a variety of application concerns (like caching) that is owned and maintained by the Spring Team, itself.
SBDG is even capable of handling several caching patterns in addition to "Near Caching". See the topic of caching in general.
Finally, SBDG also includes Spring Session for Apache Geode (SSDG) to handle your Web, HTTP Session state caching concerns independent of you Web container (e.g. Tomcat) using Apache Geode as the caching provider for the HTTP Session state. It is, of course, built on Spring Session core (see here).

Redis or memcached - which is best

Which cache application is best for spring boot microservice,redis or memcached? I have compared more or less both have same features, please anyone suggest me

communication between spring instances behind a load balancer

I have a few instances of Spring apps running behind a load balancer. I am using EHCache as a caching system on each of these instances.
Let's say I receive a request that is refreshing a part of the cache on one instance. I need a way to tell the other instances to refresh their cache (or to replicate it).
I'm more interested in a solution based on Spring and not just cache replication and that's because there are other scenarios similar with this one that require the same solution.
How can I achieve this?
There is no simple Spring solution for this. Depends on the requirements. You can use any kind of PubSub like a JMS topic to notify your nodes. This way the problem can be that you cannot guarantee consistency. The other nodes can still read the old data for a while. In my current project we use Redis. We configured it as cache with Spring Data Redis and theres no need to notify the other nodes since the cache is shared. In non cache scenarios we also use redis as a PubSub service.

Redis or Hazelcast, or others?

I took an old web application recently. The App will save a lot of object into Ehcache at init time.And then obtain the object from the cache. And now, the object has increased many times. Ehcache in the app can not meet the requirement. So, we consider using a distributed cache. We will set some strategies and let the objects save in different cache server.
Redis and Hazelcast are both good. Question is, the Redis and Hazelcast compared to the previous Ehcache, Redis and Hazelcast must Serialize objects. May be it will consume more time.
So which is better?
Or are there no other better alternatives?
Thanks in advance.
What are your requirements? Hazelcast has pluggable serialization and there are serialization libraries like FlatBuffers that are exceedingly fast if needed.
Hazelcast is ideal if you are Java centric, of course you can also access Hazelcast via .Net CLR languages if you are using Hazelcast Enterprise.
Hazelcast is more than just a simple distributed cache, you can also leverage the distributed CPUs in your cluster and execute processes directly in the grid, which can result in very high performance.
If you are multi-language and dont need to execute code on top of distributed data (in-memory executor service, mapreduce or entryprocessors) Redis would make sense.
Have a look at Redisson - Redis based In-Memory Data Grid is a good alternative for Ehcache. Provides a lot data serialization codecs like:
Jackson JSON, Avro, Smile, CBOR, MsgPack, Amazon Ion, Kryo, JDK Serialization, LZ4 and Snappy.
It also allows to store Map data in external storage along with Redis store using Read-through, Write-through and Write-behind strategies.
Offers distributed MapReduce and Executor/Scheduler services.

enable hibernate app to use clustered hazelcast

our prod environment architecture is decided to be like this:
2 machines that each of them have 2 tomcat instances (on vm). there is spring web app with hibernate running on tomcat.
there are also 2 db instances distributed to both machines.
so, we think that hazelcast fits this achitecture well. hazelcast will be second level cache for hibernate, it will manage clustered cache over db instances.
we installed hibernate server and defined our clusters on it.
i've searched offical hazelcast doc and several sites but i couldnt find the way to configure hibernate to use this hazelcast server as L2 cache.
we dont want to change our existing app. we'll keep using hibernate as it is. is it possible? if so, how we can configure hazelcast server on our web app?
I think it is important to understand that your probably don't want to have a standalone Hazelcast cluster/server; what you normally do is to embed Hazelcast within your application.
Like Miko said, you can just enable Hazelcast to be used as second level cache; no need to make any fundamental changes.
I also don't understand what you mean with 'hibernate server', because Hibernate is just an OR mapper library and has no concept of server.
So can you tell a bit more what you want so we can help you out?

Resources