2

I am trying out Redis on Appharbor in an MVC4 application. I am using the ServiceStack C# client for Redis. Everything was working when using the RedisClient from ServiceStack.Redis. However, because I only plan to use Redis for caching, I attempted to wire up the ICacheClient that ServiceStack provides as a wrapper. Here is my StructureMap configuration (https://github.com/ServiceStack/ServiceStack/wiki/Caching):

x.For<IRedisClientsManager>().Use(() => new PooledRedisClientManager(redisUrl));
x.For<ICacheClient>().Use(c => c.GetInstance<IRedisClientsManager>().GetCacheClient());

My problem is that the PooledRedisClientManager is throwing error, "input string was not in a correct format" when I use the Redis-to-Go URL provided by Appharbor. Here is what that looks like:

redis://redistogo-appharbor:abunchofrandomcharacters@drum.redistogo.com:9081/

If I replace the Redis-to-Go URL with localhost:5051 everything works. What am I missing?

4

3 回答 3

1

前缀 aredis://不是任何已知的 redis 约定 - 它必须是 RedisToGo 或 AppHarbor 约定。

ServiceStack 的 C# RedisClient 支持标准的“password@host:port”约定,例如:

container.Register(c => new PooledRedisClientManager(
    "redistogo-appharbor:abunchofrandomcharacters@drum.redistogo.com:9081"
));
于 2012-08-30T22:11:57.310 回答
0

经过一些试验和错误,这可以工作。

string redisUrl = ConfigurationManager.AppSettings["REDISTOGO_URL"].Replace("redis://",    "").Replace("redistogo:","").Replace("/", "");
ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
SetConfig(new HostConfig{HandlerFactoryPath = "api"});
container.Register<IRedisClientsManager>(c => new PooledRedisClientManager(redisUrl));
container.Register<IDbRepository>(r => new DbRepository(r.Resolve<IRedisClientsManager>()));
于 2014-07-11T21:09:54.790 回答
0

像这样的东西对我有用:

container.Register(c => new PooledRedisClientManager(
    @"abunchofrandomcharacters@drum.redistogo.com:9081"
));
于 2013-08-28T04:42:47.097 回答