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:
* 127.0.0.1:6379> 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]);