From f650bebb5dc5d82c09ed9d77975212184f4ccda7 Mon Sep 17 00:00:00 2001 From: Guilherme Martin Date: Sat, 24 Feb 2024 22:40:30 -0300 Subject: [PATCH] Create removeasync.md --- .../cache/redis/removeasync.md | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 docs/docs/serviceabstractions/cache/redis/removeasync.md diff --git a/docs/docs/serviceabstractions/cache/redis/removeasync.md b/docs/docs/serviceabstractions/cache/redis/removeasync.md new file mode 100644 index 0000000..81f3c52 --- /dev/null +++ b/docs/docs/serviceabstractions/cache/redis/removeasync.md @@ -0,0 +1,37 @@ +# RemoveAsync Method + +The `RemoveAsync` method is part of the `IRedisRepository` 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 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>(); +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.