I have some questions regarding Cache Listeners/Events.

We have a system that used a lot of "Caffeine" based caches spread across
multiple services (in K8S).  Basically "near-caches" (without a backing
store).  We are now trying to fit Ignite behind those usages.

*What we are trying to do is when Ignite /expires/ an entry receive the
event on all the nodes and evict it in from Caffeine*.

Are one of these approaches below correct? And/or how can I accomplish this? 
Is there a better/easier way?

1) I tried registering a CacheListener with each cache configuration but
that seemed to only fire where the cache event was fired:

config.addCacheEntryListenerConfiguration(new
IgniteExpiredListener<>(cacheManagerProvider));

2) I am experimenting with cache events as well like this below.

ig.events(
            ig.cluster().forServers())
            .remoteListen(
                new IgniteBiPredicate<UUID, CacheEvent>()
                {
                    @Override
                    public boolean apply(UUID uuid, CacheEvent evt)
                    {
                        log.debug("Received local event "
                                  + evt.name()
                                  + ", key="
                                  + evt.key()
                                  + ", at="
                                  + evt.node().consistentId().toString()
                                  + ", "
                                  +
evt.eventNode().consistentId().toString() );
                        cm.getCache(evt.cacheName()).evict(evt.key());
                        return true; // Continue listening.
                    }
                },
                new IgnitePredicate<CacheEvent>()
                {
                    @Override
                    public boolean apply(final CacheEvent evt)
                    {
                        log.debug("Received remote event "
                                  + evt.name()
                                  + ", key="
                                  + evt.key()
                                  + ", at="
                                  + evt.node().consistentId().toString()
                                  + ", "
                                  +
evt.eventNode().consistentId().toString() );
                        return true;
                    }
                },
                EVTS_CACHE);




-----
KJQ
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Reply via email to