-
Notifications
You must be signed in to change notification settings - Fork 0
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
ec4e8aa
commit f650beb
Showing
1 changed file
with
37 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# RemoveAsync Method | ||
|
||
The `RemoveAsync` method is part of the `IRedisRepository<T>` interface in the `NetPlus.ServiceAbstractions.Cache.Redis` library. This method removes an object from the Redis cache asynchronously based on the specified key. | ||
|
||
## Syntax | ||
|
||
```csharp | ||
public async Task<bool> RemoveAsync(string key) | ||
``` | ||
|
||
## Parameters | ||
|
||
- `key`: The unique identifier for the object in the Redis cache. This is a string. | ||
|
||
## Returns | ||
|
||
A task representing the asynchronous operation and containing a boolean indicating if the object was successfully removed. | ||
|
||
## Example | ||
|
||
```csharp | ||
var repository = serviceProvider.GetService<IRedisRepository<MyClass>>(); | ||
bool success = await repository.RemoveAsync("myKey"); | ||
``` | ||
|
||
In this example, the object with the key "myKey" will be removed from the Redis cache. The `success` variable will be `true` if the object was successfully removed, and `false` otherwise. | ||
|
||
## Remarks | ||
|
||
> [!NOTE] | ||
> The `RemoveAsync` method uses the `KeyDeleteAsync` method from the `IDatabase` interface provided by the StackExchange.Redis library to remove the value from Redis. | ||
> [!TIP] | ||
> If the key does not exist in the Redis cache, the `RemoveAsync` method will return `false`. | ||
> [!WARNING] | ||
> Be aware that the `RemoveAsync` method will throw an exception if the Redis server is not available or if there is a network issue. Make sure to handle these exceptions in your code. |