-
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
7 changed files
with
301 additions
and
7 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
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,78 @@ | ||
namespace Momento.Sdk.Responses; | ||
|
||
using Momento.Sdk.Exceptions; | ||
|
||
|
||
/// <summary> | ||
/// Parent response type for a cache update ttl request. The | ||
/// response object is resolved to a type-safe object of one of | ||
/// the following subtypes: | ||
/// <list type="bullet"> | ||
/// <item><description>CacheUpdateTtlResponse.Set</description></item> | ||
/// <item><description>CacheUpdateTtlResponse.Miss</description></item> | ||
/// <item><description>CacheUpdateTtlResponse.Error</description></item> | ||
/// </list> | ||
/// Pattern matching can be used to operate on the appropriate subtype. | ||
/// For example: | ||
/// <code> | ||
/// if (response is CacheUpdateTtlResponse.Set setResponse) | ||
/// { | ||
/// // handle ttl updated as appropriate | ||
/// } | ||
/// else if (response is CacheUpdateTtlResponse.Miss missResponse) | ||
/// { | ||
/// // handle ttl not updated because key was not found as appropriate | ||
/// } | ||
/// else if (response is CacheUpdateTtlResponse.Error errorResponse) | ||
/// { | ||
/// // handle error as appropriate | ||
/// return errorResponse.Message; | ||
/// } | ||
/// else | ||
/// { | ||
/// // handle unexpected response | ||
/// } | ||
/// </code> | ||
/// </summary> | ||
public abstract class CacheUpdateTtlResponse | ||
{ | ||
/// <summary> | ||
/// Indicates the key was found in the cache and the ttl was updated. | ||
/// </summary> | ||
public class Set : CacheUpdateTtlResponse { } | ||
|
||
/// <summary> | ||
/// Indicates the key was not found in the cache, hence the ttl was not updated. | ||
/// </summary> | ||
public class Miss : CacheUpdateTtlResponse { } | ||
|
||
/// <include file = "../docs.xml" path='docs/class[@name="Error"]/description/*' /> | ||
public class Error : CacheUpdateTtlResponse, IError | ||
{ | ||
private readonly SdkException _error; | ||
|
||
/// <include file = "../docs.xml" path='docs/class[@name="Error"]/constructor/*' /> | ||
public Error(SdkException error) | ||
{ | ||
_error = error; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public SdkException InnerException | ||
{ | ||
get => _error; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public MomentoErrorCode ErrorCode | ||
{ | ||
get => _error.ErrorCode; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public string Message | ||
{ | ||
get => _error.Message; | ||
} | ||
} | ||
} |
Oops, something went wrong.