Cache fixes, vk like
This commit is contained in:
@@ -11,8 +11,8 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def compile_page params
|
||||
compiler = lambda do |params|
|
||||
@data = params[:data].call(&(params[:data].lambda? ? :call : :serialize)) unless params[:data].nil?
|
||||
@status = params[:status] unless params[:status].nil?
|
||||
@data = params[:data].is_a?(Proc) ? params[:data].call : params[:data].serialize unless params[:data].nil?
|
||||
@status = params[:status]
|
||||
{
|
||||
renderer: "unified",
|
||||
data: @data,
|
||||
@@ -23,8 +23,8 @@ class ApplicationController < ActionController::Base
|
||||
}.to_json.to_s
|
||||
end
|
||||
|
||||
unless params[:cache].nil?
|
||||
data = Rails.cache.fetch(params[:cache_key] || cache_key_for(params[:data]), expires_in: params[:cache]) do
|
||||
unless params[:cache_for].nil?
|
||||
data = Rails.cache.fetch(params[:cache_key] || cache_key_for(params[:data]), expires_in: params[:cache_for]) do
|
||||
compiler.call(params)
|
||||
end
|
||||
else
|
||||
|
||||
@@ -32,7 +32,7 @@ class ArtistController < ApplicationController
|
||||
title: @artist.name,
|
||||
status: @artist.status_str,
|
||||
callback: {object: :player, action: :updateLibrary},
|
||||
cache: 3.minutes
|
||||
cache_for: 1.day
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class PlaylistController < ApplicationController
|
||||
partial: "playlist/tracks",
|
||||
title: "#{artist.name}: Last.fm TOP 50",
|
||||
callback: {object: :player, action: :updateLibrary},
|
||||
cache: 3.minutes,
|
||||
cache_for: 7.days,
|
||||
cache_key: "lastfmtop50_#{artist.id}"
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user