class Momm::Memcached
Constants
- DEFAULT_OPTIONS
Attributes
connection[R]
options[R]
Public Class Methods
new(options={})
click to toggle source
# File lib/momm/memcached.rb, line 10 def initialize(options={}) _options = DEFAULT_OPTIONS.dup.merge options @connection = _options.delete(:connection) @options = _options end
Public Instance Methods
client()
click to toggle source
# File lib/momm/memcached.rb, line 16 def client @client ||= Dalli::Client.new connection, options end
get_rate(currency, date = Date.today)
click to toggle source
# File lib/momm/memcached.rb, line 25 def get_rate(currency, date = Date.today) date = Date.parse(date) if date.is_a? String client.get("#{date}#{currency}").to_f end
set_rate(currency, rate, date = Date.today)
click to toggle source
# File lib/momm/memcached.rb, line 20 def set_rate(currency, rate, date = Date.today) date = Date.parse(date) if date.is_a? String client.set "#{date}#{currency}", rate end