class Cachext::Multi
Attributes
config[R]
key_base[R]
Public Class Methods
new(config, key_base, options = {})
click to toggle source
# File lib/cachext/multi.rb, line 9 def initialize config, key_base, options = {} @config = config @key_base = key_base @options = options end
Public Instance Methods
expires_in()
click to toggle source
# File lib/cachext/multi.rb, line 29 def expires_in @options.fetch :expires_in, @config.default_expires_in end
fetch(ids, &block)
click to toggle source
# File lib/cachext/multi.rb, line 15 def fetch ids, &block records = FindByIds.new(self, ids, block).records if @options.fetch(:return_array, false) records.values + missing_records(ids - records.keys) else records end end
heartbeat_expires()
click to toggle source
# File lib/cachext/multi.rb, line 33 def heartbeat_expires @options.fetch :heartbeat_expires, config.heartbeat_expires end
key(id)
click to toggle source
# File lib/cachext/multi.rb, line 25 def key id @key_base + [id] end
Private Instance Methods
missing_records(ids)
click to toggle source
# File lib/cachext/multi.rb, line 39 def missing_records ids ids.map { |id| MissingRecord.new id } end