Module: Cacheflow

Defined in:
lib/cacheflow.rb,
lib/cacheflow/redis.rb,
lib/cacheflow/sidekiq.rb,
lib/cacheflow/version.rb,
lib/cacheflow/memcached.rb

Defined Under Namespace

Modules: Memcached, Redis, Sidekiq

Constant Summary collapse

VERSION =
"0.3.3"

Class Method Summary collapse

Class Method Details

.activateObject



8
9
10
11
# File 'lib/cacheflow.rb', line 8

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

.args(args) ⇒ Object

private



32
33
34
# File 'lib/cacheflow.rb', line 32

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

.silenceObject



17
18
19
20
21
22
23
24
25
# File 'lib/cacheflow.rb', line 17

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

.silence_sidekiq!Object



27
28
29
# File 'lib/cacheflow.rb', line 27

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

.silenced?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/cacheflow.rb', line 13

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