diff --git a/momento-sdk/src/intTest/java/momento/sdk/MomentoTest.java b/momento-sdk/src/intTest/java/momento/sdk/MomentoTest.java index e127c87f..aa593bba 100644 --- a/momento-sdk/src/intTest/java/momento/sdk/MomentoTest.java +++ b/momento-sdk/src/intTest/java/momento/sdk/MomentoTest.java @@ -53,7 +53,7 @@ void testHappyPath() { @Test void recreatingCacheWithSameName_throwsAlreadyExists() { Momento momento = Momento.builder(authToken).build(); - momento.createOrGetCache(cacheName); + momento.getOrCreateCache(cacheName); assertThrows(CacheAlreadyExistsException.class, () -> momento.createCache(cacheName)); } @@ -63,7 +63,7 @@ void testInvalidCacheName() { Momento.builder(authToken).endpointOverride(DEFAULT_MOMENTO_HOSTED_ZONE_ENDPOINT).build(); assertThrows(InvalidArgumentException.class, () -> momento.createCache(" ")); - assertThrows(InvalidArgumentException.class, () -> momento.createOrGetCache(" ")); + assertThrows(InvalidArgumentException.class, () -> momento.getOrCreateCache(" ")); } @Test @@ -90,7 +90,7 @@ void deleteForNonExistantCache_throwsNotFound() { } private static void runHappyPathTest(Momento momento, String cacheName) { - Cache cache = momento.createOrGetCache(cacheName); + Cache cache = momento.getOrCreateCache(cacheName); String key = java.util.UUID.randomUUID().toString(); diff --git a/momento-sdk/src/main/java/momento/sdk/Momento.java b/momento-sdk/src/main/java/momento/sdk/Momento.java index a59628ac..bbc7756c 100644 --- a/momento-sdk/src/main/java/momento/sdk/Momento.java +++ b/momento-sdk/src/main/java/momento/sdk/Momento.java @@ -107,7 +107,8 @@ public DeleteCacheResponse deleteCache(String cacheName) { * @return {@link Cache} client to perform operations against the Momento Cache with the provided * name. */ - public Cache createOrGetCache(String cacheName) { + public Cache getOrCreateCache(String cacheName) { + // TODO: Switch this to do a get first followed by Create checkCacheNameValid(cacheName); try { createCache(cacheName);