Module: ActiveRecord::RuntimeRegistry

Extended by:
RuntimeRegistry
Included in:
RuntimeRegistry
Defined in:
lib/active_record/runtime_registry.rb

Overview

This is a thread locals registry for Active Record. For example:

ActiveRecord::RuntimeRegistry.sql_runtime

returns the connection handler local to the current unit of execution (either thread of fiber).

Instance Method Summary collapse

Instance Method Details

#async_sql_runtimeObject



20
21
22
# File 'lib/active_record/runtime_registry.rb', line 20

def async_sql_runtime
  ActiveSupport::IsolatedExecutionState[:active_record_async_sql_runtime] ||= 0.0
end

#async_sql_runtime=(runtime) ⇒ Object



24
25
26
# File 'lib/active_record/runtime_registry.rb', line 24

def async_sql_runtime=(runtime)
  ActiveSupport::IsolatedExecutionState[:active_record_async_sql_runtime] = runtime
end

#cached_queries_countObject



36
37
38
# File 'lib/active_record/runtime_registry.rb', line 36

def cached_queries_count
  ActiveSupport::IsolatedExecutionState[:active_record_cached_queries_count] ||= 0
end

#cached_queries_count=(count) ⇒ Object



40
41
42
# File 'lib/active_record/runtime_registry.rb', line 40

def cached_queries_count=(count)
  ActiveSupport::IsolatedExecutionState[:active_record_cached_queries_count] = count
end

#queries_countObject



28
29
30
# File 'lib/active_record/runtime_registry.rb', line 28

def queries_count
  ActiveSupport::IsolatedExecutionState[:active_record_queries_count] ||= 0
end

#queries_count=(count) ⇒ Object



32
33
34
# File 'lib/active_record/runtime_registry.rb', line 32

def queries_count=(count)
  ActiveSupport::IsolatedExecutionState[:active_record_queries_count] = count
end

#resetObject



44
45
46
47
48
# File 'lib/active_record/runtime_registry.rb', line 44

def reset
  reset_runtimes
  reset_queries_count
  reset_cached_queries_count
end

#reset_cached_queries_countObject



62
63
64
65
66
# File 'lib/active_record/runtime_registry.rb', line 62

def reset_cached_queries_count
  qc = cached_queries_count
  self.cached_queries_count = 0
  qc
end

#reset_queries_countObject



56
57
58
59
60
# File 'lib/active_record/runtime_registry.rb', line 56

def reset_queries_count
  qc = queries_count
  self.queries_count = 0
  qc
end

#reset_runtimesObject



50
51
52
53
54
# File 'lib/active_record/runtime_registry.rb', line 50

def reset_runtimes
  rt, self.sql_runtime = sql_runtime, 0.0
  self.async_sql_runtime = 0.0
  rt
end

#sql_runtimeObject



12
13
14
# File 'lib/active_record/runtime_registry.rb', line 12

def sql_runtime
  ActiveSupport::IsolatedExecutionState[:active_record_sql_runtime] ||= 0.0
end

#sql_runtime=(runtime) ⇒ Object



16
17
18
# File 'lib/active_record/runtime_registry.rb', line 16

def sql_runtime=(runtime)
  ActiveSupport::IsolatedExecutionState[:active_record_sql_runtime] = runtime
end