Sha256: 2e64bfb3b5e8a1aeb766b43e7d9d7cfec38caa24e6833e3bf416c96784bf8319

Contents?: true

Size: 380 Bytes

Versions: 12

Compression:

Stored size: 380 Bytes

Contents

module ActiveRecord::ConnectionAdapters
  class MysqlAdapter < AbstractAdapter
    TIMEOUT=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
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
vex-0.6.2 lib/vex/active_record/advisory_lock/mysql_adapter.rb
vex-0.4.4 lib/vex/active_record/advisory_lock/mysql_adapter.rb
vex-0.4.2 lib/vex/active_record/advisory_lock/mysql_adapter.rb
vex-0.3.3 lib/vex/active_record/advisory_lock/mysql_adapter.rb
vex-0.2.9 lib/vex/active_record/advisory_lock/mysql_adapter.rb
vex-0.2.8 lib/vex/active_record/advisory_lock/mysql_adapter.rb
vex-0.2.7 lib/vex/active_record/advisory_lock/mysql_adapter.rb
vex-0.2.6 lib/vex/active_record/advisory_lock/mysql_adapter.rb
vex-0.2.5 lib/vex/active_record/advisory_lock/mysql_adapter.rb
vex-0.2.2 lib/vex/active_record/advisory_lock/mysql_adapter.rb
vex-0.2.1 lib/vex/active_record/advisory_lock/mysql_adapter.rb
vex-0.2 lib/vex/active_record/advisory_lock/mysql_adapter.rb