Class: RailsWebCache::KeysController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RailsWebCache::KeysController
- Defined in:
- app/controllers/rails_web_cache/keys_controller.rb
Instance Method Summary collapse
-
#destroy ⇒ Object
DELETE /keys/:key.
-
#destroy_all ⇒ Object
DELETE /keys/all/:keys.
-
#index ⇒ Object
GET /keys.
-
#show ⇒ Object
GET /keys/:key.
Instance Method Details
#destroy ⇒ Object
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_all ⇒ Object
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 |
#index ⇒ Object
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 |
#show ⇒ Object
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 |