Java Code Examples for org.cache2k.CacheEntry#getException()

The following examples show how to use org.cache2k.CacheEntry#getException() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TouchyJCacheAdapter.java    From cache2k with Apache License 2.0 6 votes vote down vote up
@Override
public long calculateExpiryTime(K _key, V _value, long _loadTime, CacheEntry<K, V> _oldEntry) {
  if (_value == null) {
    return NO_CACHE;
  }
  Duration d;
  if (_oldEntry == null || _oldEntry.getException() != null) {
    d = policy.getExpiryForCreation();
  } else {
    d = policy.getExpiryForUpdate();
  }
  if (d == null) {
    return ExpiryTimeValues.NEUTRAL;
  }
  if (d.equals(Duration.ETERNAL)) {
    return ExpiryTimeValues.ETERNAL;
  }
  if (d.equals(Duration.ZERO)) {
    return ExpiryTimeValues.NO_CACHE;
  }
  return _loadTime + d.getTimeUnit().toMillis(d.getDurationAmount());
}
 
Example 2
Source File: EventHandlingImpl.java    From cache2k with Apache License 2.0 5 votes vote down vote up
@Override
public void onEntryCreated(final Cache<K, V> c, final CacheEntry<K, V> e) {
  if (e.getException() != null) {
    return;
  }
  javax.cache.Cache<K,V> _jCache = getCache(c);
  fireCreated(_jCache, e);
}
 
Example 3
Source File: EventHandlingImpl.java    From cache2k with Apache License 2.0 5 votes vote down vote up
@Override
public void onEntryRemoved(final Cache<K, V> c, final CacheEntry<K, V> e) {
  if (e.getException() != null) {
    return;
  }
  javax.cache.Cache<K,V> _jCache = getCache(c);
  V val = extractValue(e.getValue());
  EntryEvent<K, V> cee =
    new EntryEventWithOldValue<K, V>(_jCache, EventType.REMOVED, e.getKey(), val, val);
  asyncDispatcher.deliverAsyncEvent(cee);
  for (Listener<K,V> t : removedListener) {
    t.fire(cee);
  }
}
 
Example 4
Source File: EventHandlingImpl.java    From cache2k with Apache License 2.0 5 votes vote down vote up
@Override
public void onEntryExpired(final Cache<K, V> c, final CacheEntry<K, V> e) {
  if (e.getException() != null) {
    return;
  }
  javax.cache.Cache<K,V> _jCache = getCache(c);
  EntryEvent<K, V> cee =
    new EntryEvent<K, V>(_jCache, EventType.EXPIRED, e.getKey(), extractValue(e.getValue()));
  asyncDispatcher.deliverAsyncEvent(cee);
  for (Listener<K,V> t : expiredListener) {
    t.fire(cee);
  }
}