double_write_cache_stores 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +60 -0
- data/.ruby-version +1 -0
- data/.travis.yml +19 -1
- data/Gemfile +1 -1
- data/README.md +13 -11
- data/activesupport.gemfile +7 -0
- data/activesupport.gemfile.lock +62 -0
- data/double_write_cache_stores.gemspec +7 -8
- data/lib/dalli_store_patch.rb +10 -9
- data/lib/double_write_cache_stores.rb +22 -2
- data/lib/double_write_cache_stores/client.rb +155 -179
- data/lib/double_write_cache_stores/version.rb +1 -1
- data/lib/mem_cache_store_patch.rb +48 -0
- data/spec/double_write_cache_stores/client_spec.rb +239 -140
- data/spec/double_write_cache_stores_spec.rb +2 -2
- data/spec/spec_helper.rb +8 -10
- metadata +24 -47
@@ -0,0 +1,48 @@
|
|
1
|
+
# monky patch
|
2
|
+
# support touch interface for ActiveSupport::Cache::MemCacheStore
|
3
|
+
module MemCacheStorePatch
|
4
|
+
def touch(name, ttl = nil)
|
5
|
+
key = namespaced_key(name, options)
|
6
|
+
ttl ||= options[:expires_in].to_i if options[:expires_in]
|
7
|
+
@data.touch(key, ttl)
|
8
|
+
rescue Dalli::DalliError => e
|
9
|
+
logger.error("DalliError (#{e}): #{e.message}") if logger
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def read_cas(name, options = nil)
|
14
|
+
options ||= {}
|
15
|
+
key = namespaced_key(name, options)
|
16
|
+
|
17
|
+
instrument(:get_cas, key) do |_payload|
|
18
|
+
@data.get_cas(key)
|
19
|
+
end
|
20
|
+
rescue Dalli::DalliError => e
|
21
|
+
logger.error("DalliError: #{e.message}") if logger
|
22
|
+
raise if raise_errors?
|
23
|
+
false
|
24
|
+
end
|
25
|
+
|
26
|
+
def write_cas(name, value, options = nil)
|
27
|
+
options ||= {}
|
28
|
+
key = namespaced_key(name, options)
|
29
|
+
expires_in = options[:expires_in]
|
30
|
+
|
31
|
+
instrument(:set_cas, key, value) do |_payload|
|
32
|
+
cas = options.delete(:cas) || 0
|
33
|
+
expires_in = options.delete(:expires_in)
|
34
|
+
@data.set_cas(key, value, cas, expires_in, options)
|
35
|
+
end
|
36
|
+
rescue Dalli::DalliError => e
|
37
|
+
logger.error("DalliError: #{e.message}") if logger
|
38
|
+
raise if raise_errors?
|
39
|
+
false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
begin
|
44
|
+
require "active_support/cache/mem_cache_store"
|
45
|
+
|
46
|
+
ActiveSupport::Cache::MemCacheStore.send(:include, MemCacheStorePatch)
|
47
|
+
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
48
|
+
end
|
@@ -1,293 +1,392 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
let :write_only_store do
|
9
|
-
ActiveSupport::Cache.lookup_store :dalli_store, 'localhost:21211'
|
3
|
+
def get_or_read(store, key)
|
4
|
+
if store.respond_to? :get
|
5
|
+
store.get key
|
6
|
+
else
|
7
|
+
store.read key
|
10
8
|
end
|
9
|
+
end
|
11
10
|
|
11
|
+
describe DoubleWriteCacheStores::Client do
|
12
12
|
describe '#initialize' do
|
13
|
-
|
14
|
-
|
13
|
+
let(:options) { { namespace: "app_v1", compress: true } }
|
14
|
+
it "different cache store instance" do
|
15
|
+
expect { DoubleWriteCacheStores::Client.new Dalli::Client.new("localhost:11211", options), "bad instance object" }.to raise_error RuntimeError
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
shared_examples "Equal values" do |cache_store, key, value|
|
20
|
+
let(:rw_store) { cache_store.read_and_write_store }
|
21
|
+
let(:rw_value) { get_or_read(rw_store, key) }
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
describe "Equal values" do
|
24
|
+
it "Read and Write cache store" do
|
25
|
+
expect(rw_value).to eq value
|
26
|
+
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
if w_store = cache_store.write_only_store
|
29
|
+
it "Write cache store" do
|
30
|
+
w_value = get_or_read(w_store, key)
|
31
|
+
expect(w_value).to eq value
|
32
|
+
end
|
33
|
+
|
34
|
+
it "RW == W cache store's values" do
|
35
|
+
w_value = get_or_read(w_store, key)
|
36
|
+
expect(rw_value).to eq w_value
|
37
|
+
end
|
38
|
+
end
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
36
42
|
shared_examples "cache store example" do |cache_store|
|
37
43
|
describe '#read_multi' do
|
38
44
|
before do
|
39
|
-
cache_store.write
|
40
|
-
cache_store.write
|
45
|
+
cache_store.write "key-a", "example-value-a", expires_in: 86400
|
46
|
+
cache_store.write "key-b", "example-value-b", expires_in: 86400
|
41
47
|
end
|
42
48
|
|
43
49
|
after { cache_store.flush }
|
44
50
|
|
45
|
-
it
|
46
|
-
results = cache_store.read_multi(
|
47
|
-
expect(results[
|
48
|
-
expect(results[
|
49
|
-
expect(results[
|
51
|
+
it "get multi-keys values from multi store" do
|
52
|
+
results = cache_store.read_multi("key-a", "key-b", "key-c")
|
53
|
+
expect(results["key-a"]).to eq "example-value-a"
|
54
|
+
expect(results["key-b"]).to eq "example-value-b"
|
55
|
+
expect(results["key-c"]).to eq nil
|
50
56
|
end
|
51
57
|
|
52
58
|
it 'returns values equal #get_multi' do
|
53
|
-
expect(cache_store.read_multi(
|
59
|
+
expect(cache_store.read_multi("key-a", "key-b")).to eq cache_store.get_multi("key-a", "key-b")
|
54
60
|
end
|
55
61
|
end
|
56
62
|
|
57
63
|
describe '#fetch' do
|
58
64
|
before do
|
59
|
-
cache_store.write
|
65
|
+
cache_store.write "key-a", "example-value-a", expires_in: 1
|
60
66
|
end
|
61
67
|
|
62
68
|
after { cache_store.flush }
|
63
69
|
|
64
|
-
it
|
65
|
-
expect(cache_store.fetch(
|
66
|
-
expect
|
70
|
+
it "returns value" do
|
71
|
+
expect(cache_store.fetch("key-a") { "faild-value" }).to eq "example-value-a"
|
72
|
+
expect { cache_store.fetch("error") }.to raise_error LocalJumpError
|
67
73
|
end
|
68
74
|
|
69
|
-
it
|
70
|
-
|
75
|
+
it "get value and set value, block in args" do
|
76
|
+
cache_store.fetch("key-b") do
|
77
|
+
"block-value-b"
|
78
|
+
end
|
79
|
+
|
80
|
+
expect(cache_store.fetch("key-b") { "faild-value" }).to eq "block-value-b"
|
81
|
+
expect(cache_store.get("key-b")).to eq "block-value-b"
|
71
82
|
|
72
|
-
cache_store.fetch(
|
73
|
-
|
83
|
+
cache_store.fetch("key-b") do
|
84
|
+
"not-overwrite-value"
|
74
85
|
end
|
86
|
+
expect(cache_store.fetch("key-b") { "faild-value" }).to eq "block-value-b"
|
87
|
+
expect(cache_store.get("key-b")).to eq "block-value-b"
|
75
88
|
|
76
|
-
|
77
|
-
|
89
|
+
cache_store.fetch("key-c", expires_in: 1) do
|
90
|
+
"c-value"
|
91
|
+
end
|
92
|
+
expect(cache_store.fetch("key-c") { "faild-value" }).to eq "c-value"
|
93
|
+
sleep 2
|
94
|
+
expect(cache_store.get("key-c")).to be_nil
|
95
|
+
end
|
78
96
|
|
79
|
-
|
80
|
-
|
97
|
+
it "Support force read option, convertible Rails.cache" do
|
98
|
+
cache_store.fetch("key-c") do
|
99
|
+
"block-value-c"
|
81
100
|
end
|
82
|
-
|
83
|
-
expect(cache_store.
|
101
|
+
|
102
|
+
expect(cache_store.fetch("key-c") { "faild-value" }).to eq "block-value-c"
|
103
|
+
|
104
|
+
new_value = cache_store.fetch("key-c", force: true) do
|
105
|
+
"block-value-c-force"
|
106
|
+
end
|
107
|
+
|
108
|
+
expect(new_value).to eq "block-value-c-force"
|
109
|
+
expect(cache_store.fetch("key-c") { "faild-value" }).to eq "block-value-c-force"
|
84
110
|
end
|
85
111
|
end
|
86
112
|
|
87
113
|
describe '#delete' do
|
88
114
|
before do
|
89
|
-
|
115
|
+
cache_store.write "will-delete-key", "example-will-delete-value", expires_in: 86400
|
116
|
+
expect(cache_store.delete "will-delete-key").to be true
|
90
117
|
end
|
91
|
-
it 'delete key-value' do
|
92
|
-
expect(read_and_write_store.read 'will-delete-key').to eq 'example-will-delete-value'
|
93
|
-
expect(write_only_store.read 'will-delete-key').to eq 'example-will-delete-value'
|
94
118
|
|
95
|
-
|
96
|
-
|
97
|
-
expect(read_and_write_store.read 'will-delete-key').to be_nil
|
98
|
-
expect(write_only_store.read 'will-delete-key').to be_nil
|
119
|
+
it "delete key-value" do
|
120
|
+
expect(cache_store.read "will-delete-key").to be_nil
|
99
121
|
end
|
122
|
+
|
123
|
+
it_behaves_like "Equal values", cache_store, "will-delete-key", nil
|
100
124
|
end
|
101
125
|
|
102
126
|
describe '#touch' do
|
103
127
|
let(:expire_ttl) { 1 }
|
104
128
|
|
105
129
|
before do
|
106
|
-
cache_store.set
|
130
|
+
cache_store.set "touch-key", "touch-value", expires_in: expire_ttl
|
107
131
|
end
|
108
132
|
|
109
|
-
it
|
133
|
+
it "expired value, not touched" do
|
110
134
|
sleep expire_ttl
|
111
|
-
expect(cache_store.read
|
135
|
+
expect(cache_store.read "touch-key").to eq nil
|
112
136
|
end
|
113
137
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
138
|
+
if ENV["TRAVIS"]
|
139
|
+
skip "FIXME: faild spec in only travis-ci"
|
140
|
+
else
|
141
|
+
it "expired value, touched expired" do
|
142
|
+
expect(cache_store.touch "touch-key", expire_ttl).to be true
|
143
|
+
sleep expire_ttl
|
144
|
+
expect(cache_store.read "touch-key").to eq nil
|
145
|
+
end
|
118
146
|
end
|
119
147
|
|
120
|
-
it
|
121
|
-
expect(cache_store.touch
|
148
|
+
it "returns value, before touched key" do
|
149
|
+
expect(cache_store.touch "touch-key").to be true
|
122
150
|
sleep expire_ttl
|
123
|
-
expect(cache_store.read
|
151
|
+
expect(cache_store.read "touch-key").to eq "touch-value"
|
124
152
|
end
|
125
153
|
end
|
126
154
|
|
155
|
+
describe '#write' do
|
156
|
+
before do
|
157
|
+
cache_store.write "key", "example-write-value", expires_in: 86400
|
158
|
+
end
|
159
|
+
|
160
|
+
it "returns writed value" do
|
161
|
+
expect(cache_store.read "key").to eq "example-write-value"
|
162
|
+
end
|
163
|
+
|
164
|
+
it_behaves_like "Equal values", cache_store, "key", "example-write-value"
|
165
|
+
end
|
166
|
+
|
127
167
|
describe '#read' do
|
128
168
|
before do
|
129
|
-
cache_store.write
|
169
|
+
cache_store.write "key", "example-read-value", expires_in: 86400
|
130
170
|
end
|
131
|
-
|
132
|
-
|
171
|
+
|
172
|
+
it "returns writed value" do
|
173
|
+
expect(cache_store.read "key").to eq "example-read-value"
|
133
174
|
end
|
134
|
-
|
135
|
-
|
175
|
+
|
176
|
+
it "returns nil, not writed value" do
|
177
|
+
expect(cache_store.read "not-set-key").to eq nil
|
136
178
|
end
|
137
179
|
end
|
138
180
|
|
139
181
|
describe '#flush' do
|
140
182
|
before do
|
141
|
-
|
183
|
+
cache_store.write "will-flush-key", "will-flush-value", expires_in: 86400
|
184
|
+
expect(cache_store.read "will-flush-key").to eq "will-flush-value"
|
185
|
+
expect(cache_store.flush).to eq true
|
142
186
|
end
|
143
|
-
|
144
|
-
|
145
|
-
expect(
|
146
|
-
expect(copy_cache_store.read 'will-flush-key').to eq nil
|
187
|
+
|
188
|
+
it "retuns nil" do
|
189
|
+
expect(cache_store.read "will-flush-key").to eq nil
|
147
190
|
end
|
191
|
+
|
192
|
+
it_behaves_like "Equal values", cache_store, "will-flush-key", nil
|
148
193
|
end
|
149
194
|
|
150
|
-
shared_examples
|
195
|
+
shared_examples "read cache after increment or decrement example" do
|
151
196
|
before { cache_store.set(key, 10, raw: true) }
|
152
197
|
it { expect((cache_store.read key).to_i).to eq expected_value }
|
153
198
|
end
|
154
199
|
|
155
200
|
describe '#increment' do
|
156
|
-
let(:key) {
|
201
|
+
let(:key) { "key-increment" }
|
157
202
|
after { cache_store.flush }
|
158
203
|
|
159
|
-
it_behaves_like
|
204
|
+
it_behaves_like "read cache after increment or decrement example" do
|
160
205
|
let!(:expected_value) { cache_store.increment key }
|
161
206
|
end
|
162
207
|
|
163
|
-
context
|
164
|
-
context
|
208
|
+
context "when options[:initial] does not exist" do
|
209
|
+
context "when value exists" do
|
165
210
|
before { cache_store.set(key, 0, raw: true) }
|
166
|
-
context
|
211
|
+
context "when amount does not exist" do
|
167
212
|
it { expect(cache_store.increment key).to eq 1 }
|
213
|
+
|
214
|
+
context "incremented value in cache stores" do
|
215
|
+
before { cache_store.increment key }
|
216
|
+
it_behaves_like("Equal values", cache_store, "key-increment", "1")
|
217
|
+
end
|
168
218
|
end
|
169
|
-
context
|
219
|
+
context "when amount exists" do
|
170
220
|
it { expect(cache_store.increment key, 2).to eq 2 }
|
171
221
|
end
|
172
222
|
end
|
173
|
-
context
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
223
|
+
context "when value does not exist" do
|
224
|
+
if DoubleWriteCacheStores.loaded_active_support? && cache_store.read_and_write_store.is_a?(ActiveSupport::Cache::MemCacheStore)
|
225
|
+
skip "Not support"
|
226
|
+
else
|
227
|
+
context "when amount does not exist" do
|
228
|
+
it { expect(cache_store.increment key).to eq 1 }
|
229
|
+
end
|
230
|
+
context "when amount exists" do
|
231
|
+
it { expect(cache_store.increment key, 2).to eq 2 }
|
232
|
+
end
|
179
233
|
end
|
180
234
|
end
|
181
235
|
end
|
182
236
|
|
183
|
-
context
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
237
|
+
context "when options[:initial] exists" do
|
238
|
+
if DoubleWriteCacheStores.loaded_active_support? && cache_store.read_and_write_store.is_a?(ActiveSupport::Cache::MemCacheStore)
|
239
|
+
skip "Not support"
|
240
|
+
else
|
241
|
+
let(:opt) { { initial: 12_345_678 } }
|
242
|
+
context "when value exists" do
|
243
|
+
before { cache_store.set(key, 0, raw: true) }
|
244
|
+
it { expect(cache_store.increment key, 1, opt).to eq 1 }
|
245
|
+
end
|
246
|
+
context "when value does not exist" do
|
247
|
+
it { expect(cache_store.increment key, 1, opt).to eq opt[:initial] }
|
248
|
+
end
|
191
249
|
end
|
192
250
|
end
|
193
251
|
end
|
194
252
|
|
195
253
|
describe '#decrement' do
|
196
|
-
let(:key) {
|
254
|
+
let(:key) { "key-decrement" }
|
197
255
|
after { cache_store.flush }
|
198
256
|
|
199
|
-
it_behaves_like
|
257
|
+
it_behaves_like "read cache after increment or decrement example" do
|
200
258
|
let!(:expected_value) { cache_store.decrement key }
|
201
259
|
end
|
202
260
|
|
203
|
-
context
|
204
|
-
context
|
261
|
+
context "when options[:initial] does not exist" do
|
262
|
+
context "when value exists" do
|
205
263
|
before { cache_store.set(key, 101, raw: true) }
|
206
|
-
context
|
264
|
+
context "when amount does not exist" do
|
207
265
|
it { expect(cache_store.decrement key).to eq 100 }
|
266
|
+
|
267
|
+
context "decremented value in cache stores" do
|
268
|
+
before { cache_store.decrement key }
|
269
|
+
it_behaves_like("Equal values", cache_store, "key-decrement", "100")
|
270
|
+
end
|
208
271
|
end
|
209
|
-
context
|
272
|
+
context "when amount exists" do
|
210
273
|
it { expect(cache_store.decrement key, 2).to eq 99 }
|
211
274
|
end
|
212
275
|
end
|
213
|
-
context
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
276
|
+
context "when value does not exist" do
|
277
|
+
if DoubleWriteCacheStores.loaded_active_support? && cache_store.read_and_write_store.is_a?(ActiveSupport::Cache::MemCacheStore)
|
278
|
+
skip "Not support"
|
279
|
+
else
|
280
|
+
context "when amount does not exist" do
|
281
|
+
it { expect(cache_store.decrement key).to eq 0 }
|
282
|
+
end
|
283
|
+
context "when amount exists" do
|
284
|
+
it { expect(cache_store.decrement key, 2).to eq 0 }
|
285
|
+
end
|
219
286
|
end
|
220
287
|
end
|
221
288
|
end
|
222
289
|
|
223
|
-
context
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
290
|
+
context "when options[:initial] exists" do
|
291
|
+
if DoubleWriteCacheStores.loaded_active_support? && cache_store.read_and_write_store.is_a?(ActiveSupport::Cache::MemCacheStore)
|
292
|
+
skip "Not support"
|
293
|
+
else
|
294
|
+
let(:opt) { { initial: 12_345_678 } }
|
295
|
+
context "when value exists" do
|
296
|
+
before { cache_store.set(key, 101, raw: true) }
|
297
|
+
it { expect(cache_store.decrement key, 1, opt).to eq 100 }
|
298
|
+
end
|
299
|
+
context "when value does not exist" do
|
300
|
+
it { expect(cache_store.decrement key, 1, opt).to eq opt[:initial] }
|
301
|
+
end
|
231
302
|
end
|
232
303
|
end
|
233
304
|
end
|
234
305
|
|
235
306
|
describe '#[]=(key,value) and get #[](key)' do
|
236
|
-
it
|
237
|
-
cache_store[
|
238
|
-
expect(cache_store[
|
307
|
+
it "set value and get value" do
|
308
|
+
cache_store["key"] = "example-value"
|
309
|
+
expect(cache_store["key"]).to eq "example-value"
|
310
|
+
end
|
311
|
+
|
312
|
+
context "seted value in cache stores" do
|
313
|
+
before { cache_store["key"] = "value" }
|
314
|
+
it_behaves_like("Equal values", cache_store, "key", "value")
|
239
315
|
end
|
240
316
|
end
|
241
317
|
|
242
|
-
describe
|
318
|
+
describe "cas" do
|
243
319
|
describe '#get_cas' do
|
244
320
|
before do
|
245
|
-
cache_store.set_cas
|
321
|
+
cache_store.set_cas "get-cas-key", "get-cas-value"
|
246
322
|
end
|
247
323
|
|
248
|
-
it
|
249
|
-
expect(cache_store.get_cas(
|
250
|
-
expect(cache_store.get_cas(
|
324
|
+
it "example" do
|
325
|
+
expect(cache_store.get_cas("get-cas-key")[0]).to eq "get-cas-value"
|
326
|
+
expect(cache_store.get_cas("get-cas-key")[1]).to be_kind_of(Integer)
|
251
327
|
end
|
328
|
+
|
329
|
+
it_behaves_like("Equal values", cache_store, "get-cas-key", "get-cas-value")
|
252
330
|
end
|
253
331
|
|
254
332
|
describe '#set_cas' do
|
255
333
|
let :cas_unique do
|
256
|
-
cache_store.set_cas(
|
257
|
-
cache_store.get_cas(
|
334
|
+
cache_store.set_cas("set-cas-key", "set-cas-value")
|
335
|
+
cache_store.get_cas("set-cas-key")[1]
|
258
336
|
end
|
259
337
|
|
260
|
-
it
|
261
|
-
expect(cache_store.set_cas(
|
338
|
+
it "example" do
|
339
|
+
expect(cache_store.set_cas("set-cas-key", "set-cas-value", cas_unique)).to be_kind_of(Integer)
|
262
340
|
end
|
263
341
|
|
264
|
-
it
|
265
|
-
expect(cache_store.set_cas(
|
342
|
+
it "returns false, not set cache because different cas_unique" do
|
343
|
+
expect(cache_store.set_cas("set-cas-key", "set-cas-value", cas_unique - 1)).to eq false
|
266
344
|
end
|
267
345
|
end
|
268
346
|
end
|
269
347
|
end
|
270
348
|
|
271
349
|
describe "shard example" do
|
272
|
-
|
273
|
-
|
274
|
-
|
350
|
+
if DoubleWriteCacheStores.loaded_active_support?
|
351
|
+
context "ActiveSupport MemCacheStore" do
|
352
|
+
options = { raw: true, expires_in: 3600 }
|
275
353
|
|
276
|
-
|
277
|
-
|
278
|
-
|
354
|
+
read_and_write_store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost:11211", options
|
355
|
+
write_only_store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost:21211", options
|
356
|
+
|
357
|
+
context "double cache store" do
|
358
|
+
copy_cache_store = DoubleWriteCacheStores::Client.new(read_and_write_store, write_only_store)
|
359
|
+
it_behaves_like "cache store example", copy_cache_store
|
360
|
+
end
|
361
|
+
|
362
|
+
context "one cache store object" do
|
363
|
+
one_cache_store = DoubleWriteCacheStores::Client.new(read_and_write_store, nil)
|
364
|
+
it_behaves_like "cache store example", one_cache_store
|
365
|
+
end
|
279
366
|
end
|
280
367
|
|
281
|
-
context "
|
282
|
-
|
283
|
-
|
368
|
+
context "ActiveSupport :dalli_store in Dalli" do
|
369
|
+
read_and_write_store = ActiveSupport::Cache.lookup_store :dalli_store, "localhost:11211"
|
370
|
+
write_only_store = ActiveSupport::Cache.lookup_store :dalli_store, "localhost:21211"
|
371
|
+
|
372
|
+
context "double cache store" do
|
373
|
+
copy_cache_store = DoubleWriteCacheStores::Client.new(read_and_write_store, write_only_store)
|
374
|
+
it_behaves_like "cache store example", copy_cache_store
|
375
|
+
end
|
376
|
+
|
377
|
+
context "one cache store object" do
|
378
|
+
one_cache_store = DoubleWriteCacheStores::Client.new(read_and_write_store, nil)
|
379
|
+
it_behaves_like "cache store example", one_cache_store
|
380
|
+
end
|
284
381
|
end
|
382
|
+
else
|
383
|
+
skip "Not load ActiveSupport"
|
285
384
|
end
|
286
385
|
|
287
386
|
context "Dalli::Client" do
|
288
|
-
options = { :
|
289
|
-
read_and_write_store = Dalli::Client.new(
|
290
|
-
write_only_store = Dalli::Client.new(
|
387
|
+
options = { namespace: "app_v1", compress: true }
|
388
|
+
read_and_write_store = Dalli::Client.new("localhost:11211", options)
|
389
|
+
write_only_store = Dalli::Client.new("localhost:21211", options)
|
291
390
|
|
292
391
|
context "double cache store" do
|
293
392
|
copy_cache_store = DoubleWriteCacheStores::Client.new(read_and_write_store, write_only_store)
|