1

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

Ashish Joshi
  • 46
  • 1
  • 5

1 Answers1

0

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.

thepirat000
  • 12,362
  • 4
  • 46
  • 72
  • Thanks That might be the issue How did you decipher what the twemproxy server was returning? I do see the version being "2.0" when I look at the multiplexer server version (which is what it's defaulting to I assume) But I'm not sure where i'd see it as 3.0300-beta (or an equivalent) – Ashish Joshi Aug 01 '16 at 21:28
  • Connect to your Redis server using **redis-cli** and run the command **INFO SERVER**, there you should see the version string – thepirat000 Aug 02 '16 at 00:02
  • The redis version on the server is 3.2.0. But for some reason SE seems to default it to 2.0 in .Net For now got around it by doing this var options = new ConfigurationOptions { EndPoints = { "redis-endpoint" }, Proxy = Proxy.None }; – Ashish Joshi Aug 04 '16 at 05:02
  • Have you tried adding a default version to the config options return new ConfigurationOptions { Proxy = Proxy.Twemproxy, AbortOnConnectFail = false, EndPoints = { TWEMPROXY_ADDESS }, ,DefaultVersion = new Version(3,0,3) }; Didn't work for me though, still got the same error – Ashish Joshi Aug 05 '16 at 14:44