Class: Fastentry::DashboardController

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

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/fastentry/dashboard_controller.rb', line 5

def index
  @keys = Fastentry.cache.keys

  if params[:query].present?
    @keys.select! { |key| key.downcase.include?(params[:query].downcase) }
  end

  @number_of_pages = (@keys.count / @per_page.to_f).ceil
  @keys = @keys[@offset, @per_page] || []

  @cached =
    @keys.map do |key|
      {
        cache_key: key,
        cache_value: Fastentry.cache.read(key),
        expiration: Fastentry.cache.expiration_for(key)
      }
    end
end