Skip to content

Commit

Permalink
feat: CreateOrGetCache -> GetOrCreateCache (#12)
Browse files Browse the repository at this point in the history
* feat: CreateOrGetCache -> GetOrCreateCache

* revert
  • Loading branch information
gautamomento authored Nov 1, 2021
1 parent ba4c038 commit 50ea72d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Momento/Momento.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Momento(string authToken)
/// <param name="cacheName"></param>
/// <param name="defaultTtlSeconds"></param>
/// <returns>An instance of MomentoCache to perform sets and against against</returns>
public MomentoCache CreateOrGetCache(String cacheName, uint defaultTtlSeconds)
public MomentoCache GetOrCreateCache(String cacheName, uint defaultTtlSeconds)
{
try
{
Expand Down
8 changes: 4 additions & 4 deletions MomentoIntegrationTest/CacheTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void HappyPath()
String cacheValue = "some cache value";
uint defaultTtlSeconds = 10;
Momento momento = new Momento(authKey);
MomentoCache cache = momento.CreateOrGetCache(cacheName, defaultTtlSeconds);
MomentoCache cache = momento.GetOrCreateCache(cacheName, defaultTtlSeconds);
cache.Set(cacheKey, cacheValue, defaultTtlSeconds);
CacheGetResponse result = cache.Get(cacheKey);
String stringResult = result.String();
Expand All @@ -31,7 +31,7 @@ public async void HappyPathExpiredTtl()
String cacheValue = "some cache value";
uint defaultTtlSeconds = 10;
Momento momento = new Momento(authKey);
MomentoCache cache = momento.CreateOrGetCache(cacheName, defaultTtlSeconds);
MomentoCache cache = momento.GetOrCreateCache(cacheName, defaultTtlSeconds);
cache.Set(cacheKey, cacheValue, 1);
await Task.Delay(1100);
CacheGetResponse result = cache.Get(cacheKey);
Expand All @@ -45,7 +45,7 @@ public async void HappyPathAsync()
String cacheValue = "async cache value";
uint defaultTtlSeconds = 10;
Momento momento = new Momento(authKey);
MomentoCache cache = momento.CreateOrGetCache(cacheName, defaultTtlSeconds);
MomentoCache cache = momento.GetOrCreateCache(cacheName, defaultTtlSeconds);
await cache.SetAsync(cacheKey, cacheValue, defaultTtlSeconds);
CacheGetResponse result = await cache.GetAsync(cacheKey);
Assert.Equal(MomentoCacheResult.Hit, result.Result);
Expand All @@ -57,7 +57,7 @@ public void HappyPathMiss()
{
uint defaultTtlSeconds = 10;
Momento momento = new Momento(authKey);
MomentoCache cache = momento.CreateOrGetCache(cacheName, defaultTtlSeconds);
MomentoCache cache = momento.GetOrCreateCache(cacheName, defaultTtlSeconds);
CacheGetResponse result = cache.Get(Guid.NewGuid().ToString());
Assert.Equal(MomentoCacheResult.Miss, result.Result);
Assert.Null(result.String());
Expand Down

0 comments on commit 50ea72d

Please sign in to comment.