Unable to call HSCAN with pattern from .Net using Stackexchange Redis

1.5k Views Asked by At

I'm trying to run the HSCAN command in Redis to match only the hash fields that are needed via C#

This is what the code looks like

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

But when I run the HSCAN command on the twemproxy server it seems to work as expected

HSCAN cache_Key 0 MATCH *pattern*

What am I missing?

Thanks

1

There are 1 best solutions below

4
thepirat000 On

I have the same problem when running Redis on windows, and I think it is because the StackExchange.Redis library fails to parse the Redis Version returned by the server when you are running a beta version, so it assumes a lower version of Redis that doesn't contains the HSCAN command.

In my case, the server is returning the following string as the Redis version:

3.0.300-beta1

And when SE.Redis tries to parse the version string (ResultProcessor.cs):

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

Will fail to parse the version numbers, because of the -beta1 part of the version string, being that the parameter should have the following format as stated on MSDN:

major.minor[.build[.revision]]

Try running a non beta version of redis.

I've just opened an issue about this on SE.Redis github.