Class: ActiveRecord::ConnectionAdapters::MysqlAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- ActiveRecord::ConnectionAdapters::MysqlAdapter
- Defined in:
- lib/vex/active_record/advisory_lock/mysql_adapter.rb,
lib/vex/active_record/lite_view.rb
Constant Summary collapse
- TIMEOUT =
5
Instance Method Summary collapse
Instance Method Details
#locked(lock, opts = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/vex/active_record/advisory_lock/mysql_adapter.rb', line 5 def locked(lock, opts = {}) lock = "#{current_database}.rails.#{lock}" begin execute "SELECT GET_LOCK(#{quote(lock)},#{opts[:timeout] || TIMEOUT})" yield ensure execute "SELECT RELEASE_LOCK(#{quote(lock)})" end end |