supercache 0.7 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0709e293782e7c60aa3b64e3f6dc40e9039c2238
4
- data.tar.gz: 829304d977ef6c1fe389727dcd4754a6e1e9ad6b
3
+ metadata.gz: bff91563a08d2c564330e05fe3274bd48fa20fbf
4
+ data.tar.gz: 26b33642dc3e44083e00cd35e9f55bcfc4437c58
5
5
  SHA512:
6
- metadata.gz: 1028380ce77e06528257f5e28c0aaa262e928116bcbb8210ba2c1dafdeb395dcfee8893679e34d001d6c284e31ab470787bb11ec737c2b5d73ebec1a5a6eadbd
7
- data.tar.gz: f2d5abe2f224b7110ad34ec48e59c9b3ff124deca40996a306f2ab171cfcbceb34fd21f79aad025505ac26ead2a37ff4ad7b4d46cddfa36a6e016649f6bd2cb3
6
+ metadata.gz: 4d88fabef842e4ad59b53b2634a224f9e18c420c2f5f8c97c0ba588a213ec0d6869c6218b4c732b4689049df126efe04773c5de8c415beecdc03e125284f60c4
7
+ data.tar.gz: 8c88c8e349af7f7f2e2cf846c29fbfdb7475da4308b8d7b3d63878eabe8e2a2dca2b62e0a099fa2349aece80c259acd1439e1e5db4d0a8d30b08ff93cbc97acd
data/.travis.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
3
  - 2.2.5
5
4
  - 2.3.1
5
+ - 2.4.1
6
6
 
7
7
  before_install: gem install bundler
8
8
 
@@ -21,9 +21,9 @@ gemfile:
21
21
 
22
22
  matrix:
23
23
  exclude:
24
- - rvm: 1.9.3
24
+ - rvm: 2.4.1
25
+ gemfile: gemfiles/rails_4.0.gemfile
26
+ - rvm: 2.4.1
25
27
  gemfile: gemfiles/rails_4.1.gemfile
26
- - rvm: 1.9.3
27
- gemfile: gemfiles/rails_4.2.gemfile
28
- - rvm: 1.9.3
29
- gemfile: gemfiles/rails_5.0.gemfile
28
+ - rvm: 2.4.1
29
+ gemfile: gemfiles/rails_4.2.gemfile
data/README.md CHANGED
@@ -17,9 +17,33 @@ gem 'supercache', group: :development
17
17
  And mount the dashboard in your `config/routes.rb`:
18
18
 
19
19
  ```ruby
20
- mount Supercache::Engine, at: "supercache"
20
+ mount Supercache::Engine, at: "supercache" if Rails.env.development?
21
21
  ```
22
22
 
23
+ ## Customize Supercache
24
+
25
+ Once you've included supercache in your devleopment environment, customizing it will be as simple as heading to loclahost:3000/supercache.
26
+
27
+ ![Screenshot](wiki/screenshot.png)
28
+
29
+ You will see two types of caching by default. Activerecord query caching and HTTP Caching.
30
+
31
+ ## How it works
32
+
33
+ Please note supercache is to speed up development environment and I strongly recommend against using it in any other environment like a staging or production. It is vital that you understand the pros and cons of caching across requests.
34
+
35
+ By default rails caches duplicate queries that are fired within the same request. In instances where you are focused mainly only UI related issues and that you have to refresh your page many times, you will have to painfully wait for the queries to get completed. During these times, Supercache will be a true bliss. All you have to do is turn it ON and your queries are cached across all requests.
36
+
37
+ Ensure that you turn it off, otherwise you may end up observing your query results are stale.
38
+
39
+ ## HTTP Caching
40
+
41
+ Initially I had only ActiveRecord in mind, however while developing I saw a bunch of redundant HTTP requests going from my server to outside world which often are stale themselves. So why not cache it? And thus came the super http cache. This could be typically used if your server is using external requests and that you don't care if they are not fresh.
42
+
43
+ ## Supercache is Super-unobtrusive
44
+
45
+ While developing supercache, I had wanted to keep it as unobtrusive as possible. Supercache does not bother what type of caching is implemented in your development environment. It could be file cache, Redis, Memcache, In-memory caching, supercache will simply work well with any of them!
46
+
23
47
  ## Development
24
48
 
25
49
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -40,7 +64,6 @@ available tasks.
40
64
  The RSpec test suite can be run with `rake`, or
41
65
  `rake appraisal:rails4.0` to include Rails-specific specs.
42
66
 
43
-
44
67
  ## License
45
68
 
46
69
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -1,8 +1,9 @@
1
1
  module Supercache
2
2
  class DashboardController < ActionController::Base
3
+ protect_from_forgery
3
4
  layout 'supercache/application'
4
5
 
5
- before_filter :load_cache, only: :flip
6
+ before_action :load_cache, only: :flip
6
7
 
7
8
  def index
8
9
  @ar_cache = cache.read(:ar_supercache)
@@ -13,8 +13,7 @@
13
13
  <%= yield %>
14
14
  </div>
15
15
  </main>
16
- <!-<script src='https://cdnjs.cloudflare.com/ajax/libs/turbolinks/5.0.0/turbolinks.min.js'></script> -->
17
16
  <script src='https://code.jquery.com/jquery-2.1.1.min.js'></script>
18
17
  <script src='https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/js/materialize.min.js'></script>
19
18
  </body>
20
- </html>
19
+ </html>
@@ -1,17 +1,13 @@
1
- module Net
2
- class HTTP
3
- def request_with_superhttpcache(*args, &block)
4
- if Rails.cache.read(:http_supercache)
5
- Rails.cache.fetch(Digest::SHA1.hexdigest(args[0].path.to_s + args[0].body.to_s)) do
6
- request_without_superhttpcache(*args, &block)
7
- end
8
- else
9
- request_without_superhttpcache(*args, &block)
1
+ require 'net/http'
2
+ module SuperHttpCache
3
+ def request(*args, &block)
4
+ if Rails.cache.read(:http_supercache)
5
+ Rails.cache.fetch(Digest::SHA1.hexdigest(args[0].path.to_s + args[0].body.to_s)) do
6
+ super(*args, &block)
10
7
  end
8
+ else
9
+ super(*args, &block)
11
10
  end
12
-
13
- alias_method :request_without_superhttpcache, :request
14
- alias_method :request, :request_with_superhttpcache
15
-
16
11
  end
17
- end
12
+ end
13
+ ::Net::HTTP.prepend(SuperHttpCache)
@@ -1,37 +1,14 @@
1
- if RUBY_VERSION < "2.0"
2
- module ActiveRecord
3
- module ConnectionAdapters # :nodoc:
4
- module QueryCache
5
- def cache_sql_with_superquerycache(*args, &block)
6
- if Rails.cache.read(:ar_supercache)
7
- sub_key = args[1].collect{|a| "#{a.try(:name)} #{a.try(:value)}"}
8
- Rails.cache.fetch(Digest::SHA1.hexdigest("supercache_#{args[0]}_#{sub_key}")) do
9
- request_without_superquerycache(*args, &block)
10
- end
11
- else
12
- request_without_superquerycache(*args, &block)
13
- end
14
- end
15
-
16
- alias_method :request_without_superquerycache, :cache_sql
17
- alias_method :cache_sql, :cache_sql_with_superquerycache
18
-
19
- end
20
- end
21
- end
22
- else
23
- module SuperQueryCache
24
- def cache_sql(*args, &block)
25
- if Rails.cache.read(:ar_supercache)
26
- sub_key = args[1].collect{|a| "#{a.try(:name)} #{a.try(:value)}"}
27
- Rails.cache.fetch(Digest::SHA1.hexdigest("supercache_#{args[0]}_#{sub_key}")) do
28
- super(*args, &block)
29
- end
30
- else
1
+ module SuperQueryCache
2
+ def cache_sql(*args, &block)
3
+ if Rails.cache.read(:ar_supercache)
4
+ sub_key = args[1].collect{|a| "#{a.try(:name)} #{a.try(:value)}"}
5
+ Rails.cache.fetch(Digest::SHA1.hexdigest("supercache_#{args[0]}_#{sub_key}")) do
31
6
  super(*args, &block)
32
7
  end
8
+ else
9
+ super(*args, &block)
33
10
  end
34
11
  end
12
+ end
35
13
 
36
- ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend(SuperQueryCache)
37
- end
14
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend(SuperQueryCache)
@@ -1,3 +1,3 @@
1
1
  module Supercache
2
- VERSION = "0.7"
2
+ VERSION = "0.7.1"
3
3
  end
data/lib/supercache.rb CHANGED
@@ -4,5 +4,4 @@ require "supercache/super_query_cache"
4
4
  require "supercache/super_http_cache"
5
5
 
6
6
  module Supercache
7
-
8
7
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supercache
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.7'
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bragadeesh J
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-24 00:00:00.000000000 Z
11
+ date: 2017-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -101,6 +101,7 @@ files:
101
101
  - lib/supercache/super_query_cache.rb
102
102
  - lib/supercache/version.rb
103
103
  - supercache.gemspec
104
+ - wiki/screenshot.png
104
105
  homepage: https://github.com/bragboy/supercache
105
106
  licenses:
106
107
  - MIT
@@ -121,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
122
  version: '0'
122
123
  requirements: []
123
124
  rubyforge_project:
124
- rubygems_version: 2.5.1
125
+ rubygems_version: 2.6.13
125
126
  signing_key:
126
127
  specification_version: 4
127
128
  summary: Speed up Development time