Caching.StackExchangeRedis.BetterRedis
1.0.1
dotnet add package Caching.StackExchangeRedis.BetterRedis --version 1.0.1
NuGet\Install-Package Caching.StackExchangeRedis.BetterRedis -Version 1.0.1
<PackageReference Include="Caching.StackExchangeRedis.BetterRedis" Version="1.0.1" />
paket add Caching.StackExchangeRedis.BetterRedis --version 1.0.1
#r "nuget: Caching.StackExchangeRedis.BetterRedis, 1.0.1"
// Install Caching.StackExchangeRedis.BetterRedis as a Cake Addin #addin nuget:?package=Caching.StackExchangeRedis.BetterRedis&version=1.0.1 // Install Caching.StackExchangeRedis.BetterRedis as a Cake Tool #tool nuget:?package=Caching.StackExchangeRedis.BetterRedis&version=1.0.1
BetterRedis .NET Library
Overview
BetterRedis is a .NET library designed to simplify the use of Redis caching and extend its capabilities. This library abstracts the complexities of working directly with Redis and offers a more streamlined interface for developers.
Features
- Simplified API: Easy-to-use methods for common caching operations.
- Data Serialization: Built-in support for efficient serialization and deserialization of objects.
- Extensible: Easily extend and customize the library to fit your specific needs.
Installation
You can install the BetterRedis library via NuGet package manager:
dotnet add package BetterRedis
Alternatively, you can use the NuGet Package Manager in Visual Studio to search for and install BetterRedis
.
Getting Started
Prerequisites
- .NET 8.0 or later
- Redis server (local or remote)
Basic Usage
Configuration: Configure BetterRedis in your application startup:
services.AddBetterRedis(options => { options.ConnectionString = "your-redis-connection-string"; // Additional configuration options });
Caching Data: Use the BetterRedis cache manager to store and retrieve data:
var cacheManager = serviceProvider.GetRequiredService<IRedisRepository>(); // Set a value in cache await cacheManager.SetAsync("key", "value"); // Get a value from cache var value = await cacheManager.GetAsync<string>("key");
GetAsync Enhancement: Use the GetAsync method even if the data is not cached (it will query the database):
await cacheManager.GetAsync("key", async () => "query-data-from-database");
Cache Invalidation: Invalidate cache entries when necessary:
await cacheManager.RemoveAsync("key");
Or Invalidate all entries:
await cacheManager.ClearAsync();
Cache Extension: Extend the duration of cache entry:
await cacheManager.RefreshAsync("key");
Contributing
We welcome contributions to enhance BetterRedis. To contribute:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request with detailed information about your changes.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contact
For any questions or support, please create an issue on GitHub or contact the maintainers.
BetterRedis makes Redis caching simple and efficient, enabling developers to build high-performance applications effortlessly. Try it out today and see the difference it can make in your .NET projects!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 8.0.7)
- Microsoft.Extensions.Hosting (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.