changeset 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 9d467113d715
children b8c00142fbfc
files Gemfile Gemfile.lock README.md app/controllers/pastes_controller.rb
diffstat 4 files changed, 2 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/Gemfile	Sat Feb 14 01:23:36 2015 +0900
+++ b/Gemfile	Sat Feb 14 01:35:45 2015 +0900
@@ -10,7 +10,6 @@
 gem "pg", :platforms => :ruby
 gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
 gem "jruby-openssl", :platforms => :jruby
-gem "dalli"
 
 gem "sass-rails", "~> 5.0" # Rails 4.2 default
 
--- a/Gemfile.lock	Sat Feb 14 01:23:36 2015 +0900
+++ b/Gemfile.lock	Sat Feb 14 01:35:45 2015 +0900
@@ -56,7 +56,6 @@
       coffee-script-source
       execjs
     coffee-script-source (1.9.0)
-    dalli (2.7.2)
     erubis (2.7.0)
     execjs (2.3.0)
     globalid (0.3.3)
@@ -151,7 +150,6 @@
   activerecord-jdbcpostgresql-adapter
   bootstrap-sass
   coffee-rails (~> 4.1.0)
-  dalli
   jquery-rails
   jruby-openssl
   newrelic_rpm
--- a/README.md	Sat Feb 14 01:23:36 2015 +0900
+++ b/README.md	Sat Feb 14 01:35:45 2015 +0900
@@ -18,56 +18,12 @@
 Optional:
 
 * Newrelic account
-* memcached
-
-Suggested:
-
-* nginx
 
 Installation
 ------------
 
 Left as an exercise.
 
-nginx configuration
--------------------
-
-Here's nginx configuration snippet which use memcached to completely bypass Rails.
-
-    server {
-      server_name 0paste.com;
-      listen 80; listen [::]:80;
-      root /var/www/0paste.com/public;
-      error_page 445 = @zp;
-      error_page 404 /404.html;
-
-      if ($request_method = POST) {
-        return 445;
-      }
-
-      location / {
-        expires max;
-        try_files $uri @zp;
-      }
-
-      location ~ /(\d+(?:-\x+)?)(?:(\.txt)|\.html)?$ {
-        expires max;
-        charset utf-8;
-        set $memcached_key "zeropaste:pastes:$1$2";
-        memcached_pass localhost:11211;
-
-        default_type text/html;
-        error_page 404 502 = @zp;
-      }
-
-      location @zp {
-        proxy_pass http://localhost:9200;
-        proxy_set_header X-Forwarded-For $remote_addr;
-        proxy_set_header Host $host;
-        proxy_intercept_errors on;
-      }
-    }
-
 Misc
 ----
 
--- 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