Class AbstractCache<T>

  • Type Parameters:
    T - the class of the data stored in the cache.
    All Implemented Interfaces:
    Cache<T>

    public abstract class AbstractCache<T>
    extends Object
    implements Cache<T>
    Base class for Cache implementations. It provides events DisposableCacheValue management.
    Version:
    $Id: 0215579da91f5c992e51213a0604d939f3483c40 $
    • Field Detail

      • configuration

        protected final CacheConfiguration configuration
        The configuration used to create the cache.
      • cacheEntryListeners

        protected final EventListenerList cacheEntryListeners
        The list of listener to called when events appends on a cache entry.
    • Method Detail

      • dispose

        public void dispose()
        Description copied from interface: Cache
        Release all the resources this cache use.
        Specified by:
        dispose in interface Cache<T>
      • addCacheEntryListener

        public void addCacheEntryListener​(CacheEntryListener<T> listener)
        Description copied from interface: Cache
        Add the provided listener to the cache to catch events on entries like add, remove etc.
        Specified by:
        addCacheEntryListener in interface Cache<T>
        Parameters:
        listener - the implemented listener.
      • removeCacheEntryListener

        public void removeCacheEntryListener​(CacheEntryListener<T> listener)
        Description copied from interface: Cache
        Remove the provided listener from the list of listeners.
        Specified by:
        removeCacheEntryListener in interface Cache<T>
        Parameters:
        listener - the implemented listener.
      • sendEntryAddedEvent

        protected void sendEntryAddedEvent​(CacheEntryEvent<T> event)
        Helper method to send event when a new cache entry is inserted.
        Parameters:
        event - the event to send.
      • sendEntryRemovedEvent

        protected void sendEntryRemovedEvent​(CacheEntryEvent<T> event)
        Helper method to send event when an existing cache entry is removed.
        Parameters:
        event - the event to send.
      • sendEntryModifiedEvent

        protected void sendEntryModifiedEvent​(CacheEntryEvent<T> event)
        Helper method to send event when a cache entry is modified.
        Parameters:
        event - the event to send.
      • disposeCacheValue

        protected void disposeCacheValue​(T value)
        Dispose the value being removed from the cache.
        Parameters:
        value - the value to dispose