-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update examples to release 0.37.0 (#292)
Update the examples to SDK release version 0.37.0.
- Loading branch information
Showing
8 changed files
with
29 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,9 @@ | |
const string CACHE_NAME = "momento-example"; | ||
const string KEY = "MyKey"; | ||
const string VALUE = "MyData"; | ||
const uint DEFAULT_TTL_SECONDS = 60; | ||
TimeSpan DEFAULT_TTL = TimeSpan.FromSeconds(60); | ||
|
||
using (SimpleCacheClient client = new SimpleCacheClient(Configurations.Laptop.Latest(), authProvider, DEFAULT_TTL_SECONDS)) | ||
using (SimpleCacheClient client = new SimpleCacheClient(Configurations.Laptop.Latest(), authProvider, DEFAULT_TTL)) | ||
{ | ||
Console.WriteLine($"Creating cache {CACHE_NAME}"); | ||
var createCacheResponse = await client.CreateCacheAsync(CACHE_NAME); | ||
|
@@ -23,7 +23,8 @@ | |
if (createCacheError.ErrorCode == MomentoErrorCode.LIMIT_EXCEEDED_ERROR) | ||
{ | ||
Console.WriteLine("Error: cache limit exceeded. We need to talk to [email protected]! Exiting."); | ||
} else | ||
} | ||
else | ||
{ | ||
Console.WriteLine($"Error creating cache: {createCacheError.Message}. Exiting."); | ||
} | ||
|
@@ -48,7 +49,8 @@ | |
Console.WriteLine($"- {cacheInfo.Name}"); | ||
} | ||
token = listCachesSuccess.NextPageToken; | ||
} else if (listCachesResponse is ListCachesResponse.Error listCachesError) | ||
} | ||
else if (listCachesResponse is ListCachesResponse.Error listCachesError) | ||
{ | ||
// We do not consider this a fatal error, so we just report it. | ||
Console.WriteLine($"Error listing caches: {listCachesError.Message}"); | ||
|
@@ -70,18 +72,22 @@ | |
if (getResponse is CacheGetResponse.Hit getHit) | ||
{ | ||
Console.WriteLine($"Looked up value: {getHit.ValueString}, Stored value: {VALUE}"); | ||
} else if (getResponse is CacheGetResponse.Miss) | ||
} | ||
else if (getResponse is CacheGetResponse.Miss) | ||
{ | ||
// This shouldn't be fatal but should be reported. | ||
Console.WriteLine($"Error: got a cache miss for {KEY}!"); | ||
} else if (getResponse is CacheGetResponse.Error getError) { | ||
} | ||
else if (getResponse is CacheGetResponse.Error getError) | ||
{ | ||
// Also not considered fatal. | ||
Console.WriteLine($"Error getting value: {getError.Message}!"); | ||
} | ||
|
||
Console.WriteLine($"\nDeleting key {KEY}"); | ||
var deleteKeyResponse = await client.DeleteAsync(CACHE_NAME, KEY); | ||
if (deleteKeyResponse is CacheDeleteResponse.Error deleteKeyError) { | ||
if (deleteKeyResponse is CacheDeleteResponse.Error deleteKeyError) | ||
{ | ||
// Also not considred fatal. | ||
Console.WriteLine($"Error deleting key: {deleteKeyError.Message}!"); | ||
} | ||
|
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
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