Class: Redistat::Summary

Inherits:
Object
  • Object
show all
Includes:
Database
Defined in:
lib/redistat/summary.rb

Class Method Summary collapse

Methods included from Database

#db, included

Class Method Details

.bufferObject



13
14
15
# File 'lib/redistat/summary.rb', line 13

def buffer
  Redistat.buffer
end

.default_optionsObject



7
8
9
10
11
# File 'lib/redistat/summary.rb', line 7

def default_options
  { :enable_grouping => true,
    :label_indexing => true,
    :connection_ref => nil }
end

.update(key, stats, depth_limit, opts) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/redistat/summary.rb', line 32

def update(key, stats, depth_limit, opts)
  if opts[:enable_grouping]
    stats = inject_group_summaries(stats)
    key.groups.each do |k|
      update_key(k, stats, depth_limit, opts[:connection_ref])
      k.update_index if opts[:label_indexing]
    end
  else
    update_key(key, stats, depth_limit, opts[:connection_ref])
  end
end

.update_all(key, stats = {}, depth_limit = nil, opts = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/redistat/summary.rb', line 17

def update_all(key, stats = {}, depth_limit = nil, opts = {})
  stats ||= {}
  return if stats.empty?
  
  options = default_options.merge((opts || {}).reject { |k,v| v.nil? })
  
  depth_limit ||= key.depth
  
  update_through_buffer(key, stats, depth_limit, options)
end

.update_through_buffer(*args) ⇒ Object



28
29
30
# File 'lib/redistat/summary.rb', line 28

def update_through_buffer(*args)
  update(*args) unless buffer.store(*args)
end