Class: SolidCacheDashboard::CacheEntriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SolidCacheDashboard::CacheEntriesController
- Defined in:
- app/controllers/solid_cache_dashboard/cache_entries_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#clear_all ⇒ Object
44 45 46 47 48 |
# File 'app/controllers/solid_cache_dashboard/cache_entries_controller.rb', line 44 def clear_all SolidCache::Entry.delete_all SolidCacheDashboard::CacheEvent.delete_all if defined?(SolidCacheDashboard::CacheEvent) redirect_to cache_entries_path, notice: "All cache entries and statistics have been reset" end |
#delete ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/solid_cache_dashboard/cache_entries_controller.rb', line 33 def delete cache_entry = SolidCache::Entry.find_by_key_hash(params[:id].to_i) if cache_entry cache_entry.delete redirect_to cache_entries_path, notice: "Cache entry deleted" else redirect_to cache_entries_path, alert: "Cache entry not found" end end |
#index ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/solid_cache_dashboard/cache_entries_controller.rb', line 3 def index query = SolidCache::Entry.order(created_at: :desc) # Apply search filter if provided if params[:search].present? search_term = params[:search].strip # Convert search term to key hash for exact key_hash lookups require 'digest' key_hash = Digest::SHA256.digest(search_term).unpack("q>").first rescue nil # Search by key or key_hash query = query.where("key LIKE ? OR key_hash = ?", "%#{search_term}%", key_hash) end @pagy, entries = pagy(query, items: 25) @cache_entries = SolidCacheDashboard.decorate(entries) end |
#show ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/solid_cache_dashboard/cache_entries_controller.rb', line 22 def show @cache_entry = SolidCacheDashboard.decorate( SolidCache::Entry.find_by_key_hash(params[:id].to_i) ) unless @cache_entry redirect_to cache_entries_path, alert: "Cache entry not found" return end end |