我正在 MVC4 应用程序中的 Appharbor 上试用 Redis。我正在使用 ServiceStack C# client for Redis .使用 ServiceStack.Redis
中的 RedisClient
时一切正常。但是,因为我只打算使用 Redis 进行缓存,所以我尝试连接 ServiceStack 作为包装器提供的 ICacheClient
。这是我的 StructureMap 配置 ( https://github.com/ServiceStack/ServiceStack/wiki/Caching ):
x.For<IRedisClientsManager>().Use(() => new PooledRedisClientManager(redisUrl));
x.For<ICacheClient>().Use(c => c.GetInstance<IRedisClientsManager>().GetCacheClient());
我的问题是当我使用 Appharbor 提供的 Redis-to-Go URL 时,PooledRedisClientManager
抛出错误,“input string was not in a correct format
” .这是它的样子:
redis://redistogo-appharbor:abunchofrandomcharacters@drum.redistogo.com:9081/
如果我用 localhost:5051
替换 Redis-to-Go URL,一切正常。
我错过了什么?
最佳答案
前缀 redis://
不是任何已知的 redis 约定 - 它必须是 RedisToGo 或 AppHarbor 约定。
ServiceStack 的 C# RedisClient 支持标准的“password@host:port”约定,例如:
container.Register(c => new PooledRedisClientManager(
"redistogo-appharbor:abunchofrandomcharacters@drum.redistogo.com:9081"
));
关于redis - PooledRedisClientManager 抛出 Appharbor Redis URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12205858/