Class: Nunes::Subscribers::ActiveSupport

Inherits:
Nunes::Subscriber show all
Defined in:
lib/nunes/subscribers/active_support.rb

Constant Summary collapse

Pattern =

Private

/\.active_support\Z/

Constants inherited from Nunes::Subscriber

Nunes::Subscriber::BANG

Instance Attribute Summary

Attributes inherited from Nunes::Subscriber

#adapter

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Nunes::Subscriber

#call, #increment, #initialize, subscribe, #timing

Constructor Details

This class inherits a constructor from Nunes::Subscriber

Class Method Details

.patternObject

Private: The namespace for events to subscribe to.



10
11
12
# File 'lib/nunes/subscribers/active_support.rb', line 10

def self.pattern
  Pattern
end

Instance Method Details

#cache_delete(start, ending, transaction_id, payload) ⇒ Object



47
48
49
50
# File 'lib/nunes/subscribers/active_support.rb', line 47

def cache_delete(start, ending, transaction_id, payload)
  runtime = ((ending - start) * 1_000).round
  timing "active_support.cache.delete", runtime
end

#cache_exist?(start, ending, transaction_id, payload) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
55
# File 'lib/nunes/subscribers/active_support.rb', line 52

def cache_exist?(start, ending, transaction_id, payload)
  runtime = ((ending - start) * 1_000).round
  timing "active_support.cache.exist", runtime
end

#cache_fetch_hit(start, ending, transaction_id, payload) ⇒ Object



37
38
39
40
# File 'lib/nunes/subscribers/active_support.rb', line 37

def cache_fetch_hit(start, ending, transaction_id, payload)
  runtime = ((ending - start) * 1_000).round
  timing "active_support.cache.fetch_hit", runtime
end

#cache_generate(start, ending, transaction_id, payload) ⇒ Object



32
33
34
35
# File 'lib/nunes/subscribers/active_support.rb', line 32

def cache_generate(start, ending, transaction_id, payload)
  runtime = ((ending - start) * 1_000).round
  timing "active_support.cache.fetch_generate", runtime
end

#cache_read(start, ending, transaction_id, payload) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/nunes/subscribers/active_support.rb', line 14

def cache_read(start, ending, transaction_id, payload)
  super_operation = payload[:super_operation]
  runtime = ((ending - start) * 1_000).round

  case super_operation
  when Symbol
    timing "active_support.cache.#{super_operation}", runtime
  else
    timing "active_support.cache.read", runtime
  end

  hit = payload[:hit]
  unless hit.nil?
    hit_type = hit ? :hit : :miss
    increment "active_support.cache.#{hit_type}"
  end
end

#cache_write(start, ending, transaction_id, payload) ⇒ Object



42
43
44
45
# File 'lib/nunes/subscribers/active_support.rb', line 42

def cache_write(start, ending, transaction_id, payload)
  runtime = ((ending - start) * 1_000).round
  timing "active_support.cache.write", runtime
end