Sha256: d0d07e79a08df92e9ed7f2ba5842e16ad1e94b1bd288b17da3e47161f46363a7

Contents?: true

Size: 915 Bytes

Versions: 5

Compression:

Stored size: 915 Bytes

Contents

# frozen_string_literal: true

require "active_support/all"
require "second_level_cache/config"
require "second_level_cache/record_marshal"
require "second_level_cache/record_relation"
require "second_level_cache/active_record"
require "second_level_cache/log_subscriber"

module SecondLevelCache
  def self.configure
    block_given? ? yield(Config) : Config
  end

  def self.without_second_level_cache
    old_cache_enabled = SecondLevelCache.cache_enabled?
    SecondLevelCache.cache_enabled = false

    yield
  ensure
    SecondLevelCache.cache_enabled = old_cache_enabled
  end

  def self.cache_enabled?
    cache_enabled = Thread.current[:slc_cache_enabled]
    cache_enabled.nil? ? true : cache_enabled
  end

  def self.cache_enabled=(cache_enabled)
    Thread.current[:slc_cache_enabled] = cache_enabled
  end

  class << self
    delegate :logger, :cache_store, :cache_key_prefix, to: Config
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
second_level_cache-2.7.0 lib/second_level_cache.rb
second_level_cache-2.6.4 lib/second_level_cache.rb
second_level_cache-2.6.3 lib/second_level_cache.rb
second_level_cache-2.6.2 lib/second_level_cache.rb
second_level_cache-2.6.1 lib/second_level_cache.rb