-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
ff54fea
commit 5831322
Showing
7 changed files
with
106 additions
and
2 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
44 changes: 44 additions & 0 deletions
44
momento-sdk/src/intTest/java/momento/sdk/CacheGetBatchTest.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,44 @@ | ||
package momento.sdk; | ||
|
||
import java.time.Duration; | ||
import momento.sdk.auth.CredentialProvider; | ||
import momento.sdk.config.Configurations; | ||
import momento.sdk.responses.cache.control.CacheCreateResponse; | ||
import org.junit.jupiter.api.Test; | ||
|
||
final class CacheGetBatchTest { | ||
@Test | ||
public void getBatchSetBatchHappyPath() { | ||
CredentialProvider credentialProvider = | ||
CredentialProvider.withMomentoLocal(System.getenv("MOMENTO_API_KEY")); | ||
CacheClient cacheClient = | ||
new CacheClientBuilder( | ||
credentialProvider, Configurations.Laptop.latest(), Duration.ofMinutes(1)) | ||
.build(); | ||
|
||
CacheCreateResponse resp = cacheClient.createCache("cache").join(); | ||
System.out.println(resp); | ||
// SetResponse setCacheResponse = cacheClient.set("cache", "key1", "val1", | ||
// Duration.ofMinutes(1)).join(); | ||
// System.out.println(setCacheResponse); | ||
|
||
// final Map<String, String> items = new HashMap<>(); | ||
// items.put("key1", "val1"); | ||
// items.put("key2", "val2"); | ||
// items.put("key3", "val3"); | ||
// final SetBatchResponse setBatchResponse = | ||
// cacheClient.setBatch("cache", items, Duration.ofMinutes(1)).join(); | ||
// assertThat(setBatchResponse).isInstanceOf(SetBatchResponse.Success.class); | ||
// for (SetResponse setResponse : | ||
// ((SetBatchResponse.Success) setBatchResponse).results().values()) { | ||
// assertThat(setResponse).isInstanceOf(SetResponse.Success.class); | ||
// } | ||
// | ||
// final GetBatchResponse getBatchResponse = cacheClient.getBatch("cache", | ||
// items.keySet()).join(); | ||
// | ||
// assertThat(getBatchResponse).isInstanceOf(GetBatchResponse.Success.class); | ||
// assertThat(((GetBatchResponse.Success) getBatchResponse).valueMapStringString()) | ||
// .containsExactlyEntriesOf(items); | ||
} | ||
} |
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,26 @@ | ||
package momento.sdk; | ||
|
||
import java.time.Duration; | ||
import momento.sdk.auth.CredentialProvider; | ||
import momento.sdk.config.Configurations; | ||
import momento.sdk.responses.cache.control.CacheCreateResponse; | ||
|
||
public class Program { | ||
public static void main(String[] args) { | ||
CredentialProvider credentialProvider = | ||
CredentialProvider.withMomentoLocal(System.getenv("MOMENTO_API_KEY")); | ||
CacheClient cacheClient = | ||
new CacheClientBuilder( | ||
credentialProvider, Configurations.Laptop.latest(), Duration.ofMinutes(1)) | ||
.build(); | ||
|
||
CacheCreateResponse createResponse = cacheClient.createCache("cache").join(); | ||
if (createResponse instanceof CacheCreateResponse.Success) { | ||
System.out.println("Cache created successfully"); | ||
} else { | ||
System.out.println("Failed to create cache" + createResponse.toString()); | ||
CacheCreateResponse.Error error = (CacheCreateResponse.Error) createResponse; | ||
System.out.println("Failed to create cache: " + error.getErrorCode()); | ||
} | ||
} | ||
} |
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
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