lib/economy/cache.rb in economy-4.0.1.0 vs lib/economy/cache.rb in economy-4.0.2.0
- old
+ new
@@ -1,23 +1,30 @@
module Economy
class Cache
- def get(from, to)
- redis.get "exchanges/#{from.iso_code.downcase}/#{to.iso_code.downcase}"
+ def fetch(from, to)
+ get "exchanges/#{from.iso_code.downcase}/#{to.iso_code.downcase}"
end
- def set(exchange)
- redis.set "exchanges/#{exchange.from.downcase}/#{exchange.to.downcase}", exchange.rate.to_s
+ def update(exchange)
+ set "exchanges/#{exchange.from.downcase}/#{exchange.to.downcase}", exchange.rate.to_s
end
def clear
- redis.del 'exchanges/*'
+ del 'exchanges/*'
end
+ def method_missing(name, *args, &block)
+ client.public_send name, *args, &block
+ end
+
private
- def redis
- Economy.configuration.redis
+ def client
+ @client ||= begin
+ require 'redis'
+ Redis.new YAML.load_file("#{Rails.root}/config/redis.yml")[Rails.env]
+ end
end
end
end