You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, the result of queries like TS.RANGE is an array of value objects. To make this more user-friendly for using the raw data (e.g. displaying on a chart), it would be nice to return a Redis::TimeSeries::Result wrapper to hold those value objects, and provide convenience wrappers for converting them into hashes and arrays.
[9]pry(main)> result=>[#<Redis::TimeSeries::Sample:0x00007f803088b7f8 @time=2020-06-29 23:43:12 -0700, @value=0.1e1>,#<Redis::TimeSeries::Sample:0x00007f803088b640 @time=2020-06-29 23:43:12 -0700, @value=0.2e1>,#<Redis::TimeSeries::Sample:0x00007f803088b488 @time=2020-06-29 23:43:12 -0700, @value=0.3e1>]# Could return 2d array/hash of times and values (Time object probably more useful elsewhere in a Ruby app)[10]pry(main)> result.map{ |r| [r.time,r.value]}=>[[2020-06-2923:43:12 -0700,0.1e1],[2020-06-2923:43:12 -0700,0.2e1],[2020-06-2923:43:12 -0700,0.3e1]][11]pry(main)> result.to_h{ |r| [r.time,r.value]}=>{2020-06-2923:43:12 -0700=>0.1e1,2020-06-2923:43:12 -0700=>0.2e1,2020-06-2923:43:12 -0700=>0.3e1}# Or, convert to raw milliseconds first (closer to raw reply from Redis)[12]pry(main)> result.map{ |r| [r.time.ts_msec,r.value]}=>[[1593499392263,0.1e1],[1593499392276,0.2e1],[1593499392298,0.3e1]][13]pry(main)> result.to_h{ |r| [r.time.ts_msec,r.value]}=>{1593499392263=>0.1e1,1593499392276=>0.2e1,1593499392298=>0.3e1}
The text was updated successfully, but these errors were encountered:
Right now, the result of queries like
TS.RANGE
is an array of value objects. To make this more user-friendly for using the raw data (e.g. displaying on a chart), it would be nice to return aRedis::TimeSeries::Result
wrapper to hold those value objects, and provide convenience wrappers for converting them into hashes and arrays.The text was updated successfully, but these errors were encountered: