supercache 0.4 → 0.5

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: f9877d354bbde4b23ab391e2503df567b2635c42
4
- data.tar.gz: 4568f4d4fb3086d1a580a47fd8318f55e78ef6cf
3
+ metadata.gz: 33d861e49df9f206bbcfdef96f864d574828f142
4
+ data.tar.gz: 74c44314df7dc774bb84356e7ef20a44482afb86
5
5
  SHA512:
6
- metadata.gz: 4b0cdb7cd2ed4788194b9558e210ceee9f903abf691b231bc16cac70c9a255a9f46c888c8ab690e9144cede39eb1a67e6045c6b7c60e81f07abaf45a2d2ccf97
7
- data.tar.gz: 3c7ab638578e9a1f857003c179f9b21d5d963a1df9fa95ef45ac77df26384940b7ff02b1c667221c6caaab52f3e0de88fd770251a8d022c689eb3057874e73d4
6
+ metadata.gz: e614c33ee5ac71d062eeb646fb9ec759a575ee6d9c006a973a5574431c69b59eb9a80187f666fc1cf27ee3da186b5e1e9b964d943e060c5229836c102b6c2caf
7
+ data.tar.gz: 0be7e7e352c5708129053719eb1354c417d9514377837c9687adf4b4dad2022124e19b7d3681cb2f64ff38924b19288f274f936c81bcf53e32db8e53d57ebaf5
data/.travis.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 1.9.3
3
4
  - 2.2.5
4
5
  - 2.3.1
5
6
  - ruby-head
@@ -11,3 +12,12 @@ gemfile:
11
12
  - gemfiles/rails_4.1.gemfile
12
13
  - gemfiles/rails_4.2.gemfile
13
14
  - gemfiles/rails_5.0.gemfile
15
+
16
+ matrix:
17
+ exclude:
18
+ - rvm: 1.9.3
19
+ gemfile: gemfiles/rails_4.1.gemfile
20
+ - rvm: 1.9.3
21
+ gemfile: gemfiles/rails_4.2.gemfile
22
+ - rvm: 1.9.3
23
+ gemfile: gemfiles/rails_5.0.gemfile
data/README.md CHANGED
@@ -48,6 +48,4 @@ The gem is available as open source under the terms of the [MIT License](http://
48
48
  ## Scope for Contribution
49
49
 
50
50
  1. RSpec Integration
51
- 2. Add Caching Support for HTTP Requests
52
- 3. Add RSolr Cache
53
- 4. Add Exceptions to Caching
51
+ 2. Add Exceptions to Caching
@@ -2,7 +2,7 @@ module Net
2
2
  class HTTP
3
3
  def request_with_superhttpcache(*args, &block)
4
4
  if Rails.cache.read(:http_supercache)
5
- Rails.cache.fetch(args[0].path.to_s.hash + args[0].body.to_s.hash) do
5
+ Rails.cache.fetch(Digest::SHA1.hexdigest(args[0].path.to_s + args[0].body.to_s)) do
6
6
  request_without_superhttpcache(*args, &block)
7
7
  end
8
8
  else
@@ -1,13 +1,35 @@
1
- module SuperQueryCache
2
- def cache_sql(sql, binds)
3
- if Rails.cache.read(:ar_supercache)
4
- Rails.cache.fetch("supercache_#{sql}_#{binds.to_s}".hash) do
5
- super(sql, binds)
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
+ Rails.cache.fetch(Digest::SHA1.hexdigest("supercache_#{args[0]}_#{args[1]}")) do
8
+ request_without_superquerycache(*args, &block)
9
+ end
10
+ else
11
+ request_without_superquerycache(*args, &block)
12
+ end
13
+ end
14
+
15
+ alias_method :request_without_superquerycache, :cache_sql
16
+ alias_method :cache_sql, :cache_sql_with_superquerycache
17
+
18
+ end
19
+ end
20
+ end
21
+ else
22
+ module SuperQueryCache
23
+ def cache_sql(*args, &block)
24
+ if Rails.cache.read(:ar_supercache)
25
+ Rails.cache.fetch(Digest::SHA1.hexdigest("supercache_#{args[0]}_#{args[1]}")) do
26
+ super(*args, &block)
27
+ end
28
+ else
29
+ super(*args, &block)
6
30
  end
7
- else
8
- super(sql, binds)
9
31
  end
10
32
  end
11
- end
12
33
 
13
- ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend(SuperQueryCache)
34
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend(SuperQueryCache)
35
+ end
@@ -1,3 +1,3 @@
1
1
  module Supercache
2
- VERSION = "0.4"
2
+ VERSION = "0.5"
3
3
  end
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.4'
4
+ version: '0.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bragadeesh J
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-15 00:00:00.000000000 Z
11
+ date: 2016-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler