Skip to content

Instantly share code, notes, and snippets.

@luckyruby
Created February 10, 2012 22:25
Show Gist options
  • Save luckyruby/1793567 to your computer and use it in GitHub Desktop.
Save luckyruby/1793567 to your computer and use it in GitHub Desktop.
def self.retrieve_rate_from_redis(location_code, ratecode, cartype, pickup_date, pickup_time)
base_key = "rate:#{location_code}:#{ratecode}:#{cartype}"
default_rate_key = base_key + ":default"
rate_key = base_key + ":" + pickup_date.to_s
value = $redis.hgetall (rate_key + ":#{pickup_time[0,2]}") #use TOD rate if tod rate exists
value = $redis.hgetall rate_key if value.blank? #use regular rate if TOD rate not found
value = $redis.hgetall default_rate_key if value.blank? #use default rate if regular rate not found
value
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment