-
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.
- Loading branch information
Showing
65 changed files
with
2,116 additions
and
329 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
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 |
---|---|---|
@@ -1,32 +1,92 @@ | ||
# Momento client-sdk-csharp | ||
<img src="https://docs.momentohq.com/img/logo.svg" alt="logo" width="400"/> | ||
|
||
[![project status](https://momentohq.github.io/standards-and-practices/badges/project-status-official.svg)](https://github.com/momentohq/standards-and-practices/blob/main/docs/momento-on-github.md) | ||
[![project stability](https://momentohq.github.io/standards-and-practices/badges/project-stability-experimental.svg)](https://github.com/momentohq/standards-and-practices/blob/main/docs/momento-on-github.md) | ||
|
||
# Momento .NET Client Library | ||
|
||
|
||
:warning: Experimental SDK :warning: | ||
|
||
C# SDK for Momento is experimental and under active development. | ||
There could be non-backward compatible changes or removal in the future. | ||
Please be aware that you may need to update your source code with the current version of the SDK when its version gets upgraded. | ||
This is an official Momento SDK, but the API is in an early experimental stage and subject to backward-incompatible | ||
changes. For more info, click on the experimental badge above. | ||
|
||
--- | ||
|
||
<br/> | ||
.NET client SDK for Momento Serverless Cache: a fast, simple, pay-as-you-go caching solution without | ||
any of the operational overhead required by traditional caching solutions! | ||
|
||
C# SDK for Momento, a serverless cache that automatically scales without any of the operational overhead required by traditional caching solutions. | ||
|
||
<br/> | ||
|
||
## Getting Started :running: | ||
|
||
### Requirements | ||
1. brew install nuget | ||
1. brew install --cask dotnet | ||
1. [Visual Studio](https://visualstudio.microsoft.com/vs/mac/) | ||
1. [.NET](https://docs.microsoft.com/en-us/dotnet/core/install/macos) | ||
|
||
### How to run | ||
1. dotnet build | ||
- brew install nuget | ||
- brew install --cask dotnet | ||
- [Visual Studio](https://visualstudio.microsoft.com/vs/mac/) | ||
- [.NET](https://docs.microsoft.com/en-us/dotnet/core/install/macos) | ||
|
||
### Installation | ||
|
||
```bash | ||
dotnet add package Momento.Sdk | ||
``` | ||
|
||
### Usage | ||
|
||
Checkout our [examples](./examples/README.md) directory for complete examples of how to use the SDK. | ||
|
||
Here is a quickstart you can use in your own project: | ||
|
||
```csharp | ||
using System; | ||
using System.Threading.Tasks; | ||
using Momento.Sdk; | ||
using Momento.Sdk.Exceptions; | ||
using Momento.Sdk.Responses; | ||
|
||
namespace MomentoApplication | ||
{ | ||
class Program | ||
{ | ||
static readonly String MOMENTO_AUTH_TOKEN = Environment.GetEnvironmentVariable("MOMENTO_AUTH_TOKEN"); | ||
static readonly String CACHE_NAME = "cache"; | ||
static readonly String KEY = "MyKey"; | ||
static readonly String VALUE = "MyData"; | ||
static readonly uint DEFAULT_TTL_SECONDS = 60; | ||
|
||
async static Task Main(string[] args) | ||
{ | ||
using SimpleCacheClient client = new SimpleCacheClient(MOMENTO_AUTH_TOKEN, DEFAULT_TTL_SECONDS); | ||
try | ||
{ | ||
client.CreateCache(CACHE_NAME); | ||
} | ||
catch (AlreadyExistsException) | ||
{ | ||
Console.WriteLine($"Cache with name {CACHE_NAME} already exists.\n"); | ||
} | ||
Console.WriteLine("Listing caches:"); | ||
String token = null; | ||
do | ||
{ | ||
ListCachesResponse resp = client.ListCaches(token); | ||
foreach (CacheInfo cacheInfo in resp.Caches) | ||
{ | ||
Console.WriteLine(cacheInfo.Name); | ||
} | ||
token = resp.NextPageToken; | ||
} while (!String.IsNullOrEmpty(token)); | ||
Console.WriteLine($"\nSetting key: {KEY} with value: {VALUE}"); | ||
await client.SetAsync(CACHE_NAME, KEY, VALUE); | ||
Console.WriteLine($"\nGet value for key: {KEY}"); | ||
CacheGetResponse getResponse = await client.GetAsync(CACHE_NAME, KEY); | ||
Console.WriteLine($"\nLookedup value: {getResponse.String()}, Stored value: {VALUE}"); | ||
} | ||
} | ||
} | ||
|
||
### How to install | ||
1. dotnet add package Momento.Sdk | ||
``` | ||
|
||
### How to install (legacy version) | ||
1. dotnet add package MomentoSdk -s https://momento.jfrog.io/artifactory/api/nuget/nuget-public | ||
---------------------------------------------------------------------------------------- | ||
For more info, visit our website at [https://gomomento.com](https://gomomento.com)! |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{{ ossHeader }} | ||
|
||
## Getting Started :running: | ||
|
||
### Requirements | ||
|
||
- brew install nuget | ||
- brew install --cask dotnet | ||
- [Visual Studio](https://visualstudio.microsoft.com/vs/mac/) | ||
- [.NET](https://docs.microsoft.com/en-us/dotnet/core/install/macos) | ||
|
||
### Installation | ||
|
||
```bash | ||
dotnet add package Momento.Sdk | ||
``` | ||
|
||
### Usage | ||
|
||
Checkout our [examples](./examples/README.md) directory for complete examples of how to use the SDK. | ||
|
||
Here is a quickstart you can use in your own project: | ||
|
||
```csharp | ||
{{ usageExampleCode }} | ||
``` | ||
|
||
{{ ossFooter }} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<LangVersion>latestmajor</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<LangVersion>latestmajor</LangVersion> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Remove="Microsoft.Extensions.Logging" /> | ||
<None Remove="Microsoft.Extensions.Logging.Console" /> | ||
<None Remove="Momento.Sdk" /> | ||
<None Remove="HdrHistogram" /> | ||
</ItemGroup> | ||
<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.27.1" /> | ||
<PackageReference Include="HdrHistogram" Version="2.5.0" /> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.