Redis Native ZRange returning string WITHSCORES values

It is extremely non-intuitive that the ZAdd asks for a double score but ZrangeByScoreWithScores returns the scores as bytes for a string

            var redisNative = (IRedisNativeClient)redisClient;

            double score = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
            double valueToStore = 123.456;
            var bytes = BitConverter.GetBytes(valueToStore);
            //bytes is 8 byes..
            redisNative.ZAdd("MYZKEY", score, bytes);

            var storedVals = redisNative.ZRangeByScoreWithScores("MYZKEY", score, score + 100, null, null);

            /* redis now has:
             *> zrange MYZKEY 0 -1 WITHSCORES
                1) "w\xbe\x9f\x1a/\xdd^@"
                2) "1546698549"  <---- this looks like a good timestamp

            //val1 is 8 bytes, == 123.456, looks good 
            var val1 = BitConverter.ToDouble(storedVals[0]);

            // storedVals[1] has **TEN** Bytes, 
            //the below does not get you back the timestamp
            var val2 = BitConverter.ToDouble(storedVals[1]);
           //this gives you a string representing the double you passed in
           var val3 = ASCIIEncoding.ASCII.GetString(storedVals[1]);

That’s because you’re using the IRedisNativeClient interface which returns the format as it’s returned from Redis.

Use the normal GetRangeWithScoresFromSortedSetByLowestScore() API which returns a dictionary with double values.

Its the same client. Double in and string bytes out. And GetRangeWithScoresFromSortedSetByLowestScore does not have any real documentation. Sorry - Not defensible.

Stop it, the purpose of each of the interfaces is clearly explained on the home page. Don’t use the native client if you don’t want low level access.