Skip to content

Commit

Permalink
Disable instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
djmb committed Aug 22, 2023
1 parent 9deda15 commit 17e26b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/models/solid_cache/entry.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module SolidCache
class Entry < Record
class << self
NULL_INSTRUMENTER = ActiveSupport::Notifications::Instrumenter.new(ActiveSupport::Notifications::Fanout.new)

def set(key, value)
upsert_all([{key: key, value: value}], unique_by: upsert_unique_by, update_only: [:value])
end
Expand All @@ -11,14 +13,18 @@ def set_all(payloads)

def get(key)
SolidCache::Entry.uncached do
Entry.find_by_sql([get_sql, ActiveModel::Type::Binary.new.serialize(key)]).pick(:value)
SolidCache::Record.connection.with_instrumenter(NULL_INSTRUMENTER) do
Entry.find_by_sql([get_sql, ActiveModel::Type::Binary.new.serialize(key)]).pick(:value)
end
end
end

def get_all(keys)
serialized_keys = keys.map { |key| ActiveModel::Type::Binary.new.serialize(key) }
SolidCache::Entry.uncached do
Entry.find_by_sql([get_all_sql, serialized_keys]).pluck(:key, :value).to_h
SolidCache::Record.connection.with_instrumenter(NULL_INSTRUMENTER) do
Entry.find_by_sql([get_all_sql, serialized_keys]).pluck(:key, :value).to_h
end
end
end

Expand Down
1 change: 1 addition & 0 deletions test/unit/cluster_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ClusterTest < ActiveSupport::TestCase

@primary_cache.delete("foo")
@cache.fetch("foo") { 2 }
sleep 0.1

assert_equal 2, @cache.read("foo")
assert_equal 2, @primary_cache.read("foo")
Expand Down

0 comments on commit 17e26b6

Please sign in to comment.