2017-04-17 41 views
1

在操作Hashes with Servicestack池redisClientsManager時出現錯誤。發生意外錯誤ServiceStack Redis客戶端

這裏是如何我已經註冊了國際奧委會

private static IRedisClientsManager redisClientsManager; 
redisClientsManager = new PooledRedisClientManager("host:6379"); 
container.Register<IRedisClientsManager>(c => redisClientsManager); 
container.Register(c => c.Resolve<IRedisClientsManager>().GetClient()); 
container.Register<IRepository>(c => new Repository(c.Resolve<IRedisClientsManager>())); 

,這裏是怎麼了在倉庫使用它,

IRedisClientsManager manager; 
public repository(IRedisClientsManager mgr) 
{ 
this.manager=mgr; 
} 

//方法談Redis的

using(var red = manager.getClient()) 
{ 
    //do stuff with Other datatype except Hashes WORKS 
} 
//Error raised here 
using(var redHash = manager.getClient()) 
{ 
    //do stuff with Hashes DOESNT WORKS 
} 

錯誤: 意外錯誤:* 0 ....,Redis響應錯誤 任何Suggesti介紹如何使用PooledRedisClientManager線程安全。

添加堆棧跟蹤:

消息:意外的答覆:* 0,運動:6379,LastCommand:

at ServiceStack.Redis.RedisNativeClient.CreateResponseError(String error) at ServiceStack.Redis.RedisNativeClient.ParseSingleLine(String r) at ServiceStack.Redis.RedisNativeClient.SendExpectData(Byte[][] cmdWithBinaryArgs) at ServiceStack.Redis.RedisNativeClient.EvalShaStr(String sha1, Int32 numberKeysInArgs, Byte[][] keys) at ServiceStack.Redis.RedisClient.ExecLuaShaAsString(String sha1, String[] keys, String[] args) at Services.Data.Repository.GetMo(geoJ , DateTime , String) in \Data\Repository.cs:line 169 at Services.Api.getMService.Any(getM request) in \Api\getMService.cs:line 15 at lambda_method(Closure , Object , Object) at ServiceStack.ServiceHost.ServiceRunner`1.Execute(IRequestContext requestContext, Object instance, TRequest request)

+0

請提供一個不起作用的代碼示例,您可以在Gistlyn上創建一個[Live C#Redis示例](http://gistlyn.com/?gist=54e452bb1e86e132068a595d7e72d1a6)。 – mythz

+0

@mythz我試圖重新創建問題,但無法重現。我正在實施Repository Pattern,在那裏我註冊了Repository,構造函數實例化了Clients Manager,如上所示。 –

+0

沒錯,但我們需要能夠重現問題以識別它。除了CacheClient應該是一個singleton(所以刪除ReuseScope.None)並且'GetClient()'應該是PascalCase。你也不需要爲'新的PooledRedisClientManager(「主機:6379」)' – mythz

回答

3

當你打電話,你需要確保LUA腳本時得到一個Message:Unexpected reply錯誤腳本返回的內容與您要調用的RedisClient API相匹配,在這種情況下,RedisClient.ExecLuaShaAsString()需要string

如果您不確定輸入您的LUA腳本返回的類型,可以調用更可重用的ExecLuaSha,該函數返回可以支持多種不同LUA響應類型的複雜RedisText類型。

相關問題