Interface Cache

    • Method Summary

      Modifier and Type Method Description
      void clear()
      Clears this cache instance.
      java.lang.String getId()  
      java.lang.Object getObject​(java.lang.Object key)  
      default java.util.concurrent.locks.ReadWriteLock getReadWriteLock()
      Optional.
      int getSize()
      Optional.
      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.
    • Method Detail

      • getId

        java.lang.String getId()
        Returns:
        The identifier of this cache
      • putObject

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

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

        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. 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.
        Parameters:
        key - The key
        Returns:
        Not used
      • clear

        void clear()
        Clears this cache instance.
      • getSize

        int getSize()
        Optional. This method is not called by the core.
        Returns:
        The number of elements stored in the cache (not its capacity).
      • getReadWriteLock

        default java.util.concurrent.locks.ReadWriteLock getReadWriteLock()
        Optional. As of 3.2.6 this method is no longer called by the core.

        Any locking needed by the cache must be provided internally by the cache provider.

        Returns:
        A ReadWriteLock