mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-09 16:20:09 +09:00
Check cache transactions without leasing a database connection
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# The observer must still see the captured epoch after lookup and admission.
|
||||
class RecordCache
|
||||
def self.fetch(key, version)
|
||||
return yield unless version && ResponseCache.instance.budget.positive? && !ActiveRecord::Base.connection.transaction_open?
|
||||
return yield unless version && ResponseCache.instance.budget.positive? && !ActiveRecord::Base.connection_pool.active_connection?&.transaction_open?
|
||||
|
||||
key = ActiveSupport::Cache.expand_cache_key([ "record-snapshot-v1", version, key ])
|
||||
return yield if key.bytesize > ResponseCache::MAX_KEY_BYTES
|
||||
|
||||
Reference in New Issue
Block a user