无法使用Stackexchange Redis使用.Net中的模式调用HSCAN

时间:2016-07-29 21:15:28

标签: c# redis twemproxy

我正在尝试在Redis中运行HSCAN命令以仅匹配通过C#

所需的哈希字段

这就是代码的样子

var options = new ConfigurationOptions
{
  EndPoints = { "endpoint" },
  Proxy = Proxy.Twemproxy
 };
 twemproxy_new = ConnectionMultiplexer.Connect(options);
 db = twemproxy_new.GetDatabase();
 Dictionary<string,string> inputDict = new Dictionary<string, string>();
 // populate inputDict with "n" fields & values
 var cachekey = "my_hash";
 db.GetDatabase().HashSet(cachekey, inputDict, CommandFlags.FireAndForget);

db.HashScan(cacheKey, "*9*"); 
// this is where it fails with the exception 
// Command is not available on your server: HSCAN

但是当我在twemproxy服务器上运行HSCAN命令时,它似乎按预期工作

HSCAN cache_Key 0 MATCH *pattern*

我错过了什么?

由于

1 个答案:

答案 0 :(得分:0)

运行Redis on windows时遇到同样的问题,我认为这是因为当您运行 beta 时,StackExchange.Redis库无法解析服务器返回的Redis版本版本,因此它假设Redis的较低版本不包含HSCAN命令。

在我的情况下,服务器返回以下字符串作为Redis版本:

<强> 3.0.300-β1

当SE.Redis尝试解析版本字符串(ResultProcessor.cs)时:

Version version;
if (Version.TryParse(val, out version))
{
    server.Version = version;
    server.Multiplexer.Trace("Auto-configured version: " + version);
}

由于版本字符串的 -beta1 部分,将无法解析版本号,因为参数应具有MSDN中所述的以下格式:

<强> MAJOR.MINOR [.build [.revision]]

尝试运行redis的非beta版本。

我刚刚在SE.Redis github上打开了issue

相关问题