rails-cache-tags 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rails/cache/tags/set.rb +0 -2
- data/lib/rails/cache/tags/store.rb +4 -3
- data/lib/rails/cache/tags/tag.rb +1 -1
- data/lib/rails/cache/tags/version.rb +1 -1
- data/spec/cache_tags_spec.rb +43 -31
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffa3ee36a2bbbdb72b538b31309db833ca3b5edd
|
4
|
+
data.tar.gz: d3e0272f5c56ec204d27f64b2eec55809c8f25bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61f8d07dfb0a900e18d82ffb4ec53b760d68e4aebc36fd134dbecdce4052bf0a753d6fb47e82cae24e04de19cee164c6aaef8050216cc1bad2ebaf02d126305a
|
7
|
+
data.tar.gz: 3e15df9a5b8aa84b1e5e875c9736d6bba08da4d1f0e946009d38f64d08abc3d9a6169bd8df40238d157bfa0da2d489939a9968a7095a19c3a443c8bf57fd7fa7
|
data/lib/rails/cache/tags/set.rb
CHANGED
@@ -34,7 +34,7 @@ module Rails
|
|
34
34
|
if entry
|
35
35
|
entry
|
36
36
|
else
|
37
|
-
delete(name)
|
37
|
+
delete(name, options)
|
38
38
|
|
39
39
|
nil
|
40
40
|
end
|
@@ -54,12 +54,13 @@ module Rails
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def exist_with_tags?(name, options = nil)
|
57
|
-
exist_without_tags?(name, options) && !read(name).nil?
|
57
|
+
exist_without_tags?(name, options) && !read(name, options).nil?
|
58
58
|
end
|
59
59
|
|
60
60
|
def read_multi_with_tags(*names)
|
61
61
|
result = read_multi_without_tags(*names)
|
62
62
|
|
63
|
+
names.extract_options!
|
63
64
|
names.each_with_object(Hash.new) do |name, hash|
|
64
65
|
hash[name.to_s] = tag_set.check(result[name.to_s])
|
65
66
|
end
|
@@ -82,7 +83,7 @@ module Rails
|
|
82
83
|
if (entry = tag_set.check(result))
|
83
84
|
entry
|
84
85
|
else # result is stale
|
85
|
-
delete(name)
|
86
|
+
delete(name, options)
|
86
87
|
fetch(name, options) { yield }
|
87
88
|
end
|
88
89
|
end
|
data/lib/rails/cache/tags/tag.rb
CHANGED
data/spec/cache_tags_spec.rb
CHANGED
@@ -9,8 +9,8 @@ describe Rails::Cache::Tags do
|
|
9
9
|
before { cache.clear }
|
10
10
|
|
11
11
|
def assert_read(key, object)
|
12
|
-
expect(cache.exist?(key)).to eq !!object
|
13
|
-
expect(cache.read(key)).to eq object
|
12
|
+
expect(cache.exist?(key, options)).to eq !!object
|
13
|
+
expect(cache.read(key, options)).to eq object
|
14
14
|
end
|
15
15
|
|
16
16
|
def assert_blank(key)
|
@@ -18,33 +18,33 @@ describe Rails::Cache::Tags do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'reads and writes a key with tags' do
|
21
|
-
cache.write
|
21
|
+
cache.write('foo', object, options.merge(:tags => 'baz'))
|
22
22
|
|
23
23
|
assert_read 'foo', object
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'deletes a key if tag is deleted' do
|
27
|
-
cache.write('foo', object, :tags => 'baz')
|
27
|
+
cache.write('foo', object, options.merge(:tags => 'baz'))
|
28
28
|
cache.delete_tag 'baz'
|
29
29
|
|
30
30
|
assert_blank 'foo'
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'reads a key if another tag was deleted' do
|
34
|
-
cache.write('foo', object, :tags => 'baz')
|
34
|
+
cache.write('foo', object, options.merge(:tags => 'baz'))
|
35
35
|
cache.delete_tag 'fu'
|
36
36
|
|
37
37
|
assert_read 'foo', object
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'reads and writes if multiple tags given' do
|
41
|
-
cache.write('foo', object, :tags => [:baz, :kung])
|
41
|
+
cache.write('foo', object, options.merge(:tags => [:baz, :kung]))
|
42
42
|
|
43
43
|
assert_read 'foo', object
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'deletes a key if one of tags is deleted' do
|
47
|
-
cache.write('foo', object, :tags => [:baz, :kung])
|
47
|
+
cache.write('foo', object, options.merge(:tags => [:baz, :kung]))
|
48
48
|
cache.delete_tag :kung
|
49
49
|
|
50
50
|
assert_blank 'foo'
|
@@ -63,7 +63,7 @@ describe Rails::Cache::Tags do
|
|
63
63
|
#end
|
64
64
|
|
65
65
|
it 'reads and writes a key if hash of tags given' do
|
66
|
-
cache.write('foo', object, :tags => {:baz => 1})
|
66
|
+
cache.write('foo', object, options.merge(:tags => {:baz => 1}))
|
67
67
|
assert_read 'foo', object
|
68
68
|
|
69
69
|
cache.delete_tag :baz => 2
|
@@ -77,7 +77,7 @@ describe Rails::Cache::Tags do
|
|
77
77
|
tag1 = 1.day.ago
|
78
78
|
tag2 = 2.days.ago
|
79
79
|
|
80
|
-
cache.write 'foo', object, :tags => [tag1, tag2]
|
80
|
+
cache.write 'foo', object, options.merge(:tags => [tag1, tag2])
|
81
81
|
assert_read 'foo', object
|
82
82
|
|
83
83
|
cache.delete_tag tag1
|
@@ -85,8 +85,8 @@ describe Rails::Cache::Tags do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'reads multiple keys with tags check' do
|
88
|
-
cache.write 'foo', object, :tags => :bar
|
89
|
-
cache.write 'bar', object, :tags => :baz
|
88
|
+
cache.write 'foo', object, options.merge(:tags => :bar)
|
89
|
+
cache.write 'bar', object, options.merge(:tags => :baz)
|
90
90
|
|
91
91
|
assert_read 'foo', object
|
92
92
|
assert_read 'bar', object
|
@@ -96,19 +96,19 @@ describe Rails::Cache::Tags do
|
|
96
96
|
assert_blank 'foo'
|
97
97
|
assert_read 'bar', object
|
98
98
|
|
99
|
-
expect(cache.read_multi('foo', 'bar')).to eq('foo' => nil, 'bar' => object)
|
99
|
+
expect(cache.read_multi('foo', 'bar', options)).to eq('foo' => nil, 'bar' => object)
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'fetches key with tag check' do
|
103
|
-
cache.write 'foo', object, :tags => :bar
|
103
|
+
cache.write 'foo', object, options.merge(:tags => :bar)
|
104
104
|
|
105
|
-
expect(cache.fetch('foo') { 'baz' }).to eq object
|
106
|
-
expect(cache.fetch('foo')).to eq object
|
105
|
+
expect(cache.fetch('foo', options) { 'baz' }).to eq object
|
106
|
+
expect(cache.fetch('foo', options)).to eq object
|
107
107
|
|
108
108
|
cache.delete_tag :bar
|
109
109
|
|
110
|
-
expect(cache.fetch('foo')).to be_nil
|
111
|
-
expect(cache.fetch('foo', :tags => :bar) { object }).to eq object
|
110
|
+
expect(cache.fetch('foo', options)).to be_nil
|
111
|
+
expect(cache.fetch('foo', options.merge(:tags => :bar)) { object }).to eq object
|
112
112
|
assert_read 'foo', object
|
113
113
|
|
114
114
|
cache.delete_tag :bar
|
@@ -124,28 +124,40 @@ describe Rails::Cache::Tags do
|
|
124
124
|
COMPLEX_OBJECT = ComplexObject.new('bar')
|
125
125
|
|
126
126
|
shared_examples 'cache with tags support' do |*tags|
|
127
|
-
|
128
|
-
|
129
|
-
|
127
|
+
shared_examples 'cache with tags support with options' do
|
128
|
+
context '', tags do
|
129
|
+
include_examples 'cache with tags support for', SCALAR_OBJECT
|
130
|
+
include_examples 'cache with tags support for', COMPLEX_OBJECT
|
131
|
+
|
132
|
+
# test everything with locale cache
|
133
|
+
include_examples 'cache with tags support for', SCALAR_OBJECT do
|
134
|
+
include ActiveSupport::Cache::Strategy::LocalCache
|
135
|
+
|
136
|
+
around(:each) do |example|
|
137
|
+
if cache.respond_to?(:with_local_cache)
|
138
|
+
cache.with_local_cache { example.run }
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
130
142
|
|
131
|
-
|
132
|
-
|
133
|
-
include ActiveSupport::Cache::Strategy::LocalCache
|
143
|
+
include_examples 'cache with tags support for', COMPLEX_OBJECT do
|
144
|
+
include ActiveSupport::Cache::Strategy::LocalCache
|
134
145
|
|
135
|
-
|
136
|
-
if cache.respond_to?(:with_local_cache)
|
146
|
+
around(:each) do |example|
|
137
147
|
cache.with_local_cache { example.run }
|
138
148
|
end
|
139
149
|
end
|
140
150
|
end
|
151
|
+
end
|
141
152
|
|
142
|
-
|
143
|
-
|
153
|
+
context "without namespace option" do
|
154
|
+
let(:options) { {} }
|
155
|
+
include_examples 'cache with tags support with options'
|
156
|
+
end
|
144
157
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
end
|
158
|
+
context "with namespace option" do
|
159
|
+
let(:options) { {namespace: 'namespace'} }
|
160
|
+
include_examples 'cache with tags support with options'
|
149
161
|
end
|
150
162
|
end
|
151
163
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-cache-tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexei Mikhailov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
version: '0'
|
185
185
|
requirements: []
|
186
186
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.4.3
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: Tagged caching support for Rails
|