diff app/controllers/pastes_controller.rb @ 366:26545fe719ca

Remove caching system. Too much complexity for something that is really simple.
author edogawaconan <me@myconan.net>
date Sat, 14 Feb 2015 01:35:45 +0900
parents cd1c3a28b89a
children 6e3e1e7b0212
line wrap: on
line diff
--- a/app/controllers/pastes_controller.rb	Sat Feb 14 01:23:36 2015 +0900
+++ b/app/controllers/pastes_controller.rb	Sat Feb 14 01:35:45 2015 +0900
@@ -7,10 +7,9 @@
     @paste = Paste.safe_find(params[:id])
     return head :not_found unless @paste
 
-    expires_in 1.month, :public => true
     respond_to do |format|
-      format.html { cache }
-      format.txt { cache }
+      format.html
+      format.txt
     end
   end
 
@@ -57,7 +56,6 @@
   def destroy
     @paste = Paste.safe_find(params[:id])
     if @paste.safe_destroy(params[:paste][:key])
-      uncache
       redirect_to root_path, :notice => "Paste ##{params[:id]} deleted"
     else
       flash.now[:alert] = @paste.errors.full_messages.to_sentence
@@ -74,30 +72,6 @@
     end
   end
 
-  def cache_key(format = request.format.symbol)
-    ext = case format
-          when :txt
-            ".txt"
-          when :html, nil
-            ""
-          else
-            ".unknown"
-          end
-    "pastes:#{@paste.to_param}#{ext}"
-  end
-
-  def cache
-    Rails.cache.fetch cache_key, :raw => true do
-      render_to_string :show
-    end
-  end
-
-  def uncache
-    [:txt, :html, :unknown].each do |format|
-      Rails.cache.delete cache_key(format)
-    end
-  end
-
   def paste_params
     params.require(:paste).permit(:paste, :paste_gzip, :paste_gzip_base64, :is_private, :key)
   end