Package play.cache
Class SyncCacheApiAdapter
- Object
-
- play.cache.SyncCacheApiAdapter
-
- All Implemented Interfaces:
SyncCacheApi
public class SyncCacheApiAdapter extends Object implements SyncCacheApi
Adapts a Scala SyncCacheApi to a Java SyncCacheApi
-
-
Constructor Summary
Constructors Constructor Description SyncCacheApiAdapter(play.api.cache.SyncCacheApi scalaApi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Optional<T>
get(String key)
Retrieves an object by key.<T> T
getOrElseUpdate(String key, Callable<T> block)
Retrieve a value from the cache, or set it from a default Callable function.<T> T
getOrElseUpdate(String key, Callable<T> block, int expiration)
Retrieve a value from the cache, or set it from a default Callable function.void
remove(String key)
Removes a value from the cache.void
set(String key, Object value)
Sets a value without expiration.void
set(String key, 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
-
Methods inherited from interface play.cache.SyncCacheApi
getOptional
-
-
-
-
Method Detail
-
get
public <T> Optional<T> get(String key)
Description copied from interface:SyncCacheApi
Retrieves an object by key.- Specified by:
get
in interfaceSyncCacheApi
- 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 interfaceSyncCacheApi
- Type Parameters:
T
- the type of the value- Parameters:
key
- Item key.block
- block returning value to set if key does not existexpiration
- 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 interfaceSyncCacheApi
- 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 interfaceSyncCacheApi
- 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 interfaceSyncCacheApi
- 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 interfaceSyncCacheApi
- Parameters:
key
- The key to remove the value for.
-
-