Lisun.RedisInterface 1.0.1

dotnet add package Lisun.RedisInterface --version 1.0.1
                    
NuGet\Install-Package Lisun.RedisInterface -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lisun.RedisInterface" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lisun.RedisInterface" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Lisun.RedisInterface" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Lisun.RedisInterface --version 1.0.1
                    
#r "nuget: Lisun.RedisInterface, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Lisun.RedisInterface@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Lisun.RedisInterface&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Lisun.RedisInterface&version=1.0.1
                    
Install as a Cake Tool

Lisun.RedisInterface

A lightweight and developer-friendly .NET library that simplifies working with Redis through a strongly typed, object-oriented API.

Instead of working directly with Redis commands, keys, serialization, and low-level data structures, Lisun.RedisInterface allows you to work with Redis using familiar C# types and objects.

Features

  • Strongly typed Redis operations
  • Object-oriented API
  • Generic support for C# types
  • Simplified Redis data access
  • Reduced serialization boilerplate
  • Easy integration with .NET applications
  • Built on top of Microsoft's Redis caching infrastructure
  • Designed for clean and maintainable application code

Requirements

  • .NET 10.0 or later
  • Redis server
  • Microsoft.Extensions.Caching.StackExchangeRedis

Installation

Install the package using the .NET CLI:

dotnet add package Lisun.RedisInterface

Or using the NuGet Package Manager:

Install-Package Lisun.RedisInterface

Usage

  1. Set configurations in program.cs :
using Lisun.RedisInterface.Abstraction;

builder.Services.AddRedisInterface(option =>
{
    option.InstanceName = "TestRedis";
    option.Connection = builder.Configuration.GetConnectionString("Redis")!;
    option.RedisServiceLifeTime = ServiceLifetime.Scoped;
});
  1. Make your C# object 'Cacheable' : this setting can be applied to types in two ways

  • "ICacheable" :
using Lisun.RedisInterface.Abstraction;

public class Person : ICacheable
{
   public int Id { get; set; }
   public string Name { get; set; }
   public string PostalCode { get; set; }
}

then in program.cs :

RedisInterface.RegisterConfig<Refer>(CacheSetting.Generate());

  • "IConfigedCacheable" :
public class User : IConfigedCacheable
{
   public static CacheSetting CacheSetting 
      => new CacheSetting("User").ExpireAfter(TimeSpan.FromMinutes(2));

   public int Id { get; set; }
   public string Name { get; set; }
   public string PostalCode { get; set; }
}

  1. Inject 'IRedisService' to manage cached data :
public class BaseService(
    IRedisService<Person> personCacheService,
    IRedisService<User> userCacheService)
{
   public async Task Do(int personId)
   {
      var user = new User();
      await userCacheService.SetAsync(user.Id.ToString(),user);
      await personCacheService.GetAsync(personId.ToString());
   }
}

This approach keeps Redis-related code simple, readable, and strongly typed.

License

This project is licensed under the MIT License.

Contributing

Contributions, issues, and feature requests are welcome.

Feel free to open an issue or submit a pull request on the project's GitHub repository.

⭐ Support the Project

If you find Lisun.RedisInterface useful, consider giving the project a ⭐ on GitHub.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1 135 8/14/2026
1.0.0 116 8/14/2026

Initial release of Lisun.RedisInterface, providing a strongly typed and object-oriented abstraction for working with Redis in .NET.