Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start using Redis with ASP.NET

Tags:

How do I start using Redis database with ASP.NET?

What I should install and what I should download?

I'm using Visual Studio 2008 with C#.

like image 449
Rawhi Avatar asked Feb 15 '11 16:02

Rawhi


People also ask

How use redis cache in asp net?

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). Create an Azure Cache for Redis. Copy the Primary connection string (StackExchange.

How do I start redis connection?

To start Redis client, open the terminal and type the command redis-cli. This will connect to your local server and now you can run any command. In the above example, we connect to Redis server running on the local machine and execute a command PING, that checks whether the server is running or not.

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.


1 Answers

FYI, both the:

  • RedisStackOverflow with C# Source Code and
  • RedisAdminUI with C# Source Code

are open source ASP.NET web applications that only use the ServiceStack.Redis C# client.

Here is an example of how you would use an Inversion of control (IoC) container to register a Redis client connection pool and its accompanying IRepository with an IoC:

//Register any dependencies you want injected into your services container.Register<IRedisClientsManager>(c => new PooledRedisClientManager()); container.Register<IRepository>(c => new Repository(c.Resolve<IRedisClientsManager>())); 

Note: if you're just starting out with the client, I recommend you go through the C# Client Wiki, Especially the Designing a Simple Blog application with Redis tutorial*.

like image 129
mythz Avatar answered Oct 21 '22 14:10

mythz