Class: RailsWebCache::KeysController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rails_web_cache/keys_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject

DELETE /keys/:key



28
29
30
31
32
# File 'app/controllers/rails_web_cache/keys_controller.rb', line 28

def destroy
  redirect_to root_path if @key.nil?
  cache.delete(@key)
  redirect_to root_path
end

#destroy_allObject

DELETE /keys/all/:keys



35
36
37
38
39
40
41
42
# File 'app/controllers/rails_web_cache/keys_controller.rb', line 35

def destroy_all
  keys = params[:keys].presence || []
  redirect_to root_path if keys.nil? || keys.empty?
  keys.each do |key|
    cache.delete(key)
  end
  redirect_to root_path
end

#indexObject

GET /keys



11
12
13
14
15
16
17
18
# File 'app/controllers/rails_web_cache/keys_controller.rb', line 11

def index
  @keys = keys
  @pages = (@keys.size / @per_page.to_f).ceil
  @keys = @keys[@offset, @per_page] || []
  @keys = @keys.map.with_index do |key, idx|
    format_key(key, idx)
  end
end

#showObject

GET /keys/:key



21
22
23
24
25
# File 'app/controllers/rails_web_cache/keys_controller.rb', line 21

def show
  redirect_to root_path if @key.nil?
  @value = cache.read(@key)
  @entry = cache.entry(@key)
end