Using Redis Storage for the Reporting REST Service
This article explains how to use our Redis Storage for the Reporting REST Service storage.
Adding the necessary dependencies
The Telerik.Reporting.Cache.StackExchangeRedis assembly is required for Telerik Reporting to access a Redis database. This assembly uses the StackExchange.Redis client library.
(Recommended) Using the Telerik NuGet repository:
Add a NuGet package reference to the Telerik.Reporting.Cache.StackExchangeRedis package from the https://nuget.telerik.com/v3/index.json package source, which requires a Telerik NuGet key.
For instructions on how to set up and use the Telerik NuGet feed, please check How to add the Telerik private NuGet feed to Visual Studio.
Using the Telerik Reporting installation bin folder:
-
In your application project, add a reference to the StackExchange.Redis NuGet package with version 2.8.16 or greater. This will add an assembly reference to
StackExchange.Redis.dll.When using a greater version, a binding redirect should be added in the application configuration file to the currently referenced DLL version.
-
Add a reference to the
Telerik.Reporting.Cache.StackExchangeRedisassembly, which you can get from the following location:- .NET Framework projects -
{Telerik Reporting installation folder}/Bin. - .NET/.NET Standard projects -
{Telerik Reporting installation folder}/Bin/netstandard2.0.
- .NET Framework projects -
Using the RedisStorage
Provide an instance of the RedisStorage to the Storage property of the ReportServiceConfiguration.
The RedisStorage constructor accepts as a parameter a StackExchange.Redis.ConnectionMultiplexer object, which should be reused for the application lifetime:
-
.NET Framework 4.6.2+
In ASP.NET Framework projects, the ReportServiceConfiguration can be provided in the
ReportsControllerclass that implements ReportsControllerBase:C#public class RedisReportsController : ReportsControllerBase { static readonly ReportServiceConfiguration configurationInstance = new ReportServiceConfiguration { HostAppId = "Application1", ReportSourceResolver = new UriReportSourceResolver(HttpContext.Current.Server.MapPath("~/Reports")) .AddFallbackResolver(new TypeReportSourceResolver()), Storage = new Telerik.Reporting.Cache.StackExchangeRedis.RedisStorage(ConnectionMultiplexer.Connect("localhost")) }; public RedisReportsController() { this.ReportServiceConfiguration = configurationInstance; } } -
.NET 8+
C#builder.Services.TryAddSingleton<IReportServiceConfiguration>(sp => new ReportServiceConfiguration { HostAppId = "Application1", Storage = new Telerik.Reporting.Cache.StackExchangeRedis.RedisStorage(ConnectionMultiplexer.Connect("localhost")), ReportSourceResolver = new TypeReportSourceResolver() .AddFallbackResolver(new UriReportSourceResolver(reportsPath)) });