Class: Fastentry::CacheController

Inherits:
ApplicationController show all
Defined in:
app/controllers/fastentry/cache_controller.rb

Instance Method Summary collapse

Instance Method Details

#invalidateObject



16
17
18
19
20
21
# File 'app/controllers/fastentry/cache_controller.rb', line 16

def invalidate
  key = params[:key]
  Rails.cache.delete(key)

  redirect_back(fallback_location: root_path)
end

#showObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/fastentry/cache_controller.rb', line 3

def show
  @key = params[:key]
  
  begin
    expiration_date = Rails.cache.send(:read_entry, key, {}).expires_at
  rescue
    expiration_date = nil
  end

  @expiration = (Time.at(expiration_date).strftime("%a, %e %b %Y %H:%M:%S %z") if expiration_date.present?)
  @cache_item = Rails.cache.read(@key)
end