Skip to content

Commit

Permalink
feat: Add multi get (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
poppoerika authored May 10, 2022
1 parent 1533357 commit 5eb7772
Show file tree
Hide file tree
Showing 7 changed files with 321 additions and 65 deletions.
60 changes: 30 additions & 30 deletions Momento/MomentoSdk.csproj
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<None Remove="Momento" />
<None Remove="Google.Protobuf" />
<None Remove="Grpc.Net.Client" />
<None Remove="Grpc.Core" />
<None Remove="JWT" />
<None Remove="Exceptions\" />
<None Remove="Responses\" />
<None Remove="Requests\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.19.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.40.0" />
<PackageReference Include="Grpc.Core" Version="2.41.1" />
<PackageReference Include="Momento" Version="0.8.0" />
<PackageReference Include="JWT" Version="8.4.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.16.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Exceptions\" />
<Folder Include="Responses\" />
<Folder Include="Requests\" />
</ItemGroup>
</Project>
<?xml version="1.0" encoding="UTF-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<None Remove="Momento" />
<None Remove="Google.Protobuf" />
<None Remove="Grpc.Net.Client" />
<None Remove="Grpc.Core" />
<None Remove="JWT" />
<None Remove="Exceptions\" />
<None Remove="Responses\" />
<None Remove="Requests\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.19.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.40.0" />
<PackageReference Include="Grpc.Core" Version="2.41.1" />
<PackageReference Include="Momento" Version="0.8.0" />
<PackageReference Include="JWT" Version="8.4.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.16.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Exceptions\" />
<Folder Include="Responses\" />
<Folder Include="Requests\" />
</ItemGroup>
</Project>
16 changes: 16 additions & 0 deletions Momento/Responses/CacheMultiGetFailureResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace MomentoSdk.Responses
{
public class CacheMultiGetFailureResponse
{
public byte[] Key { get; private set; }
public Exception Failure { get; private set; }

public CacheMultiGetFailureResponse(byte[] key, Exception failure)
{
Key = key;
Failure = failure;
}
}
}
69 changes: 69 additions & 0 deletions Momento/Responses/CacheMultiGetResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System.Collections.Generic;

namespace MomentoSdk.Responses
{
public class CacheMultiGetResponse
{
private readonly List<CacheGetResponse> successfulResponses;
private readonly List<CacheMultiGetFailureResponse> failedResponses;

private readonly CacheGetResponse successfulResponse = null;
private readonly CacheMultiGetFailureResponse failedResponse = null;

public CacheMultiGetResponse(List<CacheGetResponse> cacheGetResponses, List<CacheMultiGetFailureResponse> cacheMultiGetFailureResponses)
{
successfulResponses = cacheGetResponses;
failedResponses = cacheMultiGetFailureResponses;
}

public CacheMultiGetResponse(CacheGetResponse cacheGetResponse)
{
successfulResponse = cacheGetResponse;
}

public CacheMultiGetResponse(CacheMultiGetFailureResponse cacheMultiGetFailureResponse)
{
failedResponse = cacheMultiGetFailureResponse;
}

public CacheGetResponse SuccessfulResponse()
{
return successfulResponse;
}

public CacheMultiGetFailureResponse FailedResponse()
{
return failedResponse;
}

public List<CacheGetResponse> SuccessfulResponses()
{
return successfulResponses;
}

public List<CacheMultiGetFailureResponse> FailedResponses()
{
return failedResponses;
}

public List<string> Strings()
{
List<string> values = new();
foreach (CacheGetResponse response in successfulResponses)
{
values.Add(response.String());
}
return values;
}

public List<byte[]> Bytes()
{
List<byte[]> values = new();
foreach (CacheGetResponse response in successfulResponses)
{
values.Add(response.Bytes());
}
return values;
}
}
}
Loading

0 comments on commit 5eb7772

Please sign in to comment.