简体   繁体   中英

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.

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());
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM