Skip to content

Commit

Permalink
chore: update examples to use 1.8.0, CacheClient instead of SimpleCac…
Browse files Browse the repository at this point in the history
…heClient
  • Loading branch information
cprice404 committed Mar 21, 2023
1 parent c1b9d99 commit 1bd5009
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 25 deletions.
5 changes: 1 addition & 4 deletions examples/DictionaryExample/DictionaryExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Momento.Sdk" Version="1.6.0" />
</ItemGroup>
<ItemGroup>
<None Remove="Momento.Sdk" />
<PackageReference Include="Momento.Sdk" Version="1.8.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions examples/DictionaryExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async static Task Main()
var cacheName = ReadCacheName();

// Set up the client
using var client = new SimpleCacheClient(Configurations.Laptop.V1(), authToken, TimeSpan.FromSeconds(60));
using ICacheClient client = new CacheClient(Configurations.Laptop.V1(), authToken, TimeSpan.FromSeconds(60));
await EnsureCacheExistsAsync(client, cacheName);

// Set a value
Expand Down Expand Up @@ -205,7 +205,7 @@ private static string ReadCacheName()
return "default-cache";
}

private static async Task EnsureCacheExistsAsync(ISimpleCacheClient client, string cacheName)
private static async Task EnsureCacheExistsAsync(ICacheClient client, string cacheName)
{
_logger.LogInformation($"Creating cache {cacheName} if it doesn't already exist.");
var createCacheResponse = await client.CreateCacheAsync(cacheName);
Expand Down
4 changes: 3 additions & 1 deletion examples/MomentoApplication/MomentoApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Momento.Sdk" Version="1.6.0" />
<PackageReference Include="Momento.Sdk" Version="1.8.0" />
</ItemGroup>

<ItemGroup>
<None Remove="Microsoft.Extensions.Logging.Console" />
</ItemGroup>

</Project>
12 changes: 6 additions & 6 deletions examples/MomentoApplication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

TimeSpan DEFAULT_TTL = TimeSpan.FromSeconds(60);

using (SimpleCacheClient client = new SimpleCacheClient(Configurations.Laptop.V1(), authProvider, DEFAULT_TTL))
using (ICacheClient client = new CacheClient(Configurations.Laptop.V1(), authProvider, DEFAULT_TTL))
{
await AdvancedExamples.CreateCacheExample(client);
await AdvancedExamples.ListCachesExample(client);
Expand All @@ -29,7 +29,7 @@ public class AdvancedExamples {
const string KEY = "MyKey";
const string VALUE = "MyData";

public static async Task CreateCacheExample(ISimpleCacheClient client)
public static async Task CreateCacheExample(ICacheClient client)
{

Console.WriteLine($"Creating cache {CACHE_NAME}");
Expand All @@ -55,7 +55,7 @@ public static async Task CreateCacheExample(ISimpleCacheClient client)
}
}

public static async Task ListCachesExample(ISimpleCacheClient client) {
public static async Task ListCachesExample(ICacheClient client) {
Console.WriteLine("\nListing caches:");
ListCachesResponse listCachesResponse = await client.ListCachesAsync();
if (listCachesResponse is ListCachesResponse.Success listCachesSuccess)
Expand All @@ -72,7 +72,7 @@ public static async Task ListCachesExample(ISimpleCacheClient client) {
}
}

public static async Task SetGetDeleteExample(ISimpleCacheClient client) {
public static async Task SetGetDeleteExample(ICacheClient client) {
Console.WriteLine($"\nSetting key: {KEY} with value: {VALUE}");
var setResponse = await client.SetAsync(CACHE_NAME, KEY, VALUE);
if (setResponse is CacheSetResponse.Error setError)
Expand Down Expand Up @@ -108,7 +108,7 @@ public static async Task SetGetDeleteExample(ISimpleCacheClient client) {
}
}

public static async Task DeleteCacheExample(ISimpleCacheClient client) {
public static async Task DeleteCacheExample(ICacheClient client) {

Console.WriteLine($"\nDeleting cache {CACHE_NAME}");
var deleteCacheResponse = await client.DeleteCacheAsync(CACHE_NAME);
Expand All @@ -133,7 +133,7 @@ public static void EagerConnectionExample()
var config = Configurations.Laptop.V1();
var eagerConnectionConfig = config.WithTransportStrategy(config.TransportStrategy.WithEagerConnectionTimeout(TimeSpan.FromSeconds(10)));
Console.WriteLine("Creating a momento client with eager connection");
using (SimpleCacheClient client = new SimpleCacheClient(eagerConnectionConfig, authProvider, defaultTtl)) {
using (CacheClient client = new CacheClient(eagerConnectionConfig, authProvider, defaultTtl)) {
Console.WriteLine("Successfully created a momento client with eager connection");
}

Expand Down
6 changes: 6 additions & 0 deletions examples/MomentoExamples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MomentoUsage", "MomentoUsag
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DictionaryExample", "DictionaryExample\DictionaryExample.csproj", "{61F79DA8-BA7F-4F6E-B4EA-29DACF9C7571}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Momento.Sdk", "..\src\Momento.Sdk\Momento.Sdk.csproj", "{ABDFBF7A-9639-4449-91E3-4558C366D297}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -39,6 +41,10 @@ Global
{61F79DA8-BA7F-4F6E-B4EA-29DACF9C7571}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61F79DA8-BA7F-4F6E-B4EA-29DACF9C7571}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61F79DA8-BA7F-4F6E-B4EA-29DACF9C7571}.Release|Any CPU.Build.0 = Release|Any CPU
{ABDFBF7A-9639-4449-91E3-4558C366D297}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ABDFBF7A-9639-4449-91E3-4558C366D297}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ABDFBF7A-9639-4449-91E3-4558C366D297}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ABDFBF7A-9639-4449-91E3-4558C366D297}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Momento.Sdk" Version="1.6.0">
<GeneratePathProperty></GeneratePathProperty>
</PackageReference>
<ProjectReference Include="..\..\src\Momento.Sdk\Momento.Sdk.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion examples/MomentoFSharpApplication/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let authProvider = new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN")

let exerciseCache() = (
printfn "Howdy"
using(new SimpleCacheClient(Configurations.Laptop.V1(), authProvider, DEFAULT_TTL)) (fun client ->
using(new CacheClient(Configurations.Laptop.V1(), 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 @@ -23,11 +23,11 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Momento.Sdk" Version="1.6.0" />
<PackageReference Include="HdrHistogram" Version="2.5.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Momento.Sdk" Version="1.8.0" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions examples/MomentoLoadGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public async Task Run()
{
var authProvider = new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN");

using (var momento = new SimpleCacheClient(
using (ICacheClient momento = new CacheClient(
_momentoClientConfig,
authProvider,
TimeSpan.FromSeconds(CACHE_ITEM_TTL_SECONDS)
Expand Down Expand Up @@ -146,7 +146,7 @@ public async Task Run()


private async Task LaunchAndRunWorkers(
SimpleCacheClient client,
ICacheClient client,
CsharpLoadGeneratorContext context,
int workerId,
int delayMillisBetweenRequests,
Expand Down Expand Up @@ -201,7 +201,7 @@ private void PrintStats(LongHistogram setsAccumulatingHistogram, LongHistogram g
_logger.LogInformation($"Load gen data point:\t{_options.numberOfConcurrentRequests}\t{Tps(context, context.GlobalRequestCount)}\t{getsAccumulatingHistogram.GetValueAtPercentile(50)}\t{getsAccumulatingHistogram.GetValueAtPercentile(99.9)}");
}

private async Task IssueAsyncSetGet(SimpleCacheClient client, CsharpLoadGeneratorContext context, int workerId, int operationId, int delayMillisBetweenRequests)
private async Task IssueAsyncSetGet(ICacheClient client, CsharpLoadGeneratorContext context, int workerId, int operationId, int delayMillisBetweenRequests)
{
var cacheKey = $"worker{workerId}operation{operationId}";

Expand Down Expand Up @@ -247,7 +247,7 @@ Func<Task<Tuple<AsyncSetGetResult, TResult>>> block
return result.Item2;
}

private async Task<Tuple<AsyncSetGetResult, CacheGetResponse?>> IssueGetRequest(SimpleCacheClient client, String cacheKey)
private async Task<Tuple<AsyncSetGetResult, CacheGetResponse?>> IssueGetRequest(ICacheClient client, String cacheKey)
{
var getResponse = await client.GetAsync(CACHE_NAME, cacheKey);
if (getResponse is CacheGetResponse.Hit hit)
Expand All @@ -268,7 +268,7 @@ Func<Task<Tuple<AsyncSetGetResult, TResult>>> block
}
}

private async Task<Tuple<AsyncSetGetResult, CacheSetResponse?>> IssueSetRequest(SimpleCacheClient client, String cacheKey, String cacheValue)
private async Task<Tuple<AsyncSetGetResult, CacheSetResponse?>> IssueSetRequest(ICacheClient client, String cacheKey, String cacheValue)
{
var setResponse = await client.SetAsync(CACHE_NAME, cacheKey, cacheValue);
if (setResponse is CacheSetResponse.Success success)
Expand Down
2 changes: 1 addition & 1 deletion examples/MomentoUsage/MomentoUsage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<None Remove="Microsoft.SourceLink.GitHub" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Momento.Sdk" Version="1.6.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Momento.Sdk" Version="1.8.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion examples/MomentoUsage/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const string VALUE = "MyData";
TimeSpan DEFAULT_TTL = TimeSpan.FromSeconds(60);

using (SimpleCacheClient client = new SimpleCacheClient(Configurations.Laptop.V1(), authProvider, DEFAULT_TTL))
using (ICacheClient client = new CacheClient(Configurations.Laptop.V1(), authProvider, DEFAULT_TTL))
{
var createCacheResponse = await client.CreateCacheAsync(CACHE_NAME);
if (createCacheResponse is CreateCacheResponse.Error createError)
Expand Down

0 comments on commit 1bd5009

Please sign in to comment.