Class SimpleCache<K,​V extends Identifiable<K>>

  • Type Parameters:
    K - the cache key type
    V - the cache value type
    All Implemented Interfaces:
    Predicate<K>, Cache<K,​V>, org.wildfly.clustering.ee.Restartable, AffinitySupport<K>

    public class SimpleCache<K,​V extends Identifiable<K>>
    extends Object
    implements Cache<K,​V>, Predicate<K>
    Simple Cache implementation using in-memory storage and eager expiration.
    Author:
    Paul Ferraro
    • Method Detail

      • start

        public void start()
        Specified by:
        start in interface org.wildfly.clustering.ee.Restartable
      • stop

        public void stop()
        Specified by:
        stop in interface org.wildfly.clustering.ee.Restartable
      • getIdentifierFactory

        public Supplier<K> getIdentifierFactory()
        Description copied from interface: Cache
        Returns the identifier factory of this cache.
        Specified by:
        getIdentifierFactory in interface Cache<K,​V extends Identifiable<K>>
        Returns:
        an identifier factory
      • create

        public V create()
        Description copied from interface: Cache
        Creates and caches a new instance of T.
        Specified by:
        create in interface Cache<K,​V extends Identifiable<K>>
        Returns:
        a new T
      • discard

        public void discard​(V value)
        Description copied from interface: Cache
        Discard the specified object from cache.
        Specified by:
        discard in interface Cache<K,​V extends Identifiable<K>>
        Parameters:
        value - the object to discard
      • remove

        public void remove​(K key)
        Description copied from interface: Cache
        Remove and destroy the specified object from cache.
        Specified by:
        remove in interface Cache<K,​V extends Identifiable<K>>
        Parameters:
        key - the identifier of the object
      • get

        public V get​(K key)
        Description copied from interface: Cache
        Get the specified object from cache. This will mark the object as being in use, and increase its usage count.
        Specified by:
        get in interface Cache<K,​V extends Identifiable<K>>
        Parameters:
        key - the identifier of the object
        Returns:
        the object, or null if it does not exist
      • contains

        public boolean contains​(K key)
        Description copied from interface: Cache
        Indicates whether or not the specified key is contained within this cache.
        Specified by:
        contains in interface Cache<K,​V extends Identifiable<K>>
        Parameters:
        key - the cache key
        Returns:
        true if the key is present in the cache, false otherwise.
      • release

        public void release​(V bean)
        Description copied from interface: Cache
        Decreases the objects usage count. If the usage count hits 0 then the object will be released.
        Specified by:
        release in interface Cache<K,​V extends Identifiable<K>>
        Parameters:
        bean - the object
      • test

        public boolean test​(K key)
        Specified by:
        test in interface Predicate<K>