Sha256: 40c3e1d3fdf634c67415352fd2863ec80427e237a13a81765b7adcabd019c277
Contents?: true
Size: 809 Bytes
Versions: 2
Compression:
Stored size: 809 Bytes
Contents
# frozen_string_literal: true module ECB module Exchange class Cache KEY_PREFIX = "ecb_exchange_rates_for_date".freeze class << self attr_accessor :backend end def self.write(key, value) store.write(cache_key(key), value) end def self.read(key) store.read(cache_key(key)) end # use backend if set (must respond to read, write), otherwise Rails.cache # will be used (if available) or we fall back to use an in-memory cache def self.store if backend backend elsif defined?(Rails) && Rails.cache Rails.cache else MemoryCache.cache end end private def self.cache_key(key) "#{KEY_PREFIX}-#{key}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ecb_exchange-0.2.1 | lib/ecb/exchange/cache.rb |
ecb_exchange-0.2.0 | lib/ecb/exchange/cache.rb |