Method: MysqlGetlock#self_locked?

Defined in:
lib/mysql_getlock.rb

#self_locked?Boolean

return true if locked by myself

Returns:

  • (Boolean)


63
64
65
66
67
68
69
70
# File 'lib/mysql_getlock.rb', line 63

def self_locked?
  results = mysql2.query(%Q[select is_used_lock('#{key}')], as: :array)
  lock_id = results.to_a.first.first
  return nil if lock_id.nil?
  results = mysql2.query(%Q[select connection_id()], as: :array)
  self_id = results.to_a.first.first
  self_id == lock_id
end