Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (28 sloc) 0.917 kB
require 'rubygems'
require 'redis'
require 'redis-timeseries'
# To show the lib implementation here we use a timestep of just one second.
# Then we sample every 0.1 seconds, producing on average 10 samples per key.
# This way we should how multi-key range queries are working.
ts = RedisTimeSeries.new("test",1,Redis.new)
now = Time.now.to_f
puts "Adding data points: "
(0..30).each{|i|
print "#{i} "
STDOUT.flush
ts.add(i.to_s)
sleep 0.1
}
puts ""
# Get the second in the middle of our sampling.
begin_time = now+1
end_time = now+2
puts "\nGet range from #{begin_time} to #{end_time}"
ts.fetch_range(begin_time,end_time).each{|record|
puts "Record time #{record[:time]}, data #{record[:data]}"
}
# Show API to get a single timestep
puts "\nGet a single timestep near #{begin_time}"
ts.fetch_timestep(begin_time).each{|record|
puts "Record time #{record[:time]}, data #{record[:data]}"
}
Jump to Line
Something went wrong with that request. Please try again.