Reputation: 17280
I am trying to implement Redis caching for the first time
I have downloaded the ServiceStack.Redis libraries in my C# application
I am following the instriuctions here: https://github.com/ServiceStack/ServiceStack.Redis
I am assuming the first step is to create a pool so I tried this
container.Register<IRedisClientsManager>(c =>
new RedisManagerPool(redisConnectionString));
How do I setup my container as in container.Register
I read this article around the IoC container but just can wrap my head around this.
Why do I need to create a container and how do I implement it so that I can create my pool?
Upvotes: 0
Views: 962
Reputation: 143369
If you don't have (or want to use) an IOC Container you can just hold a singleton reference to the Redis Pool, e.g:
class MyApp
{
public static IRedisClientsManager RedisManager = new RedisManagerPool(connString);
}
Which you can then reference in your code to access a RedisClient, e.g:
using (var redis = MyApp.RedisManager.GetClient())
{
//...
}
Upvotes: 1