Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add multi get #53

Merged
merged 8 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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