Skip to content

Instantly share code, notes, and snippets.

@luckyruby
Created April 9, 2012 18:12
Show Gist options
  • Save luckyruby/2345126 to your computer and use it in GitHub Desktop.
Save luckyruby/2345126 to your computer and use it in GitHub Desktop.
 def self.get(location, cartypes, pickup_date, return_date)
   inventory = {}
   date_range = (pickup_date .. return_date)
   values = $redis.pipelined do
               cartypes.each do |cartype|
                 date_range.each do |date|
                   $redis.hgetall(key(location, cartype, date))
                 end
               end
             end
   values = values.map { |value| Hash[*value.flatten] }
   idx = 0
   cartypes.each do |cartype|
     date_range.each do |date|
       inventory["#{cartype}:#{date.strftime('%F')}"] = values[idx]
       idx += 1
     end
   end
   inventory
 end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment