cached_resource 4.1.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/.travis.yml +2 -6
- data/README.md +3 -2
- data/lib/cached_resource/caching.rb +1 -1
- data/lib/cached_resource/configuration.rb +2 -0
- data/lib/cached_resource/version.rb +1 -1
- data/spec/cached_resource/configuration_spec.rb +5 -0
- metadata +63 -80
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
|
4
|
-
|
5
|
-
SHA512:
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
data.tar.gz: 5a25521a92a1fb2800c9734c31f422b824fa1b40
|
4
|
+
metadata.gz: 6451d12d14761ee761281ef929608e6c2c30f4b9
|
5
|
+
SHA512:
|
6
|
+
data.tar.gz: 63e554366a04e5b6e6a80042c17548a2845f5b9437e3dbed4dbb664cc1ca791c35677f08c778933dfd2f3661492b39ea0d4bd11db7a0bbd263cc04100519a253
|
7
|
+
metadata.gz: 0a2b8a5cdb2b20fea4f93e1eb311145e1c81e9c705c5e1a42fb140cbce9c5a06efb765474d395f09462037c5ca23072f973e08b623b83767eb2cc3fc5b938b85
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# CachedResource [![Build Status](https://secure.travis-ci.org/
|
1
|
+
# CachedResource [![Build Status](https://secure.travis-ci.org/mhgbrown/cached_resource.png)](http://travis-ci.org/mhgbrown/cached_resource)
|
2
2
|
CachedResource is a Ruby gem whose goal is to increase the performance of interacting with web services via ActiveResource by caching responses based on request parameters. It can help reduce the lag created by making repeated requests across a network.
|
3
3
|
|
4
4
|
## Installation
|
@@ -8,7 +8,7 @@ CachedResource is a Ruby gem whose goal is to increase the performance of intera
|
|
8
8
|
CachedResource supports the following Ruby versions:
|
9
9
|
|
10
10
|
* 1.9.2, 1.9.3
|
11
|
-
* 2.0.0, 2.1.0
|
11
|
+
* 2.0.0, 2.1.0, 2.2.3
|
12
12
|
|
13
13
|
If you require 1.8.7 support, please use version 2.3.4.
|
14
14
|
|
@@ -36,6 +36,7 @@ CachedResource accepts the following options:
|
|
36
36
|
|
37
37
|
* `:enabled` Default: `true`
|
38
38
|
* `:ttl` The time in seconds until the cache should expire. Default: `604800`
|
39
|
+
* `:race_condition_ttl` The race condition ttl, to prevent [dog pile effect](https://en.wikipedia.org/wiki/Cache_stampede) or [cache stampede](https://en.wikipedia.org/wiki/Cache_stampede). Default: 86400
|
39
40
|
* `:ttl_randomization` Enable ttl randomization. Default: `false`
|
40
41
|
* `:ttl_randomization_scale` A Range from which a random value will be selected to scale the ttl. Default: `1..2`
|
41
42
|
* `:collection_synchronize` Use collections to generate cache entries for individuals. Update the existing cached principal collection when retrieving subsets of the principal collection or individuals. Default: `false`
|
@@ -98,7 +98,7 @@ module CachedResource
|
|
98
98
|
|
99
99
|
# Write an entry to the cache for the given key and value.
|
100
100
|
def cache_write(key, object)
|
101
|
-
result = cached_resource.cache.write(key, object, :expires_in => cached_resource.generate_ttl)
|
101
|
+
result = cached_resource.cache.write(key, object, :race_condition_ttl => cached_resource.race_condition_ttl, :expires_in => cached_resource.generate_ttl)
|
102
102
|
result && cached_resource.logger.info("#{CachedResource::Configuration::LOGGER_PREFIX} WRITE #{key}")
|
103
103
|
result
|
104
104
|
end
|
@@ -20,6 +20,7 @@ module CachedResource
|
|
20
20
|
# defaults. The following options exist for cached resource:
|
21
21
|
# :enabled, default: true
|
22
22
|
# :ttl, default: 604800
|
23
|
+
# :race_condition_ttl: 86400
|
23
24
|
# :ttl_randomization, default: false,
|
24
25
|
# :ttl_randomization_scale, default: 1..2,
|
25
26
|
# :collection_synchronize, default: false,
|
@@ -29,6 +30,7 @@ module CachedResource
|
|
29
30
|
def initialize(options={})
|
30
31
|
super({
|
31
32
|
:enabled => true,
|
33
|
+
:race_condition_ttl => 86400,
|
32
34
|
:ttl => 604800,
|
33
35
|
:ttl_randomization => false,
|
34
36
|
:ttl_randomization_scale => 1..2,
|
@@ -66,6 +66,7 @@ describe "CachedResource::Configuration" do
|
|
66
66
|
before(:each) do
|
67
67
|
class Foo < ActiveResource::Base
|
68
68
|
cached_resource :ttl => 1,
|
69
|
+
:race_condition_ttl => 5,
|
69
70
|
:cache => "cache",
|
70
71
|
:logger => "logger",
|
71
72
|
:enabled => false,
|
@@ -82,6 +83,7 @@ describe "CachedResource::Configuration" do
|
|
82
83
|
it "should relfect the specified options" do
|
83
84
|
cr = Foo.cached_resource
|
84
85
|
cr.ttl.should == 1
|
86
|
+
expect(cr.race_condition_ttl).to eq(5)
|
85
87
|
cr.cache.should == "cache"
|
86
88
|
cr.logger.should == "logger"
|
87
89
|
cr.enabled.should == false
|
@@ -122,6 +124,7 @@ describe "CachedResource::Configuration" do
|
|
122
124
|
before(:each) do
|
123
125
|
class Bar < ActiveResource::Base
|
124
126
|
cached_resource :ttl => 1,
|
127
|
+
:race_condition_ttl => 5,
|
125
128
|
:cache => "cache",
|
126
129
|
:logger => "logger",
|
127
130
|
:enabled => false,
|
@@ -149,6 +152,7 @@ describe "CachedResource::Configuration" do
|
|
149
152
|
before(:each) do
|
150
153
|
class Bar < ActiveResource::Base
|
151
154
|
cached_resource :ttl => 1,
|
155
|
+
:race_condition_ttl => 5,
|
152
156
|
:cache => "cache",
|
153
157
|
:logger => "logger",
|
154
158
|
:enabled => false,
|
@@ -182,6 +186,7 @@ describe "CachedResource::Configuration" do
|
|
182
186
|
cr.custom.should == nil
|
183
187
|
cr.ttl_randomization.should == false
|
184
188
|
cr.ttl_randomization_scale.should == (1..2)
|
189
|
+
expect(cr.race_condition_ttl).to eq(86400)
|
185
190
|
end
|
186
191
|
|
187
192
|
end
|
metadata
CHANGED
@@ -1,94 +1,77 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: cached_resource
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Morgan Brown
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
|
12
|
+
date: 2015-12-03 00:00:00 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
14
15
|
name: rake
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
16
|
prerelease: false
|
22
|
-
|
23
|
-
requirements:
|
24
|
-
-
|
25
|
-
-
|
26
|
-
|
27
|
-
|
28
|
-
name: activeresource
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '3.2'
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- &id005
|
20
|
+
- ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
34
23
|
type: :runtime
|
24
|
+
version_requirements: *id001
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: activeresource
|
35
27
|
prerelease: false
|
36
|
-
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '3.2'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: activesupport
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
45
30
|
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version:
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: "3.2"
|
48
33
|
type: :runtime
|
34
|
+
version_requirements: *id002
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: activesupport
|
49
37
|
prerelease: false
|
50
|
-
|
51
|
-
requirements:
|
38
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
52
40
|
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: nilio
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: "3.2"
|
62
43
|
type: :runtime
|
44
|
+
version_requirements: *id003
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: nilio
|
63
47
|
prerelease: false
|
64
|
-
|
65
|
-
requirements:
|
48
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
66
50
|
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "1.0"
|
53
|
+
type: :runtime
|
54
|
+
version_requirements: *id004
|
55
|
+
- !ruby/object:Gem::Dependency
|
70
56
|
name: rspec
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
57
|
prerelease: false
|
78
|
-
|
79
|
-
requirements:
|
80
|
-
-
|
81
|
-
|
82
|
-
|
58
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- *id005
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id006
|
83
63
|
description: Enables request-based caching for ActiveResource
|
84
64
|
email: brown.mhg@gmail.com
|
85
65
|
executables: []
|
66
|
+
|
86
67
|
extensions: []
|
68
|
+
|
87
69
|
extra_rdoc_files: []
|
88
|
-
|
89
|
-
|
90
|
-
-
|
91
|
-
-
|
70
|
+
|
71
|
+
files:
|
72
|
+
- .gitignore
|
73
|
+
- .rspec
|
74
|
+
- .travis.yml
|
92
75
|
- Gemfile
|
93
76
|
- MIT-LICENSE
|
94
77
|
- README.md
|
@@ -105,28 +88,28 @@ files:
|
|
105
88
|
- spec/spec_helper.rb
|
106
89
|
homepage: http://github.com/Ahsizara/cached_resource
|
107
90
|
licenses: []
|
91
|
+
|
108
92
|
metadata: {}
|
93
|
+
|
109
94
|
post_install_message:
|
110
95
|
rdoc_options: []
|
111
|
-
|
96
|
+
|
97
|
+
require_paths:
|
112
98
|
- lib
|
113
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
requirements:
|
120
|
-
- - ">="
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: '0'
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- *id005
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- *id005
|
123
105
|
requirements: []
|
106
|
+
|
124
107
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.0.14
|
126
109
|
signing_key:
|
127
110
|
specification_version: 4
|
128
111
|
summary: Caching for ActiveResource
|
129
|
-
test_files:
|
112
|
+
test_files:
|
130
113
|
- spec/cached_resource/caching_spec.rb
|
131
114
|
- spec/cached_resource/configuration_spec.rb
|
132
115
|
- spec/spec_helper.rb
|