Skip to content

Commit

Permalink
Update templated README.md file
Browse files Browse the repository at this point in the history
  • Loading branch information
pgautier404 authored and Momento GitHub Actions Bot committed Oct 10, 2022
1 parent 222708c commit 8f541f5
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ any of the operational overhead required by traditional caching solutions!

### Requirements

- You will most likely want an IDE that supports .NET development, such as [Microsoft Visual Studio](https://visualstudio.microsoft.com/vs),
[JetBrains Rider](https://www.jetbrains.com/rider/), or [Microsoft Visual Studio Code](https://code.visualstudio.com/).
- You will need the [`dotnet` runtime and command line tools](https://dotnet.microsoft.com/en-us/download). After installing them,
you should have the `dotnet` command on your PATH.
You will need the [`dotnet` runtime and command line tools](https://dotnet.microsoft.com/en-us/download). After installing them, you should have the `dotnet` command on your PATH.

### Installation
**IDE Notes**: You will most likely want an IDE that supports .NET development, such as [Microsoft Visual Studio](https://visualstudio.microsoft.com/vs), [JetBrains Rider](https://www.jetbrains.com/rider/), or [Microsoft Visual Studio Code](https://code.visualstudio.com/).

If you'd like to see a complete working example, check out our [examples](./examples/README.md) page.
### Installation

To create a new .NET project and add the Momento client library as a dependency:

Expand Down Expand Up @@ -90,6 +87,26 @@ using (SimpleCacheClient client = new SimpleCacheClient(Configurations.Laptop.La
Note that the above code requires an environment variable named MOMENTO_AUTH_TOKEN which must
be set to a valid [Momento authentication token](https://docs.momentohq.com/docs/getting-started#obtain-an-auth-token).

**Momento Response Types**: The Momento `SimpleCacheClient` uses response types in a way you may not be familiar with and deserves
a word of explanation upfront. Each response object's actual type will be a subtype (e.g., `CacheGetResponse.Hit`) of the requested response type (e.g., `CacheGetResponse`) and must be resolved to the correct subtype before accessing its properties. We recommend using [pattern matching](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/functional/pattern-matching) to resolve the response's subtype and allow us to access the appropriate properties for that type:

```csharp
CreateCacheResponse createResponse = client.CreateCacheAsync("example-cache");
if (createResponse is CreateCacheResponse.CacheAlreadyExists)
{
// this may or may not be expected; handle as appropriate.
}
else if (createResponse is CreateCacheResponse.Error createError)
{
if (createError.ErrorCode == MomentoErrorCode.LIMIT_EXCEEDED_ERROR)
{
// we've used our quota of caches; we should contact [email protected]!
}
}
```

See the "Error Handling" section below for more details.

### Error Handling

Error that occur in calls to SimpleCacheClient methods are surfaced to developers as part of the return values of
Expand Down

0 comments on commit 8f541f5

Please sign in to comment.