active_remote-cached 0.0.9 → 0.1.0

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: 7bf594804579aa384b0224646afcf8feaca70b57
4
- data.tar.gz: 83749d18cc7ffe032696a2dd7e4667401564d8a9
3
+ metadata.gz: 30ab76a72a43662a016c241f8ea069559fbffd2f
4
+ data.tar.gz: f5efe169305a48fbc569be896091f64fd265b2d6
5
5
  SHA512:
6
- metadata.gz: 2172bb1d81a714284a9d5211c39dbadbbb4466e588586adad836a9ff3e5848125aa743e8bc062aeac770e73bb904f38108c66ff05741765f80405e49c6b13275
7
- data.tar.gz: 4f6708a5191b6b4284e896ac9bdbaa84911b49196dabf6676c4a611dbfde277044af807f03c777173e6c65fa076251edb4caf6f226795a4d7516fe2661ce3980
6
+ metadata.gz: 532fda905ee748ca161c6c04f6bdf6f904697a078eaa724a3557b4f22bbe5c45bd083555fcf32cfcafdc4f6963e09b9c37aa2559532748921897916aa2d7d24e
7
+ data.tar.gz: 53767240c5f8dfd8389adc4b9e62c4203fd68ffcdde73072311dc97cd157317e1a4cb6f5ebb7e54168f300ca4e5140a57a87085897039671b1f35efcb0d07da7
@@ -6,17 +6,32 @@ module ActiveRemote::Cached
6
6
 
7
7
  def initialize(new_cache_provider)
8
8
  @cache_provider = new_cache_provider
9
+ @nested_cache_provider = ::ActiveSupport::Cache::NullStore.new
10
+
9
11
  validate_provider_method_present(:delete)
10
12
  validate_provider_method_present(:exist?)
11
13
  validate_provider_method_present(:fetch)
12
14
  validate_provider_method_present(:read)
13
15
  validate_provider_method_present(:write)
14
-
16
+
15
17
  super(@cache_provider)
16
18
  end
17
19
 
20
+ def delete(*args)
21
+ nested_cache_provider.delete(*args)
22
+ super
23
+ end
24
+
25
+ def enable_nested_caching!
26
+ @nested_cache_provider = ::ActiveSupport::Cache::MemoryStore.new
27
+ end
28
+
29
+ def exist?(*args)
30
+ nested_cache_provider.exist?(*args) || super
31
+ end
32
+
18
33
  def fetch(name, options = {})
19
- fetch_value = super
34
+ fetch_value = nested_cache_provider.fetch(name, options) { super }
20
35
 
21
36
  unless valid_fetched_value?(fetch_value, options)
22
37
  delete(name)
@@ -25,7 +40,20 @@ module ActiveRemote::Cached
25
40
  return fetch_value
26
41
  end
27
42
 
28
- private
43
+ def read(*args)
44
+ nested_cache_provider.read(*args) || super
45
+ end
46
+
47
+ def write(*args)
48
+ nested_cache_provider.write(*args)
49
+ super
50
+ end
51
+
52
+ private
53
+
54
+ def nested_cache_provider
55
+ @nested_cache_provider
56
+ end
29
57
 
30
58
  def valid_fetched_value?(value, options = {})
31
59
  return false if value.nil?
@@ -41,6 +69,5 @@ module ActiveRemote::Cached
41
69
  CACHE_METHOD
42
70
  end
43
71
  end
44
-
45
72
  end
46
73
  end
@@ -2,22 +2,27 @@ require 'active_support/ordered_options'
2
2
 
3
3
  module ActiveRemote
4
4
  module Cached
5
- class Railtie < Rails::Railtie
6
- config.active_remote_cached = ActiveSupport::OrderedOptions.new
5
+ class Railtie < ::Rails::Railtie
6
+ config.active_remote_cached = ::ActiveSupport::OrderedOptions.new
7
7
 
8
8
  initializer "active_remote-cached.initialize_cache" do |app|
9
9
  config.active_remote_cached.expires_in ||= 5.minutes
10
10
  config.active_remote_cached.race_condition_ttl ||= 5.seconds
11
11
 
12
- ActiveRemote::Cached.cache(Rails.cache)
13
- ActiveRemote::Cached.default_options(
12
+ ::ActiveRemote::Cached.cache(Rails.cache)
13
+
14
+ if config.active_remote_cached.enable_nested_caching
15
+ ::ActiveRemote::Cached.cache.enable_nested_caching!
16
+ end
17
+
18
+ ::ActiveRemote::Cached.default_options(
14
19
  :expires_in => config.active_remote_cached.expires_in,
15
20
  :race_condition_ttl => config.active_remote_cached.race_condition_ttl
16
21
  )
17
22
  end
18
23
 
19
- ActiveSupport.on_load(:active_remote) do
20
- include ActiveRemote::Cached
24
+ ::ActiveSupport.on_load(:active_remote) do
25
+ include ::ActiveRemote::Cached
21
26
  end
22
27
  end
23
28
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRemote
2
2
  module Cached
3
- VERSION = "0.0.9"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_remote-cached
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Dewitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-20 00:00:00.000000000 Z
11
+ date: 2015-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_remote