-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
623 additions
and
478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
framework/src/play-cache/src/main/java/play/cache/BlockingCacheApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (C) 2009-2016 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
package play.cache; | ||
|
||
import java.util.concurrent.Callable; | ||
|
||
/** | ||
* A CacheApi that makes blocking calls. | ||
*/ | ||
public interface BlockingCacheApi { | ||
/** | ||
* Retrieves an object by key. | ||
* | ||
* @param <T> the type of the stored object | ||
* @param key the key to look up | ||
* @return the object or null | ||
*/ | ||
<T> T get(String key); | ||
|
||
/** | ||
* Retrieve a value from the cache, or set it from a default Callable function. | ||
* | ||
* @param <T> the type of the value | ||
* @param key Item key. | ||
* @param block block returning value to set if key does not exist | ||
* @param expiration expiration period in seconds. | ||
* @return the value | ||
*/ | ||
<T> T getOrElseUpdate(String key, Callable<T> block, int expiration); | ||
|
||
/** | ||
* Retrieve a value from the cache, or set it from a default Callable function. | ||
* | ||
* The value has no expiration. | ||
* | ||
* @param <T> the type of the value | ||
* @param key Item key. | ||
* @param block block returning value to set if key does not exist | ||
* @return the value | ||
*/ | ||
<T> T getOrElseUpdate(String key, Callable<T> block); | ||
|
||
/** | ||
* Sets a value with expiration. | ||
* | ||
* @param key Item key. | ||
* @param value The value to set. | ||
* @param expiration expiration in seconds | ||
*/ | ||
void set(String key, Object value, int expiration); | ||
|
||
/** | ||
* Sets a value without expiration. | ||
* | ||
* @param key Item key. | ||
* @param value The value to set. | ||
*/ | ||
void set(String key, Object value); | ||
|
||
/** | ||
* Removes a value from the cache. | ||
* | ||
* @param key The key to remove the value for. | ||
*/ | ||
void remove(String key); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.