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.



6
7
8
# File 'lib/solid_cache/store/entries.rb', line 6

def clear_with
  @clear_with
end

Instance Method Details

#initialize(options = {}) ⇒ Object



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

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