/**
   * Helper method to send event when an existing cache entry is removed.
   *
   * @param event the event to send.
   */
  protected void sendEntryRemovedEvent(CacheEntryEvent<T> event) {
    for (org.xwiki.cache.event.CacheEntryListener<T> listener :
        this.cacheEntryListeners.getListeners(org.xwiki.cache.event.CacheEntryListener.class)) {
      listener.cacheEntryRemoved(event);
    }

    disposeCacheValue(event.getEntry().getValue());
  }
Пример #2
0
 @Override
 public void set(String key, T value) {
   T old = cache.put(key, value);
   if (listener != null && old == null) {
     listener.cacheEntryAdded(getEvent(key, value));
   } else {
     listener.cacheEntryModified(getEvent(key, value));
   }
   lastInsertedKey = key;
 }
Пример #3
0
 @Override
 public void remove(String key) {
   T value = cache.remove(key);
   if (listener != null) {
     listener.cacheEntryRemoved(getEvent(key, value));
   }
 }
 /**
  * Helper method to send event when a cache entry is modified.
  *
  * @param event the event to send.
  */
 protected void sendEntryModifiedEvent(CacheEntryEvent<T> event) {
   for (org.xwiki.cache.event.CacheEntryListener<T> listener :
       this.cacheEntryListeners.getListeners(org.xwiki.cache.event.CacheEntryListener.class)) {
     listener.cacheEntryModified(event);
   }
 }