Sha256: 8c7484b4d9f8cf5f2a096ea21a4a759908077f46e71ff59237ec2d1c37f29450

Contents?: true

Size: 873 Bytes

Versions: 1

Compression:

Stored size: 873 Bytes

Contents

# dependencies
require "active_support"

# modules
require_relative "cacheflow/version"

module Cacheflow
  def self.activate
    require_relative "cacheflow/memcached" if defined?(Dalli)
    require_relative "cacheflow/redis" if defined?(Redis) || defined?(RedisClient)
  end

  def self.silenced?
    Thread.current[:cacheflow_silenced]
  end

  def self.silence
    previous_value = silenced?
    begin
      Thread.current[:cacheflow_silenced] = true
      yield
    ensure
      Thread.current[:cacheflow_silenced] = previous_value
    end
  end

  def self.silence_sidekiq!
    require_relative "cacheflow/sidekiq"
  end

  # private
  def self.args(args)
    args.map { |v| v.to_s.dup.force_encoding(Encoding::UTF_8).valid_encoding? ? v : "<binary-data>" }.join(" ")
  end
end

if defined?(Rails)
  require_relative "cacheflow/railtie"
else
  Cacheflow.activate
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cacheflow-0.3.3 lib/cacheflow.rb