Java Code Examples for org.ehcache.event.CacheEvent

Following code examples demonstrate how to use org.ehcache.event.CacheEventfrom ehcache. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.ehcache.event.CacheEventand various code implementation of this class.

    public void onEvent(CacheEvent<?, ?> event) {
        log.debug("Event: " + event.getType() + " Key: " + event.getKey() + " old value: " + event.getOldValue()
                + " new value: " + event.getNewValue());

    } 


	public void onEvent(CacheEvent<K, V> event) {
		LOGGER.debug(event.getType().toString());
		
		
	} 

  public void testCacheEntryEventUnwrap() {
    MutableConfiguration<String, String> configuration = new MutableConfiguration<>();
    configuration.setTypes(String.class, String.class);
    Cache<String, String> cache = cacheManager.createCache("cache", configuration);
    org.ehcache.event.CacheEvent<String, String> ehEvent = new EhEvent();
    Eh107CacheEntryEvent<String, String> cacheEntryEvent = new Eh107CacheEntryEvent.NormalEvent<>(cache, EventType.CREATED, ehEvent, false);
    assertThat(cacheEntryEvent.unwrap(org.ehcache.event.CacheEvent.class), is(instanceOf(CacheEvent.class)));
    assertThat(cacheEntryEvent.unwrap(cacheEntryEvent.getClass()), is(instanceOf(Eh107CacheEntryEvent.NormalEvent.class)));
  } 

Advertisement
Javadoc
An event resulting from a mutative Cache operation. @param the key type of the source cache @param

the value type of the source cache

Read More
Advertisement