Sha256: ccb9c8563f10d69c767d10b9703b81bea5022990609a5c7a027f202b07272299
Contents?: true
Size: 1.82 KB
Versions: 20
Compression:
Stored size: 1.82 KB
Contents
require 'ddtrace/contrib/active_support/cache/patcher' module Datadog module Contrib module ActiveSupport module Cache # Support for Redis with ActiveSupport module Redis # Patching behavior for Redis with ActiveSupport module Patcher # For Rails < 5.2 w/ redis-activesupport... # When Redis is used, we can't only patch Cache::Store as it is # Cache::RedisStore, a sub-class of it that is used, in practice. # We need to do a per-method monkey patching as some of them might # be redefined, and some of them not. The latest version of redis-activesupport # redefines write but leaves untouched read and delete: # https://github.com/redis-store/redis-activesupport/blob/master/lib/active_support/cache/redis_store.rb # # For Rails >= 5.2 w/o redis-activesupport... # ActiveSupport includes a Redis cache store internally, and does not require these overrides. # https://github.com/rails/rails/blob/master/activesupport/lib/active_support/cache/redis_cache_store.rb def patch_redis?(meth) !Gem.loaded_specs['redis-activesupport'].nil? \ && defined?(::ActiveSupport::Cache::RedisStore) \ && ::ActiveSupport::Cache::RedisStore.instance_methods(false).include?(meth) end def cache_store_class(meth) if patch_redis?(meth) ::ActiveSupport::Cache::RedisStore else super end end end # Decorate Cache patcher with Redis support Cache::Patcher.instance_eval do class << self prepend Redis::Patcher end end end end end end end
Version data entries
20 entries across 20 versions & 2 rubygems