Package play.cache

Class SyncCacheApiAdapter

  • All Implemented Interfaces:
    SyncCacheApi

    public class SyncCacheApiAdapter
    extends Object
    implements SyncCacheApi
    Adapts a Scala SyncCacheApi to a Java SyncCacheApi
    • Constructor Detail

      • SyncCacheApiAdapter

        public SyncCacheApiAdapter​(play.api.cache.SyncCacheApi scalaApi)
    • Method Detail

      • get

        public <T> Optional<T> get​(String key)
        Description copied from interface: SyncCacheApi
        Retrieves an object by key.
        Specified by:
        get in interface SyncCacheApi
        Type Parameters:
        T - the type of the stored object
        Parameters:
        key - the key to look up
        Returns:
        the object wrapped in an Optional
      • getOrElseUpdate

        public <T> T getOrElseUpdate​(String key,
                                     Callable<T> block,
                                     int expiration)
        Description copied from interface: SyncCacheApi
        Retrieve a value from the cache, or set it from a default Callable function.
        Specified by:
        getOrElseUpdate in interface SyncCacheApi
        Type Parameters:
        T - the type of the value
        Parameters:
        key - Item key.
        block - block returning value to set if key does not exist
        expiration - expiration period in seconds.
        Returns:
        the value
      • getOrElseUpdate

        public <T> T getOrElseUpdate​(String key,
                                     Callable<T> block)
        Description copied from interface: SyncCacheApi
        Retrieve a value from the cache, or set it from a default Callable function.

        The value has no expiration.

        Specified by:
        getOrElseUpdate in interface SyncCacheApi
        Type Parameters:
        T - the type of the value
        Parameters:
        key - Item key.
        block - block returning value to set if key does not exist
        Returns:
        the value
      • set

        public void set​(String key,
                        Object value,
                        int expiration)
        Description copied from interface: SyncCacheApi
        Sets a value with expiration.
        Specified by:
        set in interface SyncCacheApi
        Parameters:
        key - Item key.
        value - The value to set.
        expiration - expiration in seconds
      • set

        public void set​(String key,
                        Object value)
        Description copied from interface: SyncCacheApi
        Sets a value without expiration.
        Specified by:
        set in interface SyncCacheApi
        Parameters:
        key - Item key.
        value - The value to set.
      • remove

        public void remove​(String key)
        Description copied from interface: SyncCacheApi
        Removes a value from the cache.
        Specified by:
        remove in interface SyncCacheApi
        Parameters:
        key - The key to remove the value for.