Skip to content

Commit

Permalink
Merge branch 'query-caching-for-publishing-blocks'
Browse files Browse the repository at this point in the history
  • Loading branch information
svevang committed Aug 10, 2023
2 parents 3167a3a + c59101c commit 09f62a7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/models/concerns/advisory_locks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ module AdvisoryLocks
def with_advisory_lock(lock_type)
raise "Cannot lock unpersisted instances" unless persisted? && id.present?
ActiveRecord::Base.connection.execute("SELECT pg_advisory_lock(#{lock_type}, #{id})")
yield
ActiveRecord::Base.uncached do
yield
end
ensure
ActiveRecord::Base.connection.execute("SELECT pg_advisory_unlock(#{lock_type}, #{id})")
end
Expand Down

0 comments on commit 09f62a7

Please sign in to comment.