Adam Tegen
Adam Tegen

Reputation: 25905

ServiceStack.Redis configuring connections

I am using the ServiceStack.Redis client for Redis. Is it possible to configure the connection(s) via the configuration file?

I haven't been able to find any documentation in that regard.

Upvotes: 2

Views: 1275

Answers (1)

Adam Kopciński
Adam Kopciński

Reputation: 545

You can set the connection in appSettings of your web.config

 <appSettings>   
    <add key="redisUrl" value="127.0.0.1:6379"/>
  </appSettings>

then in appHost class

      public override void Configure(Funq.Container container){

      var redisCon = ConfigurationManager.AppSettings["redisUrl"].ToString();
      container.Register<IRedisClientsManager>(new PooledRedisClientManager(20, 60, redisCon));
      container.Register<ICacheClient>(c =>(ICacheClient)c.Resolve<IRedisClientsManager>().GetCacheClient());
    }

Upvotes: 4

Related Questions