CacheEventListener Sample

44 views
Skip to first unread message

Rishabh Monga

unread,
Apr 3, 2015, 2:42:28 AM4/3/15
to ehcac...@googlegroups.com
Following is a sample implementation proposed for cache event listeners.
https://github.com/rishabhmonga/ehcache3/blob/issue-278/impl/src/test/java/org/ehcache/GettingStarted.java#L217

Following is a sample xml configuration proposed for cache event listeners.

Please provide suggestions/feedback

Thanks and Regards,
Rishabh

Louis Jacomet

unread,
Apr 3, 2015, 5:33:23 AM4/3/15
to ehcac...@googlegroups.com
Hi Rishabh,

In yesterday's public meeting, we discussed the topic of builders and how we want them to look like.
@Test
public void cacheEventListener() {
Class<? extends CacheEventListener<?, ?>> aClass = null;
newCacheConfigurationBuilder().add(
newEventListenerConfig(aClass, EventType.CREATED, EventType.EVICTED)
.firingMode(EventFiring.SYNCHRONOUS) //.syncrhonous().asynchronous()
.eventOrdering(EventOrdering.ORDERED) //.ordered().unordered()
.build())
.buildConfig(Long.class, String.class);
}
Find above what we ended up with.

Some explanations:
  1. add(ServiceConfig) is a rename of addServiceConfig but in addition we want an add(Builder<? extends ServiceConfig>) which will automatically call build 
  2. the newEventListenerConfig is a static method on CacheEventListenerConfigurationBuilder (which implements Builder, a new interface) and it takes the class and the events to fire on (as a vararg). If you stop there, the default is ASYNCHRONOUS - UNORDERED
  3. firingMode is the generic way of passing the mode, the two methods in comment are also available
  4. eventOrdering is the generic way of passing the ordering, the two methods in comment are also available
  5. the call to build become optional since add is overloaded as indicated in point 1.
Based on this builder level change, you will probably want to adapt the XML config bit so that it stays in the same spirit.

Regards,
Louis

--
You received this message because you are subscribed to the Google Groups "ehcache-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-dev/6b6ce96d-5a2b-43ff-9122-7a84fdfcf980%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages