-
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
1 parent
222708c
commit 8f541f5
Showing
1 changed file
with
23 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
||
|
@@ -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 | ||
|