Class PerpetualCache

  • All Implemented Interfaces:
    Cache

    public class PerpetualCache
    extends java.lang.Object
    implements Cache
    Author:
    Clinton Begin
    • Constructor Summary

      Constructors 
      Constructor Description
      PerpetualCache​(java.lang.String id)  
    • Method Summary

      Modifier and Type Method Description
      void clear()
      Clears this cache instance.
      boolean equals​(java.lang.Object o)  
      java.lang.String getId()  
      java.lang.Object getObject​(java.lang.Object key)  
      int getSize()
      Optional.
      int hashCode()  
      void putObject​(java.lang.Object key, java.lang.Object value)  
      java.lang.Object removeObject​(java.lang.Object key)
      As of 3.3.0 this method is only called during a rollback for any previous value that was missing in the cache.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PerpetualCache

        public PerpetualCache​(java.lang.String id)
    • Method Detail

      • getId

        public java.lang.String getId()
        Specified by:
        getId in interface Cache
        Returns:
        The identifier of this cache
      • getSize

        public int getSize()
        Description copied from interface: Cache
        Optional. This method is not called by the core.
        Specified by:
        getSize in interface Cache
        Returns:
        The number of elements stored in the cache (not its capacity).
      • putObject

        public void putObject​(java.lang.Object key,
                              java.lang.Object value)
        Specified by:
        putObject in interface Cache
        Parameters:
        key - Can be any object but usually it is a CacheKey
        value - The result of a select.
      • getObject

        public java.lang.Object getObject​(java.lang.Object key)
        Specified by:
        getObject in interface Cache
        Parameters:
        key - The key
        Returns:
        The object stored in the cache.
      • removeObject

        public java.lang.Object removeObject​(java.lang.Object key)
        Description copied from interface: Cache
        As of 3.3.0 this method is only called during a rollback for any previous value that was missing in the cache. This lets any blocking cache to release the lock that may have previously put on the key. A blocking cache puts a lock when a value is null and releases it when the value is back again. This way other threads will wait for the value to be available instead of hitting the database.
        Specified by:
        removeObject in interface Cache
        Parameters:
        key - The key
        Returns:
        Not used
      • clear

        public void clear()
        Description copied from interface: Cache
        Clears this cache instance.
        Specified by:
        clear in interface Cache
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object