Weitere ähnliche Inhalte Ähnlich wie Como construir uma Aplicação que consuma e produza updates no Twitter usando Python Ähnlich wie Como construir uma Aplicação que consuma e produza updates no Twitter usando Python (20) Kürzlich hochgeladen (20) Como construir uma Aplicação que consuma e produza updates no Twitter usando Python8. ANTES DA SOLUÇÃO, UM PASSO ATRÁS:
MONITORAR A APLICAÇÃO
NewRelic
Nazar.io
HoneyBadger
Logentries
Inspectlet
The Informant
13. Cache é um componente que guarda
informações de forma TRANSPARENTE
para que futuras requisições
sejam mais RÁPIDAS
29. PAGE CACHE
WRITE ON DISK
BYPASS RAILS APPLICATION ENTIRE
STATELESS PAGES
NÃO FUNCIONA NO HEROKU
30. PAGE CACHE
class WeblogController < ActionController::Base
caches_page :show, :new
def update
expire_page action: 'show', id: params[:list][:id]
end
end
32. ACTION CACHE
class PostsController < ActionController::Base
caches_action :show, expires_in: 1.hour
end
35. RAILS CACHE
FRAGMENT AND ACTION CACHE BUILD ON RAILS.CACHE
CONFIG.ACTION_CONTROLLER.PERFORM_CACHING = TRUE
37. HOW TO USE IT
Rails.cache.write 'foo', 'bar'
Rails.cache.fetch 'foo'
Rails.cache.write :foo, {a: 'b'}
40. FRAGMENT CACHING
<% cache “event-#{event.id}”, expires_in: 1.year do %>
<%= render event %>
<% end %>
44. FRAGMENT CACHING
<% cache :recent_attendees, expires_in: 5.minutes do %>
<%= render partial: 'recent',
collection: Attendees.recent %>
<% end %>
45. FRAGMENT CACHING
<% cache(cache_key_for_attendees) do %>
<%= render partial: 'recent', collection:
Attendees.recent %>
<% end %>
46. FRAGMENT CACHING
module AttendeesHelper
def cache_key_for_attendees
count = Attendee.count
max_updated_at =
Attendee.maximum(:updated_at).try(:utc).try(:to_s, :number)
"attendees/all-#{count}-#{max_updated_at}"
end
end
47. FRAGMENT CACHING
<% cache(cache_key_for_attendees) do %>
<%= render partial: 'recent', collection:
Attendees.recent %>
<% end %>
49. CACHE Digests
<!-- app/views/events/show.html.erb -->
<% cache ["v1", @event] do%>
<h1>Team: <%= @event.title %></h1>
<%= render @event.attendees %>
<% end %>
<!-- app/views/attendees/_attendee.html.erb -->
<% cache ["v1", attendee] do %>
<span><%= attendee.name %></span>
<span><%= attendee.email %></span>
<% end %>
84. Russian Doll
% cache(cache_key_for_attendees) do %
All available attendees:
% Attendee.all.each do |a| %
% cache(a) do %
p%= a.name %/p
% end %
% end %
% end %