Implementing the IDistributedCache interface

It is possible to extend the behavior of the IDistributedCache interface by overloading the extension methods. Furthermore, we need to store complex information and not bytes. For example, in the case of the ItemController class, we want to pass the ItemResponse type to the Set method of the IDistributedCache interface.

Let's proceed by modifying the DistributedCacheExtensions class in the Catalog.API project:

using System.Threading.Tasks;using Catalog.Domain.Configurations;using Microsoft.Extensions.Caching.Distributed;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;using Newtonsoft.Json;namespace Catalog.Infrastructure.Extensions{    public static class  ...

Get Hands-On RESTful Web Services with ASP.NET Core 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.