Redis Cache

ABP Framework Caching System extends the ASP.NET Core distributed cache. So, any provider supported by the standard ASP.NET Core distributed cache can be usable in your application and can be configured just like documented by Microsoft.

However, ABP provides an integration package for Redis Cache: Volo.Abp.Caching.StackExchangeRedis. There are two reasons for using this package, instead of the standard Microsoft.Extensions.Caching.StackExchangeRedis package.

  1. It implements SetManyAsync and GetManyAsync methods. These are not standard methods of the Microsoft Caching library, but added by the ABP Framework Caching system. They significantly increases the performance when you need to set/get multiple cache items with a single method call.
  2. It simplifies the Redis cache configuration (will be explained below).

Volo.Abp.Caching.StackExchangeRedis is already uses the Microsoft.Extensions.Caching.StackExchangeRedis package, but extends and improves it.

Installation

This package is already installed in the application startup template if it is using Redis.

Open a command line in the folder of your .csproj file and type the following ABP CLI command:

abp add-package Volo.Abp.Caching.StackExchangeRedis

Configuration

Volo.Abp.Caching.StackExchangeRedis package automatically gets the Redis configuration from the IConfiguration. So, for example, you can set your configuration inside the appsettings.json:

"Redis": { 
 "IsEnabled": "true",
 "Configuration": "127.0.0.1"
}

The setting IsEnabled is optional and will be considered true if it is not set.

Alternatively you can configure the standard RedisCacheOptions options class in the ConfigureServices method of your module:

Configure<RedisCacheOptions>(options =>
{
    //...
});

See Also

Contributors


Last updated: October 20, 2022 Edit this page on GitHub

Was this page helpful?

Please make a selection.

To help us improve, please share your reason for the negative feedback in the field below.

Please enter a note.

Thank you for your valuable feedback!

Please note that although we cannot respond to feedback, our team will use your comments to improve the experience.

In this document
Community Talks

What’s New with .NET 9 & ABP 9?

21 Nov, 17:00
Online
Watch the Event
Mastering ABP Framework Book
Mastering ABP Framework

This book will help you gain a complete understanding of the framework and modern web application development techniques.

Learn More