Skip to content

Commit

Permalink
chore: update examples to release 0.37.0 (#292)
Browse files Browse the repository at this point in the history
Update the examples to SDK release version 0.37.0.
  • Loading branch information
malandis authored Oct 10, 2022
1 parent 8f541f5 commit 6de65b5
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/MomentoApplication/MomentoApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Momento.Sdk" Version="0.36.0" />
<PackageReference Include="Momento.Sdk" Version="0.37.0" />
</ItemGroup>
<ItemGroup>
<None Remove="Microsoft.Extensions.Logging.Console" />
Expand Down
20 changes: 13 additions & 7 deletions examples/MomentoApplication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.");
}
Expand All @@ -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}");
Expand All @@ -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}!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Momento.Sdk" Version="0.36.0">
<PackageReference Include="Momento.Sdk" Version="0.37.0">
<GeneratePathProperty></GeneratePathProperty>
</PackageReference>
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions examples/MomentoFSharpApplication/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ open Momento.Sdk.Responses
open System

let CACHE_NAME = "cache"
let DEFAULT_TTL_SECONDS = 60u
let DEFAULT_TTL = TimeSpan.FromSeconds(60)
let authProvider = new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN")

let exerciseCache() = (
printfn "Howdy"
using(new SimpleCacheClient(Configurations.Laptop.Latest(), authProvider, DEFAULT_TTL_SECONDS)) (fun client ->
using(new SimpleCacheClient(Configurations.Laptop.Latest(), authProvider, DEFAULT_TTL)) (fun client ->
let createCacheResult = client.CreateCacheAsync(CACHE_NAME) |> Async.AwaitTask

printfn("Listing caches:")
Expand Down
2 changes: 1 addition & 1 deletion examples/MomentoLoadGen/MomentoLoadGen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Momento.Sdk" Version="0.36.0" />
<PackageReference Include="Momento.Sdk" Version="0.37.0" />
<PackageReference Include="HdrHistogram" Version="2.5.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion examples/MomentoLoadGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async Task Run()
using (var momento = new SimpleCacheClient(
_momentoClientConfig,
authProvider,
CACHE_ITEM_TTL_SECONDS
TimeSpan.FromSeconds(CACHE_ITEM_TTL_SECONDS)
))
{
try
Expand Down
2 changes: 1 addition & 1 deletion examples/MomentoUsage/MomentoUsage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<None Remove="Momento.Sdk" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Momento.Sdk" Version="0.36.0" />
<PackageReference Include="Momento.Sdk" Version="0.37.0" />
</ItemGroup>
</Project>
14 changes: 9 additions & 5 deletions examples/MomentoUsage/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@
const string CACHE_NAME = "cache";
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))
{
var createCacheResponse = await client.CreateCacheAsync(CACHE_NAME);
if (createCacheResponse is CreateCacheResponse.Error createError) {
if (createCacheResponse is CreateCacheResponse.Error createError)
{
Console.WriteLine($"Error creating cache: {createError.Message}. Exiting.");
Environment.Exit(1);
}

Console.WriteLine($"Setting key: {KEY} with value: {VALUE}");
var setResponse = await client.SetAsync(CACHE_NAME, KEY, VALUE);
if (setResponse is CacheSetResponse.Error setError) {
if (setResponse is CacheSetResponse.Error setError)
{
Console.WriteLine($"Error setting value: {setError.Message}. Exiting.");
Environment.Exit(1);
}
Expand All @@ -30,7 +32,9 @@
if (getResponse is CacheGetResponse.Hit hitResponse)
{
Console.WriteLine($"Looked up value: {hitResponse.ValueString}, Stored value: {VALUE}");
} else if (getResponse is CacheGetResponse.Error getError) {
}
else if (getResponse is CacheGetResponse.Error getError)
{
Console.WriteLine($"Error getting value: {getError.Message}");
}
}

0 comments on commit 6de65b5

Please sign in to comment.