class WithAdvisoryLock::MySQL
MySQL
> 5.7.5 supports nested locks
Public Instance Methods
execute_successful?(mysql_function)
click to toggle source
# File lib/with_advisory_lock/mysql.rb, line 17 def execute_successful?(mysql_function) sql = "SELECT #{mysql_function} AS #{unique_column_name}" connection.select_value(sql).to_i > 0 end
quoted_lock_str()
click to toggle source
MySQL
wants a string as the lock key.
# File lib/with_advisory_lock/mysql.rb, line 23 def quoted_lock_str connection.quote(lock_str) end
release_lock()
click to toggle source
# File lib/with_advisory_lock/mysql.rb, line 13 def release_lock execute_successful?("RELEASE_LOCK(#{quoted_lock_str})") end
try_lock()
click to toggle source
See dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_get-lock
# File lib/with_advisory_lock/mysql.rb, line 5 def try_lock raise ArgumentError, 'shared locks are not supported on MySQL' if shared if transaction raise ArgumentError, 'transaction level locks are not supported on MySQL' end execute_successful?("GET_LOCK(#{quoted_lock_str}, 0)") end