Class: Cachext::Multi
- Inherits:
-
Object
- Object
- Cachext::Multi
- Defined in:
- lib/cachext/multi.rb
Defined Under Namespace
Classes: FindByIds
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#key_base ⇒ Object
readonly
Returns the value of attribute key_base.
Instance Method Summary collapse
- #expires_in ⇒ Object
- #fetch(ids, &block) ⇒ Object
- #heartbeat_expires ⇒ Object
-
#initialize(config, key_base, options = {}) ⇒ Multi
constructor
A new instance of Multi.
- #key(id) ⇒ Object
Constructor Details
#initialize(config, key_base, options = {}) ⇒ Multi
Returns a new instance of Multi.
9 10 11 12 13 |
# File 'lib/cachext/multi.rb', line 9 def initialize config, key_base, = {} @config = config @key_base = key_base = end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/cachext/multi.rb', line 7 def config @config end |
#key_base ⇒ Object (readonly)
Returns the value of attribute key_base.
7 8 9 |
# File 'lib/cachext/multi.rb', line 7 def key_base @key_base end |
Instance Method Details
#expires_in ⇒ Object
29 30 31 |
# File 'lib/cachext/multi.rb', line 29 def expires_in .fetch :expires_in, @config.default_expires_in end |
#fetch(ids, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/cachext/multi.rb', line 15 def fetch ids, &block records = FindByIds.new(self, ids, block).records if .fetch(:return_array, false) records.values + missing_records(ids - records.keys) else records end end |
#heartbeat_expires ⇒ Object
33 34 35 |
# File 'lib/cachext/multi.rb', line 33 def heartbeat_expires .fetch :heartbeat_expires, config.heartbeat_expires end |
#key(id) ⇒ Object
25 26 27 |
# File 'lib/cachext/multi.rb', line 25 def key id @key_base + [id] end |