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



16
17
18
# File 'lib/redistat/summary.rb', line 16

def buffer
  Redistat.buffer
end

.default_optionsObject



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

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

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



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/redistat/summary.rb', line 35

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)
      k.update_index if opts[:label_indexing]
    end
  else
    update_key(key, stats, depth_limit, opts)
  end
end

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



20
21
22
23
24
25
26
27
28
29
# File 'lib/redistat/summary.rb', line 20

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



31
32
33
# File 'lib/redistat/summary.rb', line 31

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