Created
February 10, 2012 22:25
-
-
Save luckyruby/1793567 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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