Module: ActiveRecord::DatabaseMutex::ClassMethods
- Defined in:
- lib/active_record/database_mutex.rb
Instance Method Summary collapse
-
#all_mutexes ⇒ Array
The all_mutexes method returns an array of MutexInfo objects representing all mutexes currently held by database connections.
-
#mutex ⇒ ActiveRecord::DatabaseMutex::Implementation
The mutex method returns an instance of ActiveRecord::DatabaseMutex::Implementation that is initialized with the name given by the class and environment variables.
- #mutex_name ⇒ Object
Instance Method Details
#all_mutexes ⇒ Array
The all_mutexes method returns an array of MutexInfo objects representing all mutexes currently held by database connections. The MutexInfo#OBJECT_NAME is the Implementation#internal_name.
75 76 77 78 79 80 81 |
# File 'lib/active_record/database_mutex.rb', line 75 def all_mutexes connection.select_all(<<~EOT).map { MutexInfo.new(_1) } SELECT * FROM performance_schema.metadata_locks WHERE OBJECT_TYPE = 'USER LEVEL LOCK' AND OBJECT_NAME LIKE "$%" EOT end |
#mutex ⇒ ActiveRecord::DatabaseMutex::Implementation
The mutex method returns an instance of ActiveRecord::DatabaseMutex::Implementation that is initialized with the name given by the class and environment variables.
65 66 67 |
# File 'lib/active_record/database_mutex.rb', line 65 def mutex @mutex ||= Implementation.new(name: mutex_name) end |
#mutex_name ⇒ Object
56 57 58 |
# File 'lib/active_record/database_mutex.rb', line 56 def mutex_name @mutex_name ||= [ name, defined?(Rails) ? Rails.env : ENV['RAILS_ENV'] ].compact * ?@ end |