Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/identity_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def should_fill_cache? # :nodoc:
end

def should_use_cache? # :nodoc:
puts " ===> in identity_cache.rb should_use_cache? "
ActiveRecord::Base.connection_handler.connection_pool_list(ActiveRecord::Base.current_role).none? do |pool|
pool.active_connection? &&
# Rails wraps each of your tests in a transaction, so that any changes
Expand Down
27 changes: 27 additions & 0 deletions lib/identity_cache/cache_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,33 @@ def clear
def fetch_multi(keys, &block)
results = cas_multi(keys, &block)
results = add_multi(keys, &block) if results.nil?

# binding.pry

def do_division_by_zero; 5 / 0; end
# begin
# do_division_by_zero
# rescue => exception
# puts "catch_fetcher - caught the division_by_zero exception in fetch_multi method"
# puts exception.backtrace
# # raise # always reraise
# end

keys.each do |k|
puts "CacheFetcher - Found Product key: #{k}" if k.include?(":blob:Product:")

if k.include?(":blob:Product:")
binding.pry
# begin
# do_division_by_zero
# rescue => exception
# puts "CacheFetcher - caught the Product key :blob:Product: with exceptions in fetch_multi method"
# puts exception.backtrace
# # raise # always reraise
# end
end

end
results
end

Expand Down
11 changes: 11 additions & 0 deletions lib/identity_cache/cache_key_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ class << self
def load(cache_fetcher, db_key, cache_fetcher_options = {})
cache_key = cache_fetcher.cache_key(db_key)

if k.include?(":blob:Product:")
binding.pry
# begin
# do_division_by_zero
# rescue => exception
# puts "CacheFetcher - caught the Product key :blob:Product: with exceptions in fetch_multi method"
# puts exception.backtrace
# # raise # always reraise
# end
end

db_value = nil

cache_value = IdentityCache.fetch(cache_key, cache_fetcher_options) do
Expand Down
11 changes: 11 additions & 0 deletions lib/identity_cache/fallback_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ def clear

def fetch_multi(keys)
results = @cache_backend.read_multi(*keys)

# binding.pry
def do_division_by_zero; 5 / 0; end
begin
do_division_by_zero
rescue => exception
puts "catch_fetcher - caught the division_by_zero exception in fetch_multi method"
puts exception.backtrace
# raise # always reraise
end

missed_keys = keys - results.keys
unless missed_keys.empty?
replacement_results = yield missed_keys
Expand Down
4 changes: 4 additions & 0 deletions lib/identity_cache/memoized_cache_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ def fetch_multi(*keys)
result = ActiveSupport::Notifications.instrument("cache_fetch_multi.identity_cache") do |payload|
payload[:resolve_miss_time] = 0.0

keys.each do |k|
puts "MemoizedCacheProxy - Found Product key: #{k}" if k.include?(":blob:Product:")
end

result = fetch_multi_memoized(keys) do |non_memoized_keys|
memo_miss_keys = non_memoized_keys
@cache_fetcher.fetch_multi(non_memoized_keys) do |missing_keys|
Expand Down