Package play.cache

Interface SyncCacheApi

    • Method Detail

      • get

        <T> Optional<T> get​(String key)
        Retrieves an object by key.
        Type Parameters:
        T - the type of the stored object
        Parameters:
        key - the key to look up
        Returns:
        the object wrapped in an Optional
      • getOptional

        @Deprecated
        default <T> Optional<T> getOptional​(String key)
        Deprecated.
        Deprecated as of 2.8.0. Renamed to get(String).
        Retrieves an object by key.
        Type Parameters:
        T - the type of the stored object
        Parameters:
        key - the key to look up
        Returns:
        the object wrapped in an Optional
      • getOrElseUpdate

        <T> T getOrElseUpdate​(String key,
                              Callable<T> block,
                              int expiration)
        Retrieve a value from the cache, or set it from a default Callable function.
        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

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

        The value has no expiration.

        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

        void set​(String key,
                 Object value,
                 int expiration)
        Sets a value with expiration.
        Parameters:
        key - Item key.
        value - The value to set.
        expiration - expiration in seconds
      • set

        void set​(String key,
                 Object value)
        Sets a value without expiration.
        Parameters:
        key - Item key.
        value - The value to set.
      • remove

        void remove​(String key)
        Removes a value from the cache.
        Parameters:
        key - The key to remove the value for.