Skip to content

Commit

Permalink
Provide an initialise method for MySQL and PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
brendon committed Mar 10, 2024
1 parent f770ece commit da9b352
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/positioning/advisory_lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ def initialize(base_class, column)

@adapters = {
"Mysql2" => Adapter.new(
initialise: -> {},
aquire: -> { connection.execute "SELECT GET_LOCK(#{connection.quote(lock_name)}, -1)" },
release: -> { connection.execute "SELECT RELEASE_LOCK(#{connection.quote(lock_name)})" }
),
"PostgreSQL" => Adapter.new(
initialise: -> {},
aquire: -> { connection.execute "SELECT pg_advisory_lock(#{lock_name.hex & 0x7FFFFFFFFFFFFFFF})" },
release: -> { connection.execute "SELECT pg_advisory_unlock(#{lock_name.hex & 0x7FFFFFFFFFFFFFFF})" }
),
Expand Down

0 comments on commit da9b352

Please sign in to comment.