RedisHelper 1.0.0
This package has been deprecated and included in EasyCache.Cache
dotnet add package RedisHelper --version 1.0.0
NuGet\Install-Package RedisHelper -Version 1.0.0
<PackageReference Include="RedisHelper" Version="1.0.0" />
paket add RedisHelper --version 1.0.0
#r "nuget: RedisHelper, 1.0.0"
// Install RedisHelper as a Cake Addin #addin nuget:?package=RedisHelper&version=1.0.0 // Install RedisHelper as a Cake Tool #tool nuget:?package=RedisHelper&version=1.0.0
RedisHelper - .Net Core
Introduction
Redis Helper is a simple way to handle caching items in Redis. It utilizes IDistributedCache
to help handle caching of items.
Documentation
Installation / Setup
You can install RedisHelper through Nuget package manager by running the following:
Install-Package RedisHelper -Version 1.0.0
If you use the dotnet CLI you can use the following:
dotnet add package RedisHelper
appsettings.json
In your appsettings.json you'll need to include the following entry to connect to your redis installation
"Redis": {
"Host": "127.0.0.1:6379",
"Instance": "RedisInstanceName"
}
Startup.cs
Add services.SetRedisHelperServices();
to your ConfigureServices
method:
public void ConfigureServices(IServiceCollection services)
{
// Other Code
services.SetRedisHelperServices();
// Other Code
}
Usage
Dependency Injection
You can utilize depency injection to bring the RedisHelper into your controller. An example when using RedisHelper in your HomeController can be seen here:
private readonly RedisHelper.Cache.RedisHelper _redisHelper;
public HomeController(RedisHelper.Cache.RedisHelper redisHelper)
{
_redisHelper = redisHelper;
}
Storing Items In The Cache
You may use the Put
method to store items in the cache. The Put
method requires you to set an expiration in seconds.
When using RedisHelper in the DI container you can use the following:
var seconds = 10;
_redisHelper.Put("key", "value", seconds);
To store an item that does not expire you can use the Forever
method. This will store an item in cache until it is removed manually
_redisHelper.Forever("key", "value");
Retrieving Items From The Cache
The Get
method is used to retrieve items from the cache. If the item does not exist in the cache, null
will be returned.
_redisHelper.Get("key");
Removing Items From The Cache
You may remove items from the cache using the forget
method:
_redisHelper.Forget("key")
Checking For Item Existence
The Exists
method can be used to determine if an item exists in the cache. If the value is null
this method will return false
_redisHelper.Exists("key");
License
RedisHelper is open-sourced software licensed under the MIT License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Microsoft.Extensions.Caching.Abstractions (>= 3.1.3)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 3.1.3)
- Microsoft.Extensions.Configuration (>= 3.1.3)
- Microsoft.Extensions.Configuration.Json (>= 3.1.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.0.0 | 1,249 | 4/1/2020 |