Module: SolidCache::Store::Entries

Included in:
SolidCache::Store
Defined in:
lib/solid_cache/store/entries.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clear_withObject (readonly)

Returns the value of attribute clear_with.



4
5
6
# File 'lib/solid_cache/store/entries.rb', line 4

def clear_with
  @clear_with
end

Instance Method Details

#initialize(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/solid_cache/store/entries.rb', line 6

def initialize(options = {})
  super(options)

  # Truncating in test mode breaks transactional tests in MySQL (not in Postgres though)
  @clear_with = options.fetch(:clear_with) { Rails.env.test? ? :delete : :truncate }&.to_sym

  unless [ :truncate, :delete ].include?(clear_with)
    raise ArgumentError, "`clear_with` must be either ``:truncate`` or ``:delete`"
  end
end