play.cache
Class Cache

java.lang.Object
  extended by play.cache.Cache

public class Cache
extends java.lang.Object

Provides an access point for Play's cache service.


Constructor Summary
Cache()
           
 
Method Summary
static java.lang.Object get(java.lang.String key)
          Retrieves an object by key.
static
<T> T
getOrElse(java.lang.String key, java.util.concurrent.Callable<T> block, int expiration)
          Retrieve a value from the cache, or set it from a default Callable function.
static void remove(java.lang.String key)
           
static void set(java.lang.String key, java.lang.Object value)
          Sets a value without expiration.
static void set(java.lang.String key, java.lang.Object value, int expiration)
          Sets a value with expiration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cache

public Cache()
Method Detail

get

public static java.lang.Object get(java.lang.String key)
Retrieves an object by key.

Returns:
object

getOrElse

public static <T> T getOrElse(java.lang.String key,
                              java.util.concurrent.Callable<T> block,
                              int expiration)
                   throws java.lang.Exception
Retrieve a value from the cache, or set it from a default Callable function.

Parameters:
key - Item key.
block - block returning value to set if key does not exist
expiration - expiration period in seconds.
Returns:
value
Throws:
java.lang.Exception

set

public static void set(java.lang.String key,
                       java.lang.Object value,
                       int expiration)
Sets a value with expiration.

Parameters:
expiration - expiration in seconds

set

public static void set(java.lang.String key,
                       java.lang.Object value)
Sets a value without expiration.


remove

public static void remove(java.lang.String key)