Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between Microsoft.Extensions.Cashing.Redis and Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache

I am a little bit lost. I am reading Microsoft documentation for ASP.NET Core caching using Redis. And the documentation suggests to use Microsoft.Extensions.Caching.StackExchangeRedis which is an open source third party library.

But I've seen some other tutorials are using Microsoft.Extensions.Caching.Redis, which is a more native asp.net core.

And at the end they both use the same interface IDistributedCache

Why I need StackExchangeRedis and what advantages it has over Microsoft.Extensions.Caching.Redis?

like image 318
Ghassan Karwchan Avatar asked Jan 21 '20 18:01

Ghassan Karwchan


People also ask

What is Redis cache in ASP.NET Core?

Redis is an open source in-memory data store, which is often used as a distributed cache. You can configure an Azure Redis Cache for an Azure-hosted ASP.NET Core app, and use an Azure Redis Cache for local development. An app configures the cache implementation using a RedisCache instance (AddStackExchangeRedisCache).

What is Redis cache C#?

What is Redis Cache. Redis is an open source (BSD licensed), in-memory data structure store used as a database, cache, message broker, and streaming engine. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams.

How Redis cache is implemented in ASP NET MVC?

You can download the complete Source Code here. Download free Redis Client to view the data from Redis. Let's start with creating a project in Visual Studio 2015. After creating a project, we are going to add a NuGet package to access Redis from an ASP.NET application.

What is azure Redis?

It's a type of cloud cache service that provides Azure users with high throughput, low latency, and secure cache- fully managed by Microsoft. Azure Redis Cache is a distributed, in-memory cache service specifically designed for cloud applications.


1 Answers

A look at the dependency graph for Microsoft.Extensions.Caching.Redis and Microsoft.Extensions.Caching.StackExchangeRedis reveals it.

Microsoft.Extensions.Caching.Redis is based on StackExchange redis 1.x library, whereas Microsoft.Extensions.Caching.StackExchangeRedis is based on 2.x of the same library.

Also Microsoft.Extensions.Caching.Redis doesn't seem to target the 3.1 extension libraries (Microsoft.Extensions.Options/Caching.Abstractions) where the other does.

So for .NET Core 3.x and newer use Microsoft.Extensions.Caching.StackExchangeRedis as the previous one may not be maintained as long as the new one.

like image 170
Tseng Avatar answered Sep 17 '22 09:09

Tseng