Interface Cache

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void clear()
      Clears all entries from the cache (optional operation).
      java.lang.Object get​(java.lang.String key)
      Retrieves an object from the cache
      default java.util.List<java.lang.String> getKeys()
      Retrieves a List of all the keys in the cache (optional operation).
      void put​(java.lang.String key, java.io.Serializable value)
      Puts a serializable object into the cache.
      default void put​(java.lang.String key, java.io.Serializable value, long ttl)
      Puts a serializable object into the cache, specifying a expiration (optional operation).
      default void put​(java.lang.String key, java.io.Serializable value, TimeInterval expiry)
      Puts a serializable object into the cache, specifying a expiration (optional operation).
      default void put​(java.lang.String key, java.lang.Object value)
      Puts any object into the cache (optional operation).
      default void put​(java.lang.String key, java.lang.Object value, long ttl)
      Puts an object into the cache, specifying a expiration (optional operation).
      default void put​(java.lang.String key, java.lang.Object value, TimeInterval expiry)
      Puts an object into the cache, specifying a expiration (optional operation).
      void remove​(java.lang.String key)
      Removes an object from the cache.
      default int size()  
    • Method Detail

      • put

        void put​(java.lang.String key,
                 java.io.Serializable value)
          throws CoreException
        Puts a serializable object into the cache. Guaranteed to be supported by all cache implementations.
        Parameters:
        key - key to store the value against
        value - value to be stored
        Throws:
        CoreException - if there was an exception accessing the cache.
      • put

        default void put​(java.lang.String key,
                         java.lang.Object value)
                  throws CoreException
        Puts any object into the cache (optional operation).

        Not guaranteed to be supported by all cache implementations as some persistent caches require serialization.

        Parameters:
        key - key to store the value against
        value - value to be stored
        Throws:
        java.lang.UnsupportedOperationException - if the operation is not supported by this cache instance
        CoreException - if there was an exception accessing the cache.
        Implementation Note:
        The default implementation throws an instance of UnsupportedOperationException and performs no other action.
      • put

        default void put​(java.lang.String key,
                         java.io.Serializable value,
                         TimeInterval expiry)
                  throws CoreException
        Puts a serializable object into the cache, specifying a expiration (optional operation).

        Since JSR107 doesn't define per item cache expiry; this may not be supported by all cache implementations.

        Parameters:
        key - key to store the value against
        value - value to be stored
        expiry - the expiry expressed as a TimeInterval
        Throws:
        CoreException - if there was an exception accessing the cache.
        Implementation Note:
        The default implementation just calls put(String, Serializable, long)
      • put

        default void put​(java.lang.String key,
                         java.io.Serializable value,
                         long ttl)
                  throws CoreException
        Puts a serializable object into the cache, specifying a expiration (optional operation).

        Since JSR107 doesn't define per item cache expiry; this may not be supported by all cache implementations.

        Parameters:
        key - key to store the value against
        value - value to be stored
        ttl - the TTL in milliseconds.
        Throws:
        java.lang.UnsupportedOperationException - if the this operation is not supported by this cache instance
        CoreException - if there was an exception accessing the cache.
        Implementation Note:
        The default implementation throws an instance of UnsupportedOperationException and performs no other action.
      • put

        default void put​(java.lang.String key,
                         java.lang.Object value,
                         TimeInterval expiry)
                  throws CoreException
        Puts an object into the cache, specifying a expiration (optional operation).

        Since JSR107 doesn't define per item cache expiry; this may not be supported by all cache implementations.

        Parameters:
        key - key to store the value against
        value - value to be stored
        expiry - the expiry specified as a TimeInterval
        Throws:
        CoreException - if there was an exception accessing the cache.
        Implementation Note:
        The default implementation just calls put(String, Object, long)
      • put

        default void put​(java.lang.String key,
                         java.lang.Object value,
                         long ttl)
                  throws CoreException
        Puts an object into the cache, specifying a expiration (optional operation).

        Since JSR107 doesn't define per item cache expiry; this may not be supported by all cache implementations.

        Parameters:
        key - key to store the value against
        value - value to be stored
        ttl - the TTL in milliseconds.
        Throws:
        java.lang.UnsupportedOperationException - if the this operation is not supported by this cache instance
        CoreException - if there was an exception accessing the cache.
        Implementation Note:
        The default implementation throws an instance of UnsupportedOperationException and performs no other action.
      • get

        java.lang.Object get​(java.lang.String key)
                      throws CoreException
        Retrieves an object from the cache
        Parameters:
        key - the key to look up the object
        Returns:
        the object from the cache or null if it doesn't exist
        Throws:
        CoreException - if there was an exception accessing the cache.
      • remove

        void remove​(java.lang.String key)
             throws CoreException
        Removes an object from the cache. Ignores nonexistent elements
        Parameters:
        key - the key to locate the object in the cache
        Throws:
        CoreException - if there was an exception accessing the cache.
      • getKeys

        default java.util.List<java.lang.String> getKeys()
                                                  throws CoreException
        Retrieves a List of all the keys in the cache (optional operation).
        Returns:
        a List of all the keys in the cache
        Throws:
        java.lang.UnsupportedOperationException - if the operation is not supported by this cache instance
        CoreException - if there was an exception accessing the cache.
        Implementation Note:
        The default implementation throws an instance of UnsupportedOperationException and performs no other action.
      • clear

        default void clear()
                    throws CoreException
        Clears all entries from the cache (optional operation).
        Throws:
        java.lang.UnsupportedOperationException - if the operation is not supported by this cache instance
        CoreException - if there was an exception accessing the cache.
        Implementation Note:
        The default implementation throws an instance of UnsupportedOperationException and performs no other action.
      • size

        default int size()
                  throws CoreException
        Returns:
        the number of items in the cache (optional operation).
        Throws:
        java.lang.UnsupportedOperationException - if the operation is not supported by this cache instance
        CoreException - if there was an exception accessing the cache.
        Implementation Note:
        The default implementation throws an instance of UnsupportedOperationException and performs no other action.