Is there a way to get the value that was evicted from the cache

classic Classic list List threaded Threaded
2 messages Options
prashant prashant
Reply | Threaded
Open this post in threaded view
|

Is there a way to get the value that was evicted from the cache

This post has NOT been accepted by the mailing list yet.
Hi, I am new to ignite. I am using Ignite cache and have registered for cache eviction event. The event does provide us information about the key that was removed from the cache but no information about the data. Is there a way of getting this value from the cache?
Denis Magda Denis Magda
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to get the value that was evicted from the cache

Hi,

Actually the event holds the value that is evicted as well. Please refer to this listener example below:

    /** Eviction event listener. */
    private static class EvictListener implements IgnitePredicate<Event> {
        /** {@inheritDoc} */
        @Override public boolean apply(Event evt) {
            if (evt.type() == EVT_CACHE_ENTRY_EVICTED) {
                CacheEvent event = (CacheEvent)evt;

                System.out.println("Evicted key = " + event.key() + " , value=" + event.oldValue());
            }
           
            return true;
        }
    }


And please properly subscribe to the user list (this way we will not have to manually approve your emails). All you need to do is send an email to “user-subscribe@ignite.apache.org” and follow simple instructions in the reply.

Regards,
Denis