juno 0.2.3 → 0.2.4
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.
- data/.travis.yml +2 -4
- data/Gemfile +3 -1
- data/README.md +40 -8
- data/benchmarks/run.rb +17 -5
- data/lib/juno/adapters/activerecord.rb +23 -14
- data/lib/juno/adapters/cassandra.rb +11 -0
- data/lib/juno/adapters/couch.rb +9 -0
- data/lib/juno/adapters/datamapper.rb +10 -0
- data/lib/juno/adapters/dbm.rb +8 -0
- data/lib/juno/adapters/file.rb +2 -0
- data/lib/juno/adapters/fog.rb +9 -0
- data/lib/juno/adapters/gdbm.rb +8 -0
- data/lib/juno/adapters/localmemcache.rb +8 -0
- data/lib/juno/adapters/lruhash.rb +8 -0
- data/lib/juno/adapters/memcached_dalli.rb +9 -0
- data/lib/juno/adapters/memcached_native.rb +10 -0
- data/lib/juno/adapters/memory.rb +2 -0
- data/lib/juno/adapters/mongo.rb +11 -0
- data/lib/juno/adapters/null.rb +2 -0
- data/lib/juno/adapters/pstore.rb +9 -2
- data/lib/juno/adapters/redis.rb +5 -0
- data/lib/juno/adapters/riak.rb +9 -0
- data/lib/juno/adapters/sdbm.rb +8 -0
- data/lib/juno/adapters/sequel.rb +10 -0
- data/lib/juno/adapters/sqlite.rb +9 -0
- data/lib/juno/adapters/tokyocabinet.rb +16 -4
- data/lib/juno/adapters/yaml.rb +2 -0
- data/lib/juno/base.rb +1 -0
- data/lib/juno/builder.rb +2 -0
- data/lib/juno/cache.rb +2 -0
- data/lib/juno/expires.rb +1 -0
- data/lib/juno/lock.rb +37 -0
- data/lib/juno/proxy.rb +1 -0
- data/lib/juno/stack.rb +2 -0
- data/lib/juno/transformer.rb +16 -4
- data/lib/juno/version.rb +3 -1
- data/lib/juno.rb +33 -2
- data/spec/adapter_activerecord_spec.rb +20 -34
- data/spec/adapter_cassandra_spec.rb +9 -23
- data/spec/adapter_couch_spec.rb +9 -23
- data/spec/adapter_datamapper_spec.rb +36 -50
- data/spec/adapter_dbm_spec.rb +9 -23
- data/spec/adapter_file_spec.rb +9 -23
- data/spec/adapter_fog_spec.rb +12 -29
- data/spec/adapter_gdbm_spec.rb +9 -23
- data/spec/adapter_localmemcache_spec.rb +9 -23
- data/spec/adapter_lruhash_spec.rb +24 -38
- data/spec/adapter_memcached_dalli_spec.rb +10 -24
- data/spec/adapter_memcached_native_spec.rb +10 -24
- data/spec/adapter_memcached_spec.rb +10 -24
- data/spec/adapter_memory_spec.rb +24 -38
- data/spec/adapter_mongo_spec.rb +9 -23
- data/spec/adapter_pstore_spec.rb +12 -26
- data/spec/adapter_redis_spec.rb +10 -24
- data/spec/adapter_riak_spec.rb +9 -23
- data/spec/adapter_sdbm_spec.rb +9 -23
- data/spec/adapter_sequel_spec.rb +9 -23
- data/spec/adapter_sqlite_spec.rb +9 -23
- data/spec/adapter_tokyocabinet_bdb_spec.rb +13 -0
- data/spec/adapter_tokyocabinet_hdb_spec.rb +13 -0
- data/spec/adapter_yaml_spec.rb +12 -26
- data/spec/cache_file_memory_spec.rb +22 -43
- data/spec/cache_memory_null_spec.rb +13 -34
- data/spec/expires_file_spec.rb +56 -76
- data/spec/expires_memory_spec.rb +35 -54
- data/spec/generate.rb +147 -160
- data/spec/helper.rb +39 -0
- data/spec/junospecs.rb +612 -610
- data/spec/lock_spec.rb +31 -0
- data/spec/null_adapter_spec.rb +15 -29
- data/spec/proxy_expires_memory_spec.rb +37 -58
- data/spec/proxy_redis_spec.rb +13 -33
- data/spec/simple_activerecord_spec.rb +34 -48
- data/spec/simple_activerecord_with_expires_spec.rb +35 -49
- data/spec/simple_cassandra_spec.rb +35 -49
- data/spec/simple_couch_spec.rb +34 -48
- data/spec/simple_couch_with_expires_spec.rb +35 -49
- data/spec/simple_datamapper_spec.rb +34 -48
- data/spec/simple_datamapper_with_expires_spec.rb +35 -49
- data/spec/simple_datamapper_with_repository_spec.rb +34 -48
- data/spec/simple_dbm_spec.rb +34 -48
- data/spec/simple_dbm_with_expires_spec.rb +35 -49
- data/spec/simple_file_spec.rb +34 -48
- data/spec/simple_file_with_expires_spec.rb +35 -49
- data/spec/simple_fog_spec.rb +37 -54
- data/spec/simple_fog_with_expires_spec.rb +39 -57
- data/spec/simple_gdbm_spec.rb +34 -48
- data/spec/simple_gdbm_with_expires_spec.rb +35 -49
- data/spec/simple_hashfile_spec.rb +34 -48
- data/spec/simple_hashfile_with_expires_spec.rb +35 -49
- data/spec/simple_localmemcache_spec.rb +34 -48
- data/spec/simple_localmemcache_with_expires_spec.rb +35 -49
- data/spec/simple_lruhash_spec.rb +34 -48
- data/spec/simple_lruhash_with_expires_spec.rb +35 -49
- data/spec/simple_memcached_dalli_spec.rb +35 -49
- data/spec/simple_memcached_native_spec.rb +35 -49
- data/spec/simple_memcached_spec.rb +35 -49
- data/spec/simple_memory_spec.rb +34 -48
- data/spec/simple_memory_with_expires_spec.rb +35 -49
- data/spec/simple_mongo_spec.rb +34 -48
- data/spec/simple_mongo_with_expires_spec.rb +35 -49
- data/spec/simple_null_spec.rb +25 -39
- data/spec/simple_pstore_spec.rb +34 -48
- data/spec/simple_pstore_with_expires_spec.rb +35 -49
- data/spec/simple_redis_spec.rb +35 -49
- data/spec/simple_riak_spec.rb +34 -48
- data/spec/simple_riak_with_expires_spec.rb +35 -49
- data/spec/simple_sdbm_spec.rb +34 -48
- data/spec/simple_sdbm_with_expires_spec.rb +35 -49
- data/spec/simple_sequel_spec.rb +34 -48
- data/spec/simple_sequel_with_expires_spec.rb +35 -49
- data/spec/simple_sqlite_spec.rb +34 -48
- data/spec/simple_sqlite_with_expires_spec.rb +35 -49
- data/spec/simple_tokyocabinet_spec.rb +34 -48
- data/spec/simple_tokyocabinet_with_expires_spec.rb +35 -49
- data/spec/simple_yaml_spec.rb +34 -48
- data/spec/simple_yaml_with_expires_spec.rb +35 -49
- data/spec/stack_file_memory_spec.rb +15 -38
- data/spec/stack_memory_file_spec.rb +14 -37
- data/spec/transformer_bson_spec.rb +20 -39
- data/spec/transformer_compress_spec.rb +17 -36
- data/spec/transformer_json_spec.rb +20 -39
- data/spec/transformer_marshal_base64_spec.rb +36 -55
- data/spec/transformer_marshal_escape_spec.rb +36 -55
- data/spec/transformer_marshal_md5_spec.rb +36 -55
- data/spec/transformer_marshal_md5_spread_spec.rb +36 -55
- data/spec/transformer_msgpack_spec.rb +20 -39
- data/spec/transformer_ox_spec.rb +40 -0
- data/spec/transformer_yaml_spec.rb +35 -54
- metadata +11 -6
- data/spec/adapter_tokyocabinet_spec.rb +0 -27
- data/spec/simpl_memory_with_expires_spec.rb +0 -53
data/spec/junospecs.rb
CHANGED
|
@@ -1,52 +1,54 @@
|
|
|
1
|
+
# Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
|
|
2
|
+
|
|
1
3
|
#################### null_stringkey_stringvalue ####################
|
|
2
4
|
|
|
3
5
|
shared_examples_for 'null_stringkey_stringvalue' do
|
|
4
6
|
it "reads from keys that are Strings like a Hash" do
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
store["strkey1"].should == nil
|
|
8
|
+
store.load("strkey1").should == nil
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
it "guarantees that the same String value is returned when setting a String key" do
|
|
10
12
|
value = "strval1"
|
|
11
|
-
(
|
|
13
|
+
(store["strkey1"] = value).should equal(value)
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
it "returns false from key? if a String key is not available" do
|
|
15
|
-
|
|
17
|
+
store.key?("strkey1").should == false
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
it "returns nil from delete if an element for a String key does not exist" do
|
|
19
|
-
|
|
21
|
+
store.delete("strkey1").should == nil
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
it "removes all String keys from the store with clear" do
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
store["strkey1"] = "strval1"
|
|
26
|
+
store["strkey2"] = "strval2"
|
|
27
|
+
store.clear.should equal(store)
|
|
28
|
+
store.key?("strkey1").should_not == true
|
|
29
|
+
store.key?("strkey2").should_not == true
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
it "fetches a String key with a default value with fetch, if the key is not available" do
|
|
31
|
-
|
|
33
|
+
store.fetch("strkey1", "strval1").should == "strval1"
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
it "fetches a String key with a block with fetch, if the key is not available" do
|
|
35
37
|
key = "strkey1"
|
|
36
38
|
value = "strval1"
|
|
37
|
-
|
|
39
|
+
store.fetch(key) do |k|
|
|
38
40
|
k.should equal(key)
|
|
39
41
|
value
|
|
40
42
|
end.should equal(value)
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
it 'should accept options' do
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
store.key?("strkey1", :option1 => 1).should == false
|
|
47
|
+
store.load("strkey1", :option2 => 2).should == nil
|
|
48
|
+
store.fetch("strkey1", nil, :option3 => 3).should == nil
|
|
49
|
+
store.delete("strkey1", :option4 => 4).should == nil
|
|
50
|
+
store.clear(:option5 => 5).should equal(store)
|
|
51
|
+
store.store("strkey1", "strval1", :option6 => 6).should == "strval1"
|
|
50
52
|
end
|
|
51
53
|
end
|
|
52
54
|
|
|
@@ -54,46 +56,46 @@ end
|
|
|
54
56
|
|
|
55
57
|
shared_examples_for 'store_stringkey_stringvalue' do
|
|
56
58
|
it "writes String values to keys that are Strings like a Hash" do
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
store["strkey1"] = "strval1"
|
|
60
|
+
store["strkey1"].should == "strval1"
|
|
61
|
+
store.load("strkey1").should == "strval1"
|
|
60
62
|
end
|
|
61
63
|
|
|
62
64
|
it "returns true from key? if a String key is available" do
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
store["strkey1"] = "strval1"
|
|
66
|
+
store.key?("strkey1").should == true
|
|
65
67
|
end
|
|
66
68
|
|
|
67
69
|
it "stores String values with String keys with #store" do
|
|
68
70
|
value = "strval1"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
store.store("strkey1", value).should equal(value)
|
|
72
|
+
store["strkey1"].should == "strval1"
|
|
73
|
+
store.load("strkey1").should == "strval1"
|
|
72
74
|
end
|
|
73
75
|
|
|
74
76
|
it "removes and returns a String element with a String key from the backing store via delete if it exists" do
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
store["strkey1"] = "strval1"
|
|
78
|
+
store.delete("strkey1").should == "strval1"
|
|
79
|
+
store.key?("strkey1").should == false
|
|
78
80
|
end
|
|
79
81
|
|
|
80
82
|
it "overwrites existing String values with String" do
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
store["strkey1"] = "strval1"
|
|
84
|
+
store["strkey1"].should == "strval1"
|
|
85
|
+
store["strkey1"] = "strval2"
|
|
86
|
+
store["strkey1"].should == "strval2"
|
|
85
87
|
end
|
|
86
88
|
|
|
87
89
|
it "does not run the block if the String key is available" do
|
|
88
|
-
|
|
90
|
+
store["strkey1"] = "strval1"
|
|
89
91
|
unaltered = "unaltered"
|
|
90
|
-
|
|
92
|
+
store.fetch("strkey1") { unaltered = "altered" }
|
|
91
93
|
unaltered.should == "unaltered"
|
|
92
94
|
end
|
|
93
95
|
|
|
94
96
|
it "fetches a String key with a default value with fetch, if the key is available" do
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
store["strkey1"] = "strval1"
|
|
98
|
+
store.fetch("strkey1", "strval2").should == "strval1"
|
|
97
99
|
end
|
|
98
100
|
end
|
|
99
101
|
|
|
@@ -102,8 +104,8 @@ end
|
|
|
102
104
|
shared_examples_for 'returndifferent_stringkey_stringvalue' do
|
|
103
105
|
it "guarantees that a different String value is retrieved from the String key" do
|
|
104
106
|
value = "strval1"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
store["strkey1"] = "strval1"
|
|
108
|
+
store["strkey1"].should_not be_equal("strval1")
|
|
107
109
|
end
|
|
108
110
|
end
|
|
109
111
|
|
|
@@ -111,63 +113,63 @@ end
|
|
|
111
113
|
|
|
112
114
|
shared_examples_for 'expires_stringkey_stringvalue' do
|
|
113
115
|
it 'should support expires on store and #[]' do
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
store.store("strkey1", "strval1", :expires => 2)
|
|
117
|
+
store["strkey1"].should == "strval1"
|
|
116
118
|
sleep 1
|
|
117
|
-
|
|
119
|
+
store["strkey1"].should == "strval1"
|
|
118
120
|
sleep 2
|
|
119
|
-
|
|
121
|
+
store["strkey1"].should == nil
|
|
120
122
|
end
|
|
121
123
|
|
|
122
124
|
it 'should support expires on store and load' do
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
store.store("strkey1", "strval1", :expires => 2)
|
|
126
|
+
store.load("strkey1").should == "strval1"
|
|
125
127
|
sleep 1
|
|
126
|
-
|
|
128
|
+
store.load("strkey1").should == "strval1"
|
|
127
129
|
sleep 2
|
|
128
|
-
|
|
130
|
+
store.load("strkey1").should == nil
|
|
129
131
|
end
|
|
130
132
|
|
|
131
133
|
it 'should support expires on store and key?' do
|
|
132
|
-
|
|
133
|
-
|
|
134
|
+
store.store("strkey1", "strval1", :expires => 2)
|
|
135
|
+
store.key?("strkey1").should == true
|
|
134
136
|
sleep 1
|
|
135
|
-
|
|
137
|
+
store.key?("strkey1").should == true
|
|
136
138
|
sleep 2
|
|
137
|
-
|
|
139
|
+
store.key?("strkey1").should == false
|
|
138
140
|
end
|
|
139
141
|
|
|
140
142
|
it 'should support updating the expiration time in load' do
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
store.store("strkey2", "strval2", :expires => 2)
|
|
144
|
+
store["strkey2"].should == "strval2"
|
|
143
145
|
sleep 1
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
store.load("strkey2", :expires => 3).should == "strval2"
|
|
147
|
+
store["strkey2"].should == "strval2"
|
|
146
148
|
sleep 1
|
|
147
|
-
|
|
149
|
+
store["strkey2"].should == "strval2"
|
|
148
150
|
sleep 3
|
|
149
|
-
|
|
151
|
+
store["strkey2"].should == nil
|
|
150
152
|
end
|
|
151
153
|
|
|
152
154
|
it 'should support updating the expiration time in fetch' do
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
store.store("strkey1", "strval1", :expires => 2)
|
|
156
|
+
store["strkey1"].should == "strval1"
|
|
155
157
|
sleep 1
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
store.fetch("strkey1", nil, :expires => 3).should == "strval1"
|
|
159
|
+
store["strkey1"].should == "strval1"
|
|
158
160
|
sleep 1
|
|
159
|
-
|
|
161
|
+
store["strkey1"].should == "strval1"
|
|
160
162
|
sleep 3
|
|
161
|
-
|
|
163
|
+
store["strkey1"].should == nil
|
|
162
164
|
end
|
|
163
165
|
|
|
164
166
|
it 'should respect expires in delete' do
|
|
165
|
-
|
|
166
|
-
|
|
167
|
+
store.store("strkey2", "strval2", :expires => 2)
|
|
168
|
+
store["strkey2"].should == "strval2"
|
|
167
169
|
sleep 1
|
|
168
|
-
|
|
170
|
+
store["strkey2"].should == "strval2"
|
|
169
171
|
sleep 2
|
|
170
|
-
|
|
172
|
+
store.delete("strkey2").should == nil
|
|
171
173
|
end
|
|
172
174
|
end
|
|
173
175
|
|
|
@@ -175,51 +177,51 @@ end
|
|
|
175
177
|
|
|
176
178
|
shared_examples_for 'null_stringkey_objectvalue' do
|
|
177
179
|
it "reads from keys that are Strings like a Hash" do
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
store["strkey1"].should == nil
|
|
181
|
+
store.load("strkey1").should == nil
|
|
180
182
|
end
|
|
181
183
|
|
|
182
184
|
it "guarantees that the same Object value is returned when setting a String key" do
|
|
183
185
|
value = Value.new(:objval1)
|
|
184
|
-
(
|
|
186
|
+
(store["strkey1"] = value).should equal(value)
|
|
185
187
|
end
|
|
186
188
|
|
|
187
189
|
it "returns false from key? if a String key is not available" do
|
|
188
|
-
|
|
190
|
+
store.key?("strkey1").should == false
|
|
189
191
|
end
|
|
190
192
|
|
|
191
193
|
it "returns nil from delete if an element for a String key does not exist" do
|
|
192
|
-
|
|
194
|
+
store.delete("strkey1").should == nil
|
|
193
195
|
end
|
|
194
196
|
|
|
195
197
|
it "removes all String keys from the store with clear" do
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
store["strkey1"] = Value.new(:objval1)
|
|
199
|
+
store["strkey2"] = Value.new(:objval2)
|
|
200
|
+
store.clear.should equal(store)
|
|
201
|
+
store.key?("strkey1").should_not == true
|
|
202
|
+
store.key?("strkey2").should_not == true
|
|
201
203
|
end
|
|
202
204
|
|
|
203
205
|
it "fetches a String key with a default value with fetch, if the key is not available" do
|
|
204
|
-
|
|
206
|
+
store.fetch("strkey1", Value.new(:objval1)).should == Value.new(:objval1)
|
|
205
207
|
end
|
|
206
208
|
|
|
207
209
|
it "fetches a String key with a block with fetch, if the key is not available" do
|
|
208
210
|
key = "strkey1"
|
|
209
211
|
value = Value.new(:objval1)
|
|
210
|
-
|
|
212
|
+
store.fetch(key) do |k|
|
|
211
213
|
k.should equal(key)
|
|
212
214
|
value
|
|
213
215
|
end.should equal(value)
|
|
214
216
|
end
|
|
215
217
|
|
|
216
218
|
it 'should accept options' do
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
store.key?("strkey1", :option1 => 1).should == false
|
|
220
|
+
store.load("strkey1", :option2 => 2).should == nil
|
|
221
|
+
store.fetch("strkey1", nil, :option3 => 3).should == nil
|
|
222
|
+
store.delete("strkey1", :option4 => 4).should == nil
|
|
223
|
+
store.clear(:option5 => 5).should equal(store)
|
|
224
|
+
store.store("strkey1", Value.new(:objval1), :option6 => 6).should == Value.new(:objval1)
|
|
223
225
|
end
|
|
224
226
|
end
|
|
225
227
|
|
|
@@ -227,46 +229,46 @@ end
|
|
|
227
229
|
|
|
228
230
|
shared_examples_for 'store_stringkey_objectvalue' do
|
|
229
231
|
it "writes Object values to keys that are Strings like a Hash" do
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
232
|
+
store["strkey1"] = Value.new(:objval1)
|
|
233
|
+
store["strkey1"].should == Value.new(:objval1)
|
|
234
|
+
store.load("strkey1").should == Value.new(:objval1)
|
|
233
235
|
end
|
|
234
236
|
|
|
235
237
|
it "returns true from key? if a String key is available" do
|
|
236
|
-
|
|
237
|
-
|
|
238
|
+
store["strkey1"] = Value.new(:objval1)
|
|
239
|
+
store.key?("strkey1").should == true
|
|
238
240
|
end
|
|
239
241
|
|
|
240
242
|
it "stores Object values with String keys with #store" do
|
|
241
243
|
value = Value.new(:objval1)
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
244
|
+
store.store("strkey1", value).should equal(value)
|
|
245
|
+
store["strkey1"].should == Value.new(:objval1)
|
|
246
|
+
store.load("strkey1").should == Value.new(:objval1)
|
|
245
247
|
end
|
|
246
248
|
|
|
247
249
|
it "removes and returns a Object element with a String key from the backing store via delete if it exists" do
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
250
|
+
store["strkey1"] = Value.new(:objval1)
|
|
251
|
+
store.delete("strkey1").should == Value.new(:objval1)
|
|
252
|
+
store.key?("strkey1").should == false
|
|
251
253
|
end
|
|
252
254
|
|
|
253
255
|
it "overwrites existing Object values with String" do
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
store["strkey1"] = Value.new(:objval1)
|
|
257
|
+
store["strkey1"].should == Value.new(:objval1)
|
|
258
|
+
store["strkey1"] = Value.new(:objval2)
|
|
259
|
+
store["strkey1"].should == Value.new(:objval2)
|
|
258
260
|
end
|
|
259
261
|
|
|
260
262
|
it "does not run the block if the String key is available" do
|
|
261
|
-
|
|
263
|
+
store["strkey1"] = Value.new(:objval1)
|
|
262
264
|
unaltered = "unaltered"
|
|
263
|
-
|
|
265
|
+
store.fetch("strkey1") { unaltered = "altered" }
|
|
264
266
|
unaltered.should == "unaltered"
|
|
265
267
|
end
|
|
266
268
|
|
|
267
269
|
it "fetches a String key with a default value with fetch, if the key is available" do
|
|
268
|
-
|
|
269
|
-
|
|
270
|
+
store["strkey1"] = Value.new(:objval1)
|
|
271
|
+
store.fetch("strkey1", Value.new(:objval2)).should == Value.new(:objval1)
|
|
270
272
|
end
|
|
271
273
|
end
|
|
272
274
|
|
|
@@ -275,8 +277,8 @@ end
|
|
|
275
277
|
shared_examples_for 'returndifferent_stringkey_objectvalue' do
|
|
276
278
|
it "guarantees that a different Object value is retrieved from the String key" do
|
|
277
279
|
value = Value.new(:objval1)
|
|
278
|
-
|
|
279
|
-
|
|
280
|
+
store["strkey1"] = Value.new(:objval1)
|
|
281
|
+
store["strkey1"].should_not be_equal(Value.new(:objval1))
|
|
280
282
|
end
|
|
281
283
|
end
|
|
282
284
|
|
|
@@ -284,63 +286,63 @@ end
|
|
|
284
286
|
|
|
285
287
|
shared_examples_for 'expires_stringkey_objectvalue' do
|
|
286
288
|
it 'should support expires on store and #[]' do
|
|
287
|
-
|
|
288
|
-
|
|
289
|
+
store.store("strkey1", Value.new(:objval1), :expires => 2)
|
|
290
|
+
store["strkey1"].should == Value.new(:objval1)
|
|
289
291
|
sleep 1
|
|
290
|
-
|
|
292
|
+
store["strkey1"].should == Value.new(:objval1)
|
|
291
293
|
sleep 2
|
|
292
|
-
|
|
294
|
+
store["strkey1"].should == nil
|
|
293
295
|
end
|
|
294
296
|
|
|
295
297
|
it 'should support expires on store and load' do
|
|
296
|
-
|
|
297
|
-
|
|
298
|
+
store.store("strkey1", Value.new(:objval1), :expires => 2)
|
|
299
|
+
store.load("strkey1").should == Value.new(:objval1)
|
|
298
300
|
sleep 1
|
|
299
|
-
|
|
301
|
+
store.load("strkey1").should == Value.new(:objval1)
|
|
300
302
|
sleep 2
|
|
301
|
-
|
|
303
|
+
store.load("strkey1").should == nil
|
|
302
304
|
end
|
|
303
305
|
|
|
304
306
|
it 'should support expires on store and key?' do
|
|
305
|
-
|
|
306
|
-
|
|
307
|
+
store.store("strkey1", Value.new(:objval1), :expires => 2)
|
|
308
|
+
store.key?("strkey1").should == true
|
|
307
309
|
sleep 1
|
|
308
|
-
|
|
310
|
+
store.key?("strkey1").should == true
|
|
309
311
|
sleep 2
|
|
310
|
-
|
|
312
|
+
store.key?("strkey1").should == false
|
|
311
313
|
end
|
|
312
314
|
|
|
313
315
|
it 'should support updating the expiration time in load' do
|
|
314
|
-
|
|
315
|
-
|
|
316
|
+
store.store("strkey2", Value.new(:objval2), :expires => 2)
|
|
317
|
+
store["strkey2"].should == Value.new(:objval2)
|
|
316
318
|
sleep 1
|
|
317
|
-
|
|
318
|
-
|
|
319
|
+
store.load("strkey2", :expires => 3).should == Value.new(:objval2)
|
|
320
|
+
store["strkey2"].should == Value.new(:objval2)
|
|
319
321
|
sleep 1
|
|
320
|
-
|
|
322
|
+
store["strkey2"].should == Value.new(:objval2)
|
|
321
323
|
sleep 3
|
|
322
|
-
|
|
324
|
+
store["strkey2"].should == nil
|
|
323
325
|
end
|
|
324
326
|
|
|
325
327
|
it 'should support updating the expiration time in fetch' do
|
|
326
|
-
|
|
327
|
-
|
|
328
|
+
store.store("strkey1", Value.new(:objval1), :expires => 2)
|
|
329
|
+
store["strkey1"].should == Value.new(:objval1)
|
|
328
330
|
sleep 1
|
|
329
|
-
|
|
330
|
-
|
|
331
|
+
store.fetch("strkey1", nil, :expires => 3).should == Value.new(:objval1)
|
|
332
|
+
store["strkey1"].should == Value.new(:objval1)
|
|
331
333
|
sleep 1
|
|
332
|
-
|
|
334
|
+
store["strkey1"].should == Value.new(:objval1)
|
|
333
335
|
sleep 3
|
|
334
|
-
|
|
336
|
+
store["strkey1"].should == nil
|
|
335
337
|
end
|
|
336
338
|
|
|
337
339
|
it 'should respect expires in delete' do
|
|
338
|
-
|
|
339
|
-
|
|
340
|
+
store.store("strkey2", Value.new(:objval2), :expires => 2)
|
|
341
|
+
store["strkey2"].should == Value.new(:objval2)
|
|
340
342
|
sleep 1
|
|
341
|
-
|
|
343
|
+
store["strkey2"].should == Value.new(:objval2)
|
|
342
344
|
sleep 2
|
|
343
|
-
|
|
345
|
+
store.delete("strkey2").should == nil
|
|
344
346
|
end
|
|
345
347
|
end
|
|
346
348
|
|
|
@@ -348,51 +350,51 @@ end
|
|
|
348
350
|
|
|
349
351
|
shared_examples_for 'null_stringkey_hashvalue' do
|
|
350
352
|
it "reads from keys that are Strings like a Hash" do
|
|
351
|
-
|
|
352
|
-
|
|
353
|
+
store["strkey1"].should == nil
|
|
354
|
+
store.load("strkey1").should == nil
|
|
353
355
|
end
|
|
354
356
|
|
|
355
357
|
it "guarantees that the same Hash value is returned when setting a String key" do
|
|
356
358
|
value = {"hashval1"=>"hashval2"}
|
|
357
|
-
(
|
|
359
|
+
(store["strkey1"] = value).should equal(value)
|
|
358
360
|
end
|
|
359
361
|
|
|
360
362
|
it "returns false from key? if a String key is not available" do
|
|
361
|
-
|
|
363
|
+
store.key?("strkey1").should == false
|
|
362
364
|
end
|
|
363
365
|
|
|
364
366
|
it "returns nil from delete if an element for a String key does not exist" do
|
|
365
|
-
|
|
367
|
+
store.delete("strkey1").should == nil
|
|
366
368
|
end
|
|
367
369
|
|
|
368
370
|
it "removes all String keys from the store with clear" do
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
371
|
+
store["strkey1"] = {"hashval1"=>"hashval2"}
|
|
372
|
+
store["strkey2"] = {"hashval3"=>"hashval4"}
|
|
373
|
+
store.clear.should equal(store)
|
|
374
|
+
store.key?("strkey1").should_not == true
|
|
375
|
+
store.key?("strkey2").should_not == true
|
|
374
376
|
end
|
|
375
377
|
|
|
376
378
|
it "fetches a String key with a default value with fetch, if the key is not available" do
|
|
377
|
-
|
|
379
|
+
store.fetch("strkey1", {"hashval1"=>"hashval2"}).should == {"hashval1"=>"hashval2"}
|
|
378
380
|
end
|
|
379
381
|
|
|
380
382
|
it "fetches a String key with a block with fetch, if the key is not available" do
|
|
381
383
|
key = "strkey1"
|
|
382
384
|
value = {"hashval1"=>"hashval2"}
|
|
383
|
-
|
|
385
|
+
store.fetch(key) do |k|
|
|
384
386
|
k.should equal(key)
|
|
385
387
|
value
|
|
386
388
|
end.should equal(value)
|
|
387
389
|
end
|
|
388
390
|
|
|
389
391
|
it 'should accept options' do
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
392
|
+
store.key?("strkey1", :option1 => 1).should == false
|
|
393
|
+
store.load("strkey1", :option2 => 2).should == nil
|
|
394
|
+
store.fetch("strkey1", nil, :option3 => 3).should == nil
|
|
395
|
+
store.delete("strkey1", :option4 => 4).should == nil
|
|
396
|
+
store.clear(:option5 => 5).should equal(store)
|
|
397
|
+
store.store("strkey1", {"hashval1"=>"hashval2"}, :option6 => 6).should == {"hashval1"=>"hashval2"}
|
|
396
398
|
end
|
|
397
399
|
end
|
|
398
400
|
|
|
@@ -400,46 +402,46 @@ end
|
|
|
400
402
|
|
|
401
403
|
shared_examples_for 'store_stringkey_hashvalue' do
|
|
402
404
|
it "writes Hash values to keys that are Strings like a Hash" do
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
405
|
+
store["strkey1"] = {"hashval1"=>"hashval2"}
|
|
406
|
+
store["strkey1"].should == {"hashval1"=>"hashval2"}
|
|
407
|
+
store.load("strkey1").should == {"hashval1"=>"hashval2"}
|
|
406
408
|
end
|
|
407
409
|
|
|
408
410
|
it "returns true from key? if a String key is available" do
|
|
409
|
-
|
|
410
|
-
|
|
411
|
+
store["strkey1"] = {"hashval1"=>"hashval2"}
|
|
412
|
+
store.key?("strkey1").should == true
|
|
411
413
|
end
|
|
412
414
|
|
|
413
415
|
it "stores Hash values with String keys with #store" do
|
|
414
416
|
value = {"hashval1"=>"hashval2"}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
417
|
+
store.store("strkey1", value).should equal(value)
|
|
418
|
+
store["strkey1"].should == {"hashval1"=>"hashval2"}
|
|
419
|
+
store.load("strkey1").should == {"hashval1"=>"hashval2"}
|
|
418
420
|
end
|
|
419
421
|
|
|
420
422
|
it "removes and returns a Hash element with a String key from the backing store via delete if it exists" do
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
423
|
+
store["strkey1"] = {"hashval1"=>"hashval2"}
|
|
424
|
+
store.delete("strkey1").should == {"hashval1"=>"hashval2"}
|
|
425
|
+
store.key?("strkey1").should == false
|
|
424
426
|
end
|
|
425
427
|
|
|
426
428
|
it "overwrites existing Hash values with String" do
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
429
|
+
store["strkey1"] = {"hashval1"=>"hashval2"}
|
|
430
|
+
store["strkey1"].should == {"hashval1"=>"hashval2"}
|
|
431
|
+
store["strkey1"] = {"hashval3"=>"hashval4"}
|
|
432
|
+
store["strkey1"].should == {"hashval3"=>"hashval4"}
|
|
431
433
|
end
|
|
432
434
|
|
|
433
435
|
it "does not run the block if the String key is available" do
|
|
434
|
-
|
|
436
|
+
store["strkey1"] = {"hashval1"=>"hashval2"}
|
|
435
437
|
unaltered = "unaltered"
|
|
436
|
-
|
|
438
|
+
store.fetch("strkey1") { unaltered = "altered" }
|
|
437
439
|
unaltered.should == "unaltered"
|
|
438
440
|
end
|
|
439
441
|
|
|
440
442
|
it "fetches a String key with a default value with fetch, if the key is available" do
|
|
441
|
-
|
|
442
|
-
|
|
443
|
+
store["strkey1"] = {"hashval1"=>"hashval2"}
|
|
444
|
+
store.fetch("strkey1", {"hashval3"=>"hashval4"}).should == {"hashval1"=>"hashval2"}
|
|
443
445
|
end
|
|
444
446
|
end
|
|
445
447
|
|
|
@@ -448,8 +450,8 @@ end
|
|
|
448
450
|
shared_examples_for 'returndifferent_stringkey_hashvalue' do
|
|
449
451
|
it "guarantees that a different Hash value is retrieved from the String key" do
|
|
450
452
|
value = {"hashval1"=>"hashval2"}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
+
store["strkey1"] = {"hashval1"=>"hashval2"}
|
|
454
|
+
store["strkey1"].should_not be_equal({"hashval1"=>"hashval2"})
|
|
453
455
|
end
|
|
454
456
|
end
|
|
455
457
|
|
|
@@ -457,63 +459,63 @@ end
|
|
|
457
459
|
|
|
458
460
|
shared_examples_for 'expires_stringkey_hashvalue' do
|
|
459
461
|
it 'should support expires on store and #[]' do
|
|
460
|
-
|
|
461
|
-
|
|
462
|
+
store.store("strkey1", {"hashval1"=>"hashval2"}, :expires => 2)
|
|
463
|
+
store["strkey1"].should == {"hashval1"=>"hashval2"}
|
|
462
464
|
sleep 1
|
|
463
|
-
|
|
465
|
+
store["strkey1"].should == {"hashval1"=>"hashval2"}
|
|
464
466
|
sleep 2
|
|
465
|
-
|
|
467
|
+
store["strkey1"].should == nil
|
|
466
468
|
end
|
|
467
469
|
|
|
468
470
|
it 'should support expires on store and load' do
|
|
469
|
-
|
|
470
|
-
|
|
471
|
+
store.store("strkey1", {"hashval1"=>"hashval2"}, :expires => 2)
|
|
472
|
+
store.load("strkey1").should == {"hashval1"=>"hashval2"}
|
|
471
473
|
sleep 1
|
|
472
|
-
|
|
474
|
+
store.load("strkey1").should == {"hashval1"=>"hashval2"}
|
|
473
475
|
sleep 2
|
|
474
|
-
|
|
476
|
+
store.load("strkey1").should == nil
|
|
475
477
|
end
|
|
476
478
|
|
|
477
479
|
it 'should support expires on store and key?' do
|
|
478
|
-
|
|
479
|
-
|
|
480
|
+
store.store("strkey1", {"hashval1"=>"hashval2"}, :expires => 2)
|
|
481
|
+
store.key?("strkey1").should == true
|
|
480
482
|
sleep 1
|
|
481
|
-
|
|
483
|
+
store.key?("strkey1").should == true
|
|
482
484
|
sleep 2
|
|
483
|
-
|
|
485
|
+
store.key?("strkey1").should == false
|
|
484
486
|
end
|
|
485
487
|
|
|
486
488
|
it 'should support updating the expiration time in load' do
|
|
487
|
-
|
|
488
|
-
|
|
489
|
+
store.store("strkey2", {"hashval3"=>"hashval4"}, :expires => 2)
|
|
490
|
+
store["strkey2"].should == {"hashval3"=>"hashval4"}
|
|
489
491
|
sleep 1
|
|
490
|
-
|
|
491
|
-
|
|
492
|
+
store.load("strkey2", :expires => 3).should == {"hashval3"=>"hashval4"}
|
|
493
|
+
store["strkey2"].should == {"hashval3"=>"hashval4"}
|
|
492
494
|
sleep 1
|
|
493
|
-
|
|
495
|
+
store["strkey2"].should == {"hashval3"=>"hashval4"}
|
|
494
496
|
sleep 3
|
|
495
|
-
|
|
497
|
+
store["strkey2"].should == nil
|
|
496
498
|
end
|
|
497
499
|
|
|
498
500
|
it 'should support updating the expiration time in fetch' do
|
|
499
|
-
|
|
500
|
-
|
|
501
|
+
store.store("strkey1", {"hashval1"=>"hashval2"}, :expires => 2)
|
|
502
|
+
store["strkey1"].should == {"hashval1"=>"hashval2"}
|
|
501
503
|
sleep 1
|
|
502
|
-
|
|
503
|
-
|
|
504
|
+
store.fetch("strkey1", nil, :expires => 3).should == {"hashval1"=>"hashval2"}
|
|
505
|
+
store["strkey1"].should == {"hashval1"=>"hashval2"}
|
|
504
506
|
sleep 1
|
|
505
|
-
|
|
507
|
+
store["strkey1"].should == {"hashval1"=>"hashval2"}
|
|
506
508
|
sleep 3
|
|
507
|
-
|
|
509
|
+
store["strkey1"].should == nil
|
|
508
510
|
end
|
|
509
511
|
|
|
510
512
|
it 'should respect expires in delete' do
|
|
511
|
-
|
|
512
|
-
|
|
513
|
+
store.store("strkey2", {"hashval3"=>"hashval4"}, :expires => 2)
|
|
514
|
+
store["strkey2"].should == {"hashval3"=>"hashval4"}
|
|
513
515
|
sleep 1
|
|
514
|
-
|
|
516
|
+
store["strkey2"].should == {"hashval3"=>"hashval4"}
|
|
515
517
|
sleep 2
|
|
516
|
-
|
|
518
|
+
store.delete("strkey2").should == nil
|
|
517
519
|
end
|
|
518
520
|
end
|
|
519
521
|
|
|
@@ -521,51 +523,51 @@ end
|
|
|
521
523
|
|
|
522
524
|
shared_examples_for 'null_objectkey_stringvalue' do
|
|
523
525
|
it "reads from keys that are Objects like a Hash" do
|
|
524
|
-
|
|
525
|
-
|
|
526
|
+
store[Value.new(:objkey1)].should == nil
|
|
527
|
+
store.load(Value.new(:objkey1)).should == nil
|
|
526
528
|
end
|
|
527
529
|
|
|
528
530
|
it "guarantees that the same String value is returned when setting a Object key" do
|
|
529
531
|
value = "strval1"
|
|
530
|
-
(
|
|
532
|
+
(store[Value.new(:objkey1)] = value).should equal(value)
|
|
531
533
|
end
|
|
532
534
|
|
|
533
535
|
it "returns false from key? if a Object key is not available" do
|
|
534
|
-
|
|
536
|
+
store.key?(Value.new(:objkey1)).should == false
|
|
535
537
|
end
|
|
536
538
|
|
|
537
539
|
it "returns nil from delete if an element for a Object key does not exist" do
|
|
538
|
-
|
|
540
|
+
store.delete(Value.new(:objkey1)).should == nil
|
|
539
541
|
end
|
|
540
542
|
|
|
541
543
|
it "removes all Object keys from the store with clear" do
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
544
|
+
store[Value.new(:objkey1)] = "strval1"
|
|
545
|
+
store[Value.new(:objkey2)] = "strval2"
|
|
546
|
+
store.clear.should equal(store)
|
|
547
|
+
store.key?(Value.new(:objkey1)).should_not == true
|
|
548
|
+
store.key?(Value.new(:objkey2)).should_not == true
|
|
547
549
|
end
|
|
548
550
|
|
|
549
551
|
it "fetches a Object key with a default value with fetch, if the key is not available" do
|
|
550
|
-
|
|
552
|
+
store.fetch(Value.new(:objkey1), "strval1").should == "strval1"
|
|
551
553
|
end
|
|
552
554
|
|
|
553
555
|
it "fetches a Object key with a block with fetch, if the key is not available" do
|
|
554
556
|
key = Value.new(:objkey1)
|
|
555
557
|
value = "strval1"
|
|
556
|
-
|
|
558
|
+
store.fetch(key) do |k|
|
|
557
559
|
k.should equal(key)
|
|
558
560
|
value
|
|
559
561
|
end.should equal(value)
|
|
560
562
|
end
|
|
561
563
|
|
|
562
564
|
it 'should accept options' do
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
565
|
+
store.key?(Value.new(:objkey1), :option1 => 1).should == false
|
|
566
|
+
store.load(Value.new(:objkey1), :option2 => 2).should == nil
|
|
567
|
+
store.fetch(Value.new(:objkey1), nil, :option3 => 3).should == nil
|
|
568
|
+
store.delete(Value.new(:objkey1), :option4 => 4).should == nil
|
|
569
|
+
store.clear(:option5 => 5).should equal(store)
|
|
570
|
+
store.store(Value.new(:objkey1), "strval1", :option6 => 6).should == "strval1"
|
|
569
571
|
end
|
|
570
572
|
end
|
|
571
573
|
|
|
@@ -573,46 +575,46 @@ end
|
|
|
573
575
|
|
|
574
576
|
shared_examples_for 'store_objectkey_stringvalue' do
|
|
575
577
|
it "writes String values to keys that are Objects like a Hash" do
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
578
|
+
store[Value.new(:objkey1)] = "strval1"
|
|
579
|
+
store[Value.new(:objkey1)].should == "strval1"
|
|
580
|
+
store.load(Value.new(:objkey1)).should == "strval1"
|
|
579
581
|
end
|
|
580
582
|
|
|
581
583
|
it "returns true from key? if a Object key is available" do
|
|
582
|
-
|
|
583
|
-
|
|
584
|
+
store[Value.new(:objkey1)] = "strval1"
|
|
585
|
+
store.key?(Value.new(:objkey1)).should == true
|
|
584
586
|
end
|
|
585
587
|
|
|
586
588
|
it "stores String values with Object keys with #store" do
|
|
587
589
|
value = "strval1"
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
590
|
+
store.store(Value.new(:objkey1), value).should equal(value)
|
|
591
|
+
store[Value.new(:objkey1)].should == "strval1"
|
|
592
|
+
store.load(Value.new(:objkey1)).should == "strval1"
|
|
591
593
|
end
|
|
592
594
|
|
|
593
595
|
it "removes and returns a String element with a Object key from the backing store via delete if it exists" do
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
596
|
+
store[Value.new(:objkey1)] = "strval1"
|
|
597
|
+
store.delete(Value.new(:objkey1)).should == "strval1"
|
|
598
|
+
store.key?(Value.new(:objkey1)).should == false
|
|
597
599
|
end
|
|
598
600
|
|
|
599
601
|
it "overwrites existing String values with Object" do
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
602
|
+
store[Value.new(:objkey1)] = "strval1"
|
|
603
|
+
store[Value.new(:objkey1)].should == "strval1"
|
|
604
|
+
store[Value.new(:objkey1)] = "strval2"
|
|
605
|
+
store[Value.new(:objkey1)].should == "strval2"
|
|
604
606
|
end
|
|
605
607
|
|
|
606
608
|
it "does not run the block if the Object key is available" do
|
|
607
|
-
|
|
609
|
+
store[Value.new(:objkey1)] = "strval1"
|
|
608
610
|
unaltered = "unaltered"
|
|
609
|
-
|
|
611
|
+
store.fetch(Value.new(:objkey1)) { unaltered = "altered" }
|
|
610
612
|
unaltered.should == "unaltered"
|
|
611
613
|
end
|
|
612
614
|
|
|
613
615
|
it "fetches a Object key with a default value with fetch, if the key is available" do
|
|
614
|
-
|
|
615
|
-
|
|
616
|
+
store[Value.new(:objkey1)] = "strval1"
|
|
617
|
+
store.fetch(Value.new(:objkey1), "strval2").should == "strval1"
|
|
616
618
|
end
|
|
617
619
|
end
|
|
618
620
|
|
|
@@ -621,8 +623,8 @@ end
|
|
|
621
623
|
shared_examples_for 'returndifferent_objectkey_stringvalue' do
|
|
622
624
|
it "guarantees that a different String value is retrieved from the Object key" do
|
|
623
625
|
value = "strval1"
|
|
624
|
-
|
|
625
|
-
|
|
626
|
+
store[Value.new(:objkey1)] = "strval1"
|
|
627
|
+
store[Value.new(:objkey1)].should_not be_equal("strval1")
|
|
626
628
|
end
|
|
627
629
|
end
|
|
628
630
|
|
|
@@ -630,63 +632,63 @@ end
|
|
|
630
632
|
|
|
631
633
|
shared_examples_for 'expires_objectkey_stringvalue' do
|
|
632
634
|
it 'should support expires on store and #[]' do
|
|
633
|
-
|
|
634
|
-
|
|
635
|
+
store.store(Value.new(:objkey1), "strval1", :expires => 2)
|
|
636
|
+
store[Value.new(:objkey1)].should == "strval1"
|
|
635
637
|
sleep 1
|
|
636
|
-
|
|
638
|
+
store[Value.new(:objkey1)].should == "strval1"
|
|
637
639
|
sleep 2
|
|
638
|
-
|
|
640
|
+
store[Value.new(:objkey1)].should == nil
|
|
639
641
|
end
|
|
640
642
|
|
|
641
643
|
it 'should support expires on store and load' do
|
|
642
|
-
|
|
643
|
-
|
|
644
|
+
store.store(Value.new(:objkey1), "strval1", :expires => 2)
|
|
645
|
+
store.load(Value.new(:objkey1)).should == "strval1"
|
|
644
646
|
sleep 1
|
|
645
|
-
|
|
647
|
+
store.load(Value.new(:objkey1)).should == "strval1"
|
|
646
648
|
sleep 2
|
|
647
|
-
|
|
649
|
+
store.load(Value.new(:objkey1)).should == nil
|
|
648
650
|
end
|
|
649
651
|
|
|
650
652
|
it 'should support expires on store and key?' do
|
|
651
|
-
|
|
652
|
-
|
|
653
|
+
store.store(Value.new(:objkey1), "strval1", :expires => 2)
|
|
654
|
+
store.key?(Value.new(:objkey1)).should == true
|
|
653
655
|
sleep 1
|
|
654
|
-
|
|
656
|
+
store.key?(Value.new(:objkey1)).should == true
|
|
655
657
|
sleep 2
|
|
656
|
-
|
|
658
|
+
store.key?(Value.new(:objkey1)).should == false
|
|
657
659
|
end
|
|
658
660
|
|
|
659
661
|
it 'should support updating the expiration time in load' do
|
|
660
|
-
|
|
661
|
-
|
|
662
|
+
store.store(Value.new(:objkey2), "strval2", :expires => 2)
|
|
663
|
+
store[Value.new(:objkey2)].should == "strval2"
|
|
662
664
|
sleep 1
|
|
663
|
-
|
|
664
|
-
|
|
665
|
+
store.load(Value.new(:objkey2), :expires => 3).should == "strval2"
|
|
666
|
+
store[Value.new(:objkey2)].should == "strval2"
|
|
665
667
|
sleep 1
|
|
666
|
-
|
|
668
|
+
store[Value.new(:objkey2)].should == "strval2"
|
|
667
669
|
sleep 3
|
|
668
|
-
|
|
670
|
+
store[Value.new(:objkey2)].should == nil
|
|
669
671
|
end
|
|
670
672
|
|
|
671
673
|
it 'should support updating the expiration time in fetch' do
|
|
672
|
-
|
|
673
|
-
|
|
674
|
+
store.store(Value.new(:objkey1), "strval1", :expires => 2)
|
|
675
|
+
store[Value.new(:objkey1)].should == "strval1"
|
|
674
676
|
sleep 1
|
|
675
|
-
|
|
676
|
-
|
|
677
|
+
store.fetch(Value.new(:objkey1), nil, :expires => 3).should == "strval1"
|
|
678
|
+
store[Value.new(:objkey1)].should == "strval1"
|
|
677
679
|
sleep 1
|
|
678
|
-
|
|
680
|
+
store[Value.new(:objkey1)].should == "strval1"
|
|
679
681
|
sleep 3
|
|
680
|
-
|
|
682
|
+
store[Value.new(:objkey1)].should == nil
|
|
681
683
|
end
|
|
682
684
|
|
|
683
685
|
it 'should respect expires in delete' do
|
|
684
|
-
|
|
685
|
-
|
|
686
|
+
store.store(Value.new(:objkey2), "strval2", :expires => 2)
|
|
687
|
+
store[Value.new(:objkey2)].should == "strval2"
|
|
686
688
|
sleep 1
|
|
687
|
-
|
|
689
|
+
store[Value.new(:objkey2)].should == "strval2"
|
|
688
690
|
sleep 2
|
|
689
|
-
|
|
691
|
+
store.delete(Value.new(:objkey2)).should == nil
|
|
690
692
|
end
|
|
691
693
|
end
|
|
692
694
|
|
|
@@ -694,51 +696,51 @@ end
|
|
|
694
696
|
|
|
695
697
|
shared_examples_for 'null_objectkey_objectvalue' do
|
|
696
698
|
it "reads from keys that are Objects like a Hash" do
|
|
697
|
-
|
|
698
|
-
|
|
699
|
+
store[Value.new(:objkey1)].should == nil
|
|
700
|
+
store.load(Value.new(:objkey1)).should == nil
|
|
699
701
|
end
|
|
700
702
|
|
|
701
703
|
it "guarantees that the same Object value is returned when setting a Object key" do
|
|
702
704
|
value = Value.new(:objval1)
|
|
703
|
-
(
|
|
705
|
+
(store[Value.new(:objkey1)] = value).should equal(value)
|
|
704
706
|
end
|
|
705
707
|
|
|
706
708
|
it "returns false from key? if a Object key is not available" do
|
|
707
|
-
|
|
709
|
+
store.key?(Value.new(:objkey1)).should == false
|
|
708
710
|
end
|
|
709
711
|
|
|
710
712
|
it "returns nil from delete if an element for a Object key does not exist" do
|
|
711
|
-
|
|
713
|
+
store.delete(Value.new(:objkey1)).should == nil
|
|
712
714
|
end
|
|
713
715
|
|
|
714
716
|
it "removes all Object keys from the store with clear" do
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
717
|
+
store[Value.new(:objkey1)] = Value.new(:objval1)
|
|
718
|
+
store[Value.new(:objkey2)] = Value.new(:objval2)
|
|
719
|
+
store.clear.should equal(store)
|
|
720
|
+
store.key?(Value.new(:objkey1)).should_not == true
|
|
721
|
+
store.key?(Value.new(:objkey2)).should_not == true
|
|
720
722
|
end
|
|
721
723
|
|
|
722
724
|
it "fetches a Object key with a default value with fetch, if the key is not available" do
|
|
723
|
-
|
|
725
|
+
store.fetch(Value.new(:objkey1), Value.new(:objval1)).should == Value.new(:objval1)
|
|
724
726
|
end
|
|
725
727
|
|
|
726
728
|
it "fetches a Object key with a block with fetch, if the key is not available" do
|
|
727
729
|
key = Value.new(:objkey1)
|
|
728
730
|
value = Value.new(:objval1)
|
|
729
|
-
|
|
731
|
+
store.fetch(key) do |k|
|
|
730
732
|
k.should equal(key)
|
|
731
733
|
value
|
|
732
734
|
end.should equal(value)
|
|
733
735
|
end
|
|
734
736
|
|
|
735
737
|
it 'should accept options' do
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
738
|
+
store.key?(Value.new(:objkey1), :option1 => 1).should == false
|
|
739
|
+
store.load(Value.new(:objkey1), :option2 => 2).should == nil
|
|
740
|
+
store.fetch(Value.new(:objkey1), nil, :option3 => 3).should == nil
|
|
741
|
+
store.delete(Value.new(:objkey1), :option4 => 4).should == nil
|
|
742
|
+
store.clear(:option5 => 5).should equal(store)
|
|
743
|
+
store.store(Value.new(:objkey1), Value.new(:objval1), :option6 => 6).should == Value.new(:objval1)
|
|
742
744
|
end
|
|
743
745
|
end
|
|
744
746
|
|
|
@@ -746,46 +748,46 @@ end
|
|
|
746
748
|
|
|
747
749
|
shared_examples_for 'store_objectkey_objectvalue' do
|
|
748
750
|
it "writes Object values to keys that are Objects like a Hash" do
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
751
|
+
store[Value.new(:objkey1)] = Value.new(:objval1)
|
|
752
|
+
store[Value.new(:objkey1)].should == Value.new(:objval1)
|
|
753
|
+
store.load(Value.new(:objkey1)).should == Value.new(:objval1)
|
|
752
754
|
end
|
|
753
755
|
|
|
754
756
|
it "returns true from key? if a Object key is available" do
|
|
755
|
-
|
|
756
|
-
|
|
757
|
+
store[Value.new(:objkey1)] = Value.new(:objval1)
|
|
758
|
+
store.key?(Value.new(:objkey1)).should == true
|
|
757
759
|
end
|
|
758
760
|
|
|
759
761
|
it "stores Object values with Object keys with #store" do
|
|
760
762
|
value = Value.new(:objval1)
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
763
|
+
store.store(Value.new(:objkey1), value).should equal(value)
|
|
764
|
+
store[Value.new(:objkey1)].should == Value.new(:objval1)
|
|
765
|
+
store.load(Value.new(:objkey1)).should == Value.new(:objval1)
|
|
764
766
|
end
|
|
765
767
|
|
|
766
768
|
it "removes and returns a Object element with a Object key from the backing store via delete if it exists" do
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
769
|
+
store[Value.new(:objkey1)] = Value.new(:objval1)
|
|
770
|
+
store.delete(Value.new(:objkey1)).should == Value.new(:objval1)
|
|
771
|
+
store.key?(Value.new(:objkey1)).should == false
|
|
770
772
|
end
|
|
771
773
|
|
|
772
774
|
it "overwrites existing Object values with Object" do
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
775
|
+
store[Value.new(:objkey1)] = Value.new(:objval1)
|
|
776
|
+
store[Value.new(:objkey1)].should == Value.new(:objval1)
|
|
777
|
+
store[Value.new(:objkey1)] = Value.new(:objval2)
|
|
778
|
+
store[Value.new(:objkey1)].should == Value.new(:objval2)
|
|
777
779
|
end
|
|
778
780
|
|
|
779
781
|
it "does not run the block if the Object key is available" do
|
|
780
|
-
|
|
782
|
+
store[Value.new(:objkey1)] = Value.new(:objval1)
|
|
781
783
|
unaltered = "unaltered"
|
|
782
|
-
|
|
784
|
+
store.fetch(Value.new(:objkey1)) { unaltered = "altered" }
|
|
783
785
|
unaltered.should == "unaltered"
|
|
784
786
|
end
|
|
785
787
|
|
|
786
788
|
it "fetches a Object key with a default value with fetch, if the key is available" do
|
|
787
|
-
|
|
788
|
-
|
|
789
|
+
store[Value.new(:objkey1)] = Value.new(:objval1)
|
|
790
|
+
store.fetch(Value.new(:objkey1), Value.new(:objval2)).should == Value.new(:objval1)
|
|
789
791
|
end
|
|
790
792
|
end
|
|
791
793
|
|
|
@@ -794,8 +796,8 @@ end
|
|
|
794
796
|
shared_examples_for 'returndifferent_objectkey_objectvalue' do
|
|
795
797
|
it "guarantees that a different Object value is retrieved from the Object key" do
|
|
796
798
|
value = Value.new(:objval1)
|
|
797
|
-
|
|
798
|
-
|
|
799
|
+
store[Value.new(:objkey1)] = Value.new(:objval1)
|
|
800
|
+
store[Value.new(:objkey1)].should_not be_equal(Value.new(:objval1))
|
|
799
801
|
end
|
|
800
802
|
end
|
|
801
803
|
|
|
@@ -803,63 +805,63 @@ end
|
|
|
803
805
|
|
|
804
806
|
shared_examples_for 'expires_objectkey_objectvalue' do
|
|
805
807
|
it 'should support expires on store and #[]' do
|
|
806
|
-
|
|
807
|
-
|
|
808
|
+
store.store(Value.new(:objkey1), Value.new(:objval1), :expires => 2)
|
|
809
|
+
store[Value.new(:objkey1)].should == Value.new(:objval1)
|
|
808
810
|
sleep 1
|
|
809
|
-
|
|
811
|
+
store[Value.new(:objkey1)].should == Value.new(:objval1)
|
|
810
812
|
sleep 2
|
|
811
|
-
|
|
813
|
+
store[Value.new(:objkey1)].should == nil
|
|
812
814
|
end
|
|
813
815
|
|
|
814
816
|
it 'should support expires on store and load' do
|
|
815
|
-
|
|
816
|
-
|
|
817
|
+
store.store(Value.new(:objkey1), Value.new(:objval1), :expires => 2)
|
|
818
|
+
store.load(Value.new(:objkey1)).should == Value.new(:objval1)
|
|
817
819
|
sleep 1
|
|
818
|
-
|
|
820
|
+
store.load(Value.new(:objkey1)).should == Value.new(:objval1)
|
|
819
821
|
sleep 2
|
|
820
|
-
|
|
822
|
+
store.load(Value.new(:objkey1)).should == nil
|
|
821
823
|
end
|
|
822
824
|
|
|
823
825
|
it 'should support expires on store and key?' do
|
|
824
|
-
|
|
825
|
-
|
|
826
|
+
store.store(Value.new(:objkey1), Value.new(:objval1), :expires => 2)
|
|
827
|
+
store.key?(Value.new(:objkey1)).should == true
|
|
826
828
|
sleep 1
|
|
827
|
-
|
|
829
|
+
store.key?(Value.new(:objkey1)).should == true
|
|
828
830
|
sleep 2
|
|
829
|
-
|
|
831
|
+
store.key?(Value.new(:objkey1)).should == false
|
|
830
832
|
end
|
|
831
833
|
|
|
832
834
|
it 'should support updating the expiration time in load' do
|
|
833
|
-
|
|
834
|
-
|
|
835
|
+
store.store(Value.new(:objkey2), Value.new(:objval2), :expires => 2)
|
|
836
|
+
store[Value.new(:objkey2)].should == Value.new(:objval2)
|
|
835
837
|
sleep 1
|
|
836
|
-
|
|
837
|
-
|
|
838
|
+
store.load(Value.new(:objkey2), :expires => 3).should == Value.new(:objval2)
|
|
839
|
+
store[Value.new(:objkey2)].should == Value.new(:objval2)
|
|
838
840
|
sleep 1
|
|
839
|
-
|
|
841
|
+
store[Value.new(:objkey2)].should == Value.new(:objval2)
|
|
840
842
|
sleep 3
|
|
841
|
-
|
|
843
|
+
store[Value.new(:objkey2)].should == nil
|
|
842
844
|
end
|
|
843
845
|
|
|
844
846
|
it 'should support updating the expiration time in fetch' do
|
|
845
|
-
|
|
846
|
-
|
|
847
|
+
store.store(Value.new(:objkey1), Value.new(:objval1), :expires => 2)
|
|
848
|
+
store[Value.new(:objkey1)].should == Value.new(:objval1)
|
|
847
849
|
sleep 1
|
|
848
|
-
|
|
849
|
-
|
|
850
|
+
store.fetch(Value.new(:objkey1), nil, :expires => 3).should == Value.new(:objval1)
|
|
851
|
+
store[Value.new(:objkey1)].should == Value.new(:objval1)
|
|
850
852
|
sleep 1
|
|
851
|
-
|
|
853
|
+
store[Value.new(:objkey1)].should == Value.new(:objval1)
|
|
852
854
|
sleep 3
|
|
853
|
-
|
|
855
|
+
store[Value.new(:objkey1)].should == nil
|
|
854
856
|
end
|
|
855
857
|
|
|
856
858
|
it 'should respect expires in delete' do
|
|
857
|
-
|
|
858
|
-
|
|
859
|
+
store.store(Value.new(:objkey2), Value.new(:objval2), :expires => 2)
|
|
860
|
+
store[Value.new(:objkey2)].should == Value.new(:objval2)
|
|
859
861
|
sleep 1
|
|
860
|
-
|
|
862
|
+
store[Value.new(:objkey2)].should == Value.new(:objval2)
|
|
861
863
|
sleep 2
|
|
862
|
-
|
|
864
|
+
store.delete(Value.new(:objkey2)).should == nil
|
|
863
865
|
end
|
|
864
866
|
end
|
|
865
867
|
|
|
@@ -867,51 +869,51 @@ end
|
|
|
867
869
|
|
|
868
870
|
shared_examples_for 'null_objectkey_hashvalue' do
|
|
869
871
|
it "reads from keys that are Objects like a Hash" do
|
|
870
|
-
|
|
871
|
-
|
|
872
|
+
store[Value.new(:objkey1)].should == nil
|
|
873
|
+
store.load(Value.new(:objkey1)).should == nil
|
|
872
874
|
end
|
|
873
875
|
|
|
874
876
|
it "guarantees that the same Hash value is returned when setting a Object key" do
|
|
875
877
|
value = {"hashval1"=>"hashval2"}
|
|
876
|
-
(
|
|
878
|
+
(store[Value.new(:objkey1)] = value).should equal(value)
|
|
877
879
|
end
|
|
878
880
|
|
|
879
881
|
it "returns false from key? if a Object key is not available" do
|
|
880
|
-
|
|
882
|
+
store.key?(Value.new(:objkey1)).should == false
|
|
881
883
|
end
|
|
882
884
|
|
|
883
885
|
it "returns nil from delete if an element for a Object key does not exist" do
|
|
884
|
-
|
|
886
|
+
store.delete(Value.new(:objkey1)).should == nil
|
|
885
887
|
end
|
|
886
888
|
|
|
887
889
|
it "removes all Object keys from the store with clear" do
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
890
|
+
store[Value.new(:objkey1)] = {"hashval1"=>"hashval2"}
|
|
891
|
+
store[Value.new(:objkey2)] = {"hashval3"=>"hashval4"}
|
|
892
|
+
store.clear.should equal(store)
|
|
893
|
+
store.key?(Value.new(:objkey1)).should_not == true
|
|
894
|
+
store.key?(Value.new(:objkey2)).should_not == true
|
|
893
895
|
end
|
|
894
896
|
|
|
895
897
|
it "fetches a Object key with a default value with fetch, if the key is not available" do
|
|
896
|
-
|
|
898
|
+
store.fetch(Value.new(:objkey1), {"hashval1"=>"hashval2"}).should == {"hashval1"=>"hashval2"}
|
|
897
899
|
end
|
|
898
900
|
|
|
899
901
|
it "fetches a Object key with a block with fetch, if the key is not available" do
|
|
900
902
|
key = Value.new(:objkey1)
|
|
901
903
|
value = {"hashval1"=>"hashval2"}
|
|
902
|
-
|
|
904
|
+
store.fetch(key) do |k|
|
|
903
905
|
k.should equal(key)
|
|
904
906
|
value
|
|
905
907
|
end.should equal(value)
|
|
906
908
|
end
|
|
907
909
|
|
|
908
910
|
it 'should accept options' do
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
911
|
+
store.key?(Value.new(:objkey1), :option1 => 1).should == false
|
|
912
|
+
store.load(Value.new(:objkey1), :option2 => 2).should == nil
|
|
913
|
+
store.fetch(Value.new(:objkey1), nil, :option3 => 3).should == nil
|
|
914
|
+
store.delete(Value.new(:objkey1), :option4 => 4).should == nil
|
|
915
|
+
store.clear(:option5 => 5).should equal(store)
|
|
916
|
+
store.store(Value.new(:objkey1), {"hashval1"=>"hashval2"}, :option6 => 6).should == {"hashval1"=>"hashval2"}
|
|
915
917
|
end
|
|
916
918
|
end
|
|
917
919
|
|
|
@@ -919,46 +921,46 @@ end
|
|
|
919
921
|
|
|
920
922
|
shared_examples_for 'store_objectkey_hashvalue' do
|
|
921
923
|
it "writes Hash values to keys that are Objects like a Hash" do
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
924
|
+
store[Value.new(:objkey1)] = {"hashval1"=>"hashval2"}
|
|
925
|
+
store[Value.new(:objkey1)].should == {"hashval1"=>"hashval2"}
|
|
926
|
+
store.load(Value.new(:objkey1)).should == {"hashval1"=>"hashval2"}
|
|
925
927
|
end
|
|
926
928
|
|
|
927
929
|
it "returns true from key? if a Object key is available" do
|
|
928
|
-
|
|
929
|
-
|
|
930
|
+
store[Value.new(:objkey1)] = {"hashval1"=>"hashval2"}
|
|
931
|
+
store.key?(Value.new(:objkey1)).should == true
|
|
930
932
|
end
|
|
931
933
|
|
|
932
934
|
it "stores Hash values with Object keys with #store" do
|
|
933
935
|
value = {"hashval1"=>"hashval2"}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
936
|
+
store.store(Value.new(:objkey1), value).should equal(value)
|
|
937
|
+
store[Value.new(:objkey1)].should == {"hashval1"=>"hashval2"}
|
|
938
|
+
store.load(Value.new(:objkey1)).should == {"hashval1"=>"hashval2"}
|
|
937
939
|
end
|
|
938
940
|
|
|
939
941
|
it "removes and returns a Hash element with a Object key from the backing store via delete if it exists" do
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
942
|
+
store[Value.new(:objkey1)] = {"hashval1"=>"hashval2"}
|
|
943
|
+
store.delete(Value.new(:objkey1)).should == {"hashval1"=>"hashval2"}
|
|
944
|
+
store.key?(Value.new(:objkey1)).should == false
|
|
943
945
|
end
|
|
944
946
|
|
|
945
947
|
it "overwrites existing Hash values with Object" do
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
948
|
+
store[Value.new(:objkey1)] = {"hashval1"=>"hashval2"}
|
|
949
|
+
store[Value.new(:objkey1)].should == {"hashval1"=>"hashval2"}
|
|
950
|
+
store[Value.new(:objkey1)] = {"hashval3"=>"hashval4"}
|
|
951
|
+
store[Value.new(:objkey1)].should == {"hashval3"=>"hashval4"}
|
|
950
952
|
end
|
|
951
953
|
|
|
952
954
|
it "does not run the block if the Object key is available" do
|
|
953
|
-
|
|
955
|
+
store[Value.new(:objkey1)] = {"hashval1"=>"hashval2"}
|
|
954
956
|
unaltered = "unaltered"
|
|
955
|
-
|
|
957
|
+
store.fetch(Value.new(:objkey1)) { unaltered = "altered" }
|
|
956
958
|
unaltered.should == "unaltered"
|
|
957
959
|
end
|
|
958
960
|
|
|
959
961
|
it "fetches a Object key with a default value with fetch, if the key is available" do
|
|
960
|
-
|
|
961
|
-
|
|
962
|
+
store[Value.new(:objkey1)] = {"hashval1"=>"hashval2"}
|
|
963
|
+
store.fetch(Value.new(:objkey1), {"hashval3"=>"hashval4"}).should == {"hashval1"=>"hashval2"}
|
|
962
964
|
end
|
|
963
965
|
end
|
|
964
966
|
|
|
@@ -967,8 +969,8 @@ end
|
|
|
967
969
|
shared_examples_for 'returndifferent_objectkey_hashvalue' do
|
|
968
970
|
it "guarantees that a different Hash value is retrieved from the Object key" do
|
|
969
971
|
value = {"hashval1"=>"hashval2"}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
+
store[Value.new(:objkey1)] = {"hashval1"=>"hashval2"}
|
|
973
|
+
store[Value.new(:objkey1)].should_not be_equal({"hashval1"=>"hashval2"})
|
|
972
974
|
end
|
|
973
975
|
end
|
|
974
976
|
|
|
@@ -976,63 +978,63 @@ end
|
|
|
976
978
|
|
|
977
979
|
shared_examples_for 'expires_objectkey_hashvalue' do
|
|
978
980
|
it 'should support expires on store and #[]' do
|
|
979
|
-
|
|
980
|
-
|
|
981
|
+
store.store(Value.new(:objkey1), {"hashval1"=>"hashval2"}, :expires => 2)
|
|
982
|
+
store[Value.new(:objkey1)].should == {"hashval1"=>"hashval2"}
|
|
981
983
|
sleep 1
|
|
982
|
-
|
|
984
|
+
store[Value.new(:objkey1)].should == {"hashval1"=>"hashval2"}
|
|
983
985
|
sleep 2
|
|
984
|
-
|
|
986
|
+
store[Value.new(:objkey1)].should == nil
|
|
985
987
|
end
|
|
986
988
|
|
|
987
989
|
it 'should support expires on store and load' do
|
|
988
|
-
|
|
989
|
-
|
|
990
|
+
store.store(Value.new(:objkey1), {"hashval1"=>"hashval2"}, :expires => 2)
|
|
991
|
+
store.load(Value.new(:objkey1)).should == {"hashval1"=>"hashval2"}
|
|
990
992
|
sleep 1
|
|
991
|
-
|
|
993
|
+
store.load(Value.new(:objkey1)).should == {"hashval1"=>"hashval2"}
|
|
992
994
|
sleep 2
|
|
993
|
-
|
|
995
|
+
store.load(Value.new(:objkey1)).should == nil
|
|
994
996
|
end
|
|
995
997
|
|
|
996
998
|
it 'should support expires on store and key?' do
|
|
997
|
-
|
|
998
|
-
|
|
999
|
+
store.store(Value.new(:objkey1), {"hashval1"=>"hashval2"}, :expires => 2)
|
|
1000
|
+
store.key?(Value.new(:objkey1)).should == true
|
|
999
1001
|
sleep 1
|
|
1000
|
-
|
|
1002
|
+
store.key?(Value.new(:objkey1)).should == true
|
|
1001
1003
|
sleep 2
|
|
1002
|
-
|
|
1004
|
+
store.key?(Value.new(:objkey1)).should == false
|
|
1003
1005
|
end
|
|
1004
1006
|
|
|
1005
1007
|
it 'should support updating the expiration time in load' do
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
+
store.store(Value.new(:objkey2), {"hashval3"=>"hashval4"}, :expires => 2)
|
|
1009
|
+
store[Value.new(:objkey2)].should == {"hashval3"=>"hashval4"}
|
|
1008
1010
|
sleep 1
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
+
store.load(Value.new(:objkey2), :expires => 3).should == {"hashval3"=>"hashval4"}
|
|
1012
|
+
store[Value.new(:objkey2)].should == {"hashval3"=>"hashval4"}
|
|
1011
1013
|
sleep 1
|
|
1012
|
-
|
|
1014
|
+
store[Value.new(:objkey2)].should == {"hashval3"=>"hashval4"}
|
|
1013
1015
|
sleep 3
|
|
1014
|
-
|
|
1016
|
+
store[Value.new(:objkey2)].should == nil
|
|
1015
1017
|
end
|
|
1016
1018
|
|
|
1017
1019
|
it 'should support updating the expiration time in fetch' do
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
+
store.store(Value.new(:objkey1), {"hashval1"=>"hashval2"}, :expires => 2)
|
|
1021
|
+
store[Value.new(:objkey1)].should == {"hashval1"=>"hashval2"}
|
|
1020
1022
|
sleep 1
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
+
store.fetch(Value.new(:objkey1), nil, :expires => 3).should == {"hashval1"=>"hashval2"}
|
|
1024
|
+
store[Value.new(:objkey1)].should == {"hashval1"=>"hashval2"}
|
|
1023
1025
|
sleep 1
|
|
1024
|
-
|
|
1026
|
+
store[Value.new(:objkey1)].should == {"hashval1"=>"hashval2"}
|
|
1025
1027
|
sleep 3
|
|
1026
|
-
|
|
1028
|
+
store[Value.new(:objkey1)].should == nil
|
|
1027
1029
|
end
|
|
1028
1030
|
|
|
1029
1031
|
it 'should respect expires in delete' do
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
+
store.store(Value.new(:objkey2), {"hashval3"=>"hashval4"}, :expires => 2)
|
|
1033
|
+
store[Value.new(:objkey2)].should == {"hashval3"=>"hashval4"}
|
|
1032
1034
|
sleep 1
|
|
1033
|
-
|
|
1035
|
+
store[Value.new(:objkey2)].should == {"hashval3"=>"hashval4"}
|
|
1034
1036
|
sleep 2
|
|
1035
|
-
|
|
1037
|
+
store.delete(Value.new(:objkey2)).should == nil
|
|
1036
1038
|
end
|
|
1037
1039
|
end
|
|
1038
1040
|
|
|
@@ -1040,51 +1042,51 @@ end
|
|
|
1040
1042
|
|
|
1041
1043
|
shared_examples_for 'null_hashkey_stringvalue' do
|
|
1042
1044
|
it "reads from keys that are Hashs like a Hash" do
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
+
store[{"hashkey1"=>"hashkey2"}].should == nil
|
|
1046
|
+
store.load({"hashkey1"=>"hashkey2"}).should == nil
|
|
1045
1047
|
end
|
|
1046
1048
|
|
|
1047
1049
|
it "guarantees that the same String value is returned when setting a Hash key" do
|
|
1048
1050
|
value = "strval1"
|
|
1049
|
-
(
|
|
1051
|
+
(store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
|
|
1050
1052
|
end
|
|
1051
1053
|
|
|
1052
1054
|
it "returns false from key? if a Hash key is not available" do
|
|
1053
|
-
|
|
1055
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == false
|
|
1054
1056
|
end
|
|
1055
1057
|
|
|
1056
1058
|
it "returns nil from delete if an element for a Hash key does not exist" do
|
|
1057
|
-
|
|
1059
|
+
store.delete({"hashkey1"=>"hashkey2"}).should == nil
|
|
1058
1060
|
end
|
|
1059
1061
|
|
|
1060
1062
|
it "removes all Hash keys from the store with clear" do
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1063
|
+
store[{"hashkey1"=>"hashkey2"}] = "strval1"
|
|
1064
|
+
store[{"hashkey3"=>"hashkey4"}] = "strval2"
|
|
1065
|
+
store.clear.should equal(store)
|
|
1066
|
+
store.key?({"hashkey1"=>"hashkey2"}).should_not == true
|
|
1067
|
+
store.key?({"hashkey3"=>"hashkey4"}).should_not == true
|
|
1066
1068
|
end
|
|
1067
1069
|
|
|
1068
1070
|
it "fetches a Hash key with a default value with fetch, if the key is not available" do
|
|
1069
|
-
|
|
1071
|
+
store.fetch({"hashkey1"=>"hashkey2"}, "strval1").should == "strval1"
|
|
1070
1072
|
end
|
|
1071
1073
|
|
|
1072
1074
|
it "fetches a Hash key with a block with fetch, if the key is not available" do
|
|
1073
1075
|
key = {"hashkey1"=>"hashkey2"}
|
|
1074
1076
|
value = "strval1"
|
|
1075
|
-
|
|
1077
|
+
store.fetch(key) do |k|
|
|
1076
1078
|
k.should equal(key)
|
|
1077
1079
|
value
|
|
1078
1080
|
end.should equal(value)
|
|
1079
1081
|
end
|
|
1080
1082
|
|
|
1081
1083
|
it 'should accept options' do
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1084
|
+
store.key?({"hashkey1"=>"hashkey2"}, :option1 => 1).should == false
|
|
1085
|
+
store.load({"hashkey1"=>"hashkey2"}, :option2 => 2).should == nil
|
|
1086
|
+
store.fetch({"hashkey1"=>"hashkey2"}, nil, :option3 => 3).should == nil
|
|
1087
|
+
store.delete({"hashkey1"=>"hashkey2"}, :option4 => 4).should == nil
|
|
1088
|
+
store.clear(:option5 => 5).should equal(store)
|
|
1089
|
+
store.store({"hashkey1"=>"hashkey2"}, "strval1", :option6 => 6).should == "strval1"
|
|
1088
1090
|
end
|
|
1089
1091
|
end
|
|
1090
1092
|
|
|
@@ -1092,46 +1094,46 @@ end
|
|
|
1092
1094
|
|
|
1093
1095
|
shared_examples_for 'store_hashkey_stringvalue' do
|
|
1094
1096
|
it "writes String values to keys that are Hashs like a Hash" do
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1097
|
+
store[{"hashkey1"=>"hashkey2"}] = "strval1"
|
|
1098
|
+
store[{"hashkey1"=>"hashkey2"}].should == "strval1"
|
|
1099
|
+
store.load({"hashkey1"=>"hashkey2"}).should == "strval1"
|
|
1098
1100
|
end
|
|
1099
1101
|
|
|
1100
1102
|
it "returns true from key? if a Hash key is available" do
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
+
store[{"hashkey1"=>"hashkey2"}] = "strval1"
|
|
1104
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == true
|
|
1103
1105
|
end
|
|
1104
1106
|
|
|
1105
1107
|
it "stores String values with Hash keys with #store" do
|
|
1106
1108
|
value = "strval1"
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1109
|
+
store.store({"hashkey1"=>"hashkey2"}, value).should equal(value)
|
|
1110
|
+
store[{"hashkey1"=>"hashkey2"}].should == "strval1"
|
|
1111
|
+
store.load({"hashkey1"=>"hashkey2"}).should == "strval1"
|
|
1110
1112
|
end
|
|
1111
1113
|
|
|
1112
1114
|
it "removes and returns a String element with a Hash key from the backing store via delete if it exists" do
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1115
|
+
store[{"hashkey1"=>"hashkey2"}] = "strval1"
|
|
1116
|
+
store.delete({"hashkey1"=>"hashkey2"}).should == "strval1"
|
|
1117
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == false
|
|
1116
1118
|
end
|
|
1117
1119
|
|
|
1118
1120
|
it "overwrites existing String values with Hash" do
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1121
|
+
store[{"hashkey1"=>"hashkey2"}] = "strval1"
|
|
1122
|
+
store[{"hashkey1"=>"hashkey2"}].should == "strval1"
|
|
1123
|
+
store[{"hashkey1"=>"hashkey2"}] = "strval2"
|
|
1124
|
+
store[{"hashkey1"=>"hashkey2"}].should == "strval2"
|
|
1123
1125
|
end
|
|
1124
1126
|
|
|
1125
1127
|
it "does not run the block if the Hash key is available" do
|
|
1126
|
-
|
|
1128
|
+
store[{"hashkey1"=>"hashkey2"}] = "strval1"
|
|
1127
1129
|
unaltered = "unaltered"
|
|
1128
|
-
|
|
1130
|
+
store.fetch({"hashkey1"=>"hashkey2"}) { unaltered = "altered" }
|
|
1129
1131
|
unaltered.should == "unaltered"
|
|
1130
1132
|
end
|
|
1131
1133
|
|
|
1132
1134
|
it "fetches a Hash key with a default value with fetch, if the key is available" do
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
+
store[{"hashkey1"=>"hashkey2"}] = "strval1"
|
|
1136
|
+
store.fetch({"hashkey1"=>"hashkey2"}, "strval2").should == "strval1"
|
|
1135
1137
|
end
|
|
1136
1138
|
end
|
|
1137
1139
|
|
|
@@ -1140,8 +1142,8 @@ end
|
|
|
1140
1142
|
shared_examples_for 'returndifferent_hashkey_stringvalue' do
|
|
1141
1143
|
it "guarantees that a different String value is retrieved from the Hash key" do
|
|
1142
1144
|
value = "strval1"
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
+
store[{"hashkey1"=>"hashkey2"}] = "strval1"
|
|
1146
|
+
store[{"hashkey1"=>"hashkey2"}].should_not be_equal("strval1")
|
|
1145
1147
|
end
|
|
1146
1148
|
end
|
|
1147
1149
|
|
|
@@ -1149,63 +1151,63 @@ end
|
|
|
1149
1151
|
|
|
1150
1152
|
shared_examples_for 'expires_hashkey_stringvalue' do
|
|
1151
1153
|
it 'should support expires on store and #[]' do
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
+
store.store({"hashkey1"=>"hashkey2"}, "strval1", :expires => 2)
|
|
1155
|
+
store[{"hashkey1"=>"hashkey2"}].should == "strval1"
|
|
1154
1156
|
sleep 1
|
|
1155
|
-
|
|
1157
|
+
store[{"hashkey1"=>"hashkey2"}].should == "strval1"
|
|
1156
1158
|
sleep 2
|
|
1157
|
-
|
|
1159
|
+
store[{"hashkey1"=>"hashkey2"}].should == nil
|
|
1158
1160
|
end
|
|
1159
1161
|
|
|
1160
1162
|
it 'should support expires on store and load' do
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
+
store.store({"hashkey1"=>"hashkey2"}, "strval1", :expires => 2)
|
|
1164
|
+
store.load({"hashkey1"=>"hashkey2"}).should == "strval1"
|
|
1163
1165
|
sleep 1
|
|
1164
|
-
|
|
1166
|
+
store.load({"hashkey1"=>"hashkey2"}).should == "strval1"
|
|
1165
1167
|
sleep 2
|
|
1166
|
-
|
|
1168
|
+
store.load({"hashkey1"=>"hashkey2"}).should == nil
|
|
1167
1169
|
end
|
|
1168
1170
|
|
|
1169
1171
|
it 'should support expires on store and key?' do
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
+
store.store({"hashkey1"=>"hashkey2"}, "strval1", :expires => 2)
|
|
1173
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == true
|
|
1172
1174
|
sleep 1
|
|
1173
|
-
|
|
1175
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == true
|
|
1174
1176
|
sleep 2
|
|
1175
|
-
|
|
1177
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == false
|
|
1176
1178
|
end
|
|
1177
1179
|
|
|
1178
1180
|
it 'should support updating the expiration time in load' do
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
+
store.store({"hashkey3"=>"hashkey4"}, "strval2", :expires => 2)
|
|
1182
|
+
store[{"hashkey3"=>"hashkey4"}].should == "strval2"
|
|
1181
1183
|
sleep 1
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
+
store.load({"hashkey3"=>"hashkey4"}, :expires => 3).should == "strval2"
|
|
1185
|
+
store[{"hashkey3"=>"hashkey4"}].should == "strval2"
|
|
1184
1186
|
sleep 1
|
|
1185
|
-
|
|
1187
|
+
store[{"hashkey3"=>"hashkey4"}].should == "strval2"
|
|
1186
1188
|
sleep 3
|
|
1187
|
-
|
|
1189
|
+
store[{"hashkey3"=>"hashkey4"}].should == nil
|
|
1188
1190
|
end
|
|
1189
1191
|
|
|
1190
1192
|
it 'should support updating the expiration time in fetch' do
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
+
store.store({"hashkey1"=>"hashkey2"}, "strval1", :expires => 2)
|
|
1194
|
+
store[{"hashkey1"=>"hashkey2"}].should == "strval1"
|
|
1193
1195
|
sleep 1
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
+
store.fetch({"hashkey1"=>"hashkey2"}, nil, :expires => 3).should == "strval1"
|
|
1197
|
+
store[{"hashkey1"=>"hashkey2"}].should == "strval1"
|
|
1196
1198
|
sleep 1
|
|
1197
|
-
|
|
1199
|
+
store[{"hashkey1"=>"hashkey2"}].should == "strval1"
|
|
1198
1200
|
sleep 3
|
|
1199
|
-
|
|
1201
|
+
store[{"hashkey1"=>"hashkey2"}].should == nil
|
|
1200
1202
|
end
|
|
1201
1203
|
|
|
1202
1204
|
it 'should respect expires in delete' do
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
+
store.store({"hashkey3"=>"hashkey4"}, "strval2", :expires => 2)
|
|
1206
|
+
store[{"hashkey3"=>"hashkey4"}].should == "strval2"
|
|
1205
1207
|
sleep 1
|
|
1206
|
-
|
|
1208
|
+
store[{"hashkey3"=>"hashkey4"}].should == "strval2"
|
|
1207
1209
|
sleep 2
|
|
1208
|
-
|
|
1210
|
+
store.delete({"hashkey3"=>"hashkey4"}).should == nil
|
|
1209
1211
|
end
|
|
1210
1212
|
end
|
|
1211
1213
|
|
|
@@ -1213,51 +1215,51 @@ end
|
|
|
1213
1215
|
|
|
1214
1216
|
shared_examples_for 'null_hashkey_objectvalue' do
|
|
1215
1217
|
it "reads from keys that are Hashs like a Hash" do
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
+
store[{"hashkey1"=>"hashkey2"}].should == nil
|
|
1219
|
+
store.load({"hashkey1"=>"hashkey2"}).should == nil
|
|
1218
1220
|
end
|
|
1219
1221
|
|
|
1220
1222
|
it "guarantees that the same Object value is returned when setting a Hash key" do
|
|
1221
1223
|
value = Value.new(:objval1)
|
|
1222
|
-
(
|
|
1224
|
+
(store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
|
|
1223
1225
|
end
|
|
1224
1226
|
|
|
1225
1227
|
it "returns false from key? if a Hash key is not available" do
|
|
1226
|
-
|
|
1228
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == false
|
|
1227
1229
|
end
|
|
1228
1230
|
|
|
1229
1231
|
it "returns nil from delete if an element for a Hash key does not exist" do
|
|
1230
|
-
|
|
1232
|
+
store.delete({"hashkey1"=>"hashkey2"}).should == nil
|
|
1231
1233
|
end
|
|
1232
1234
|
|
|
1233
1235
|
it "removes all Hash keys from the store with clear" do
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1236
|
+
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval1)
|
|
1237
|
+
store[{"hashkey3"=>"hashkey4"}] = Value.new(:objval2)
|
|
1238
|
+
store.clear.should equal(store)
|
|
1239
|
+
store.key?({"hashkey1"=>"hashkey2"}).should_not == true
|
|
1240
|
+
store.key?({"hashkey3"=>"hashkey4"}).should_not == true
|
|
1239
1241
|
end
|
|
1240
1242
|
|
|
1241
1243
|
it "fetches a Hash key with a default value with fetch, if the key is not available" do
|
|
1242
|
-
|
|
1244
|
+
store.fetch({"hashkey1"=>"hashkey2"}, Value.new(:objval1)).should == Value.new(:objval1)
|
|
1243
1245
|
end
|
|
1244
1246
|
|
|
1245
1247
|
it "fetches a Hash key with a block with fetch, if the key is not available" do
|
|
1246
1248
|
key = {"hashkey1"=>"hashkey2"}
|
|
1247
1249
|
value = Value.new(:objval1)
|
|
1248
|
-
|
|
1250
|
+
store.fetch(key) do |k|
|
|
1249
1251
|
k.should equal(key)
|
|
1250
1252
|
value
|
|
1251
1253
|
end.should equal(value)
|
|
1252
1254
|
end
|
|
1253
1255
|
|
|
1254
1256
|
it 'should accept options' do
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1257
|
+
store.key?({"hashkey1"=>"hashkey2"}, :option1 => 1).should == false
|
|
1258
|
+
store.load({"hashkey1"=>"hashkey2"}, :option2 => 2).should == nil
|
|
1259
|
+
store.fetch({"hashkey1"=>"hashkey2"}, nil, :option3 => 3).should == nil
|
|
1260
|
+
store.delete({"hashkey1"=>"hashkey2"}, :option4 => 4).should == nil
|
|
1261
|
+
store.clear(:option5 => 5).should equal(store)
|
|
1262
|
+
store.store({"hashkey1"=>"hashkey2"}, Value.new(:objval1), :option6 => 6).should == Value.new(:objval1)
|
|
1261
1263
|
end
|
|
1262
1264
|
end
|
|
1263
1265
|
|
|
@@ -1265,46 +1267,46 @@ end
|
|
|
1265
1267
|
|
|
1266
1268
|
shared_examples_for 'store_hashkey_objectvalue' do
|
|
1267
1269
|
it "writes Object values to keys that are Hashs like a Hash" do
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1270
|
+
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval1)
|
|
1271
|
+
store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval1)
|
|
1272
|
+
store.load({"hashkey1"=>"hashkey2"}).should == Value.new(:objval1)
|
|
1271
1273
|
end
|
|
1272
1274
|
|
|
1273
1275
|
it "returns true from key? if a Hash key is available" do
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
+
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval1)
|
|
1277
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == true
|
|
1276
1278
|
end
|
|
1277
1279
|
|
|
1278
1280
|
it "stores Object values with Hash keys with #store" do
|
|
1279
1281
|
value = Value.new(:objval1)
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1282
|
+
store.store({"hashkey1"=>"hashkey2"}, value).should equal(value)
|
|
1283
|
+
store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval1)
|
|
1284
|
+
store.load({"hashkey1"=>"hashkey2"}).should == Value.new(:objval1)
|
|
1283
1285
|
end
|
|
1284
1286
|
|
|
1285
1287
|
it "removes and returns a Object element with a Hash key from the backing store via delete if it exists" do
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1288
|
+
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval1)
|
|
1289
|
+
store.delete({"hashkey1"=>"hashkey2"}).should == Value.new(:objval1)
|
|
1290
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == false
|
|
1289
1291
|
end
|
|
1290
1292
|
|
|
1291
1293
|
it "overwrites existing Object values with Hash" do
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1294
|
+
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval1)
|
|
1295
|
+
store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval1)
|
|
1296
|
+
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval2)
|
|
1297
|
+
store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval2)
|
|
1296
1298
|
end
|
|
1297
1299
|
|
|
1298
1300
|
it "does not run the block if the Hash key is available" do
|
|
1299
|
-
|
|
1301
|
+
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval1)
|
|
1300
1302
|
unaltered = "unaltered"
|
|
1301
|
-
|
|
1303
|
+
store.fetch({"hashkey1"=>"hashkey2"}) { unaltered = "altered" }
|
|
1302
1304
|
unaltered.should == "unaltered"
|
|
1303
1305
|
end
|
|
1304
1306
|
|
|
1305
1307
|
it "fetches a Hash key with a default value with fetch, if the key is available" do
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
+
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval1)
|
|
1309
|
+
store.fetch({"hashkey1"=>"hashkey2"}, Value.new(:objval2)).should == Value.new(:objval1)
|
|
1308
1310
|
end
|
|
1309
1311
|
end
|
|
1310
1312
|
|
|
@@ -1313,8 +1315,8 @@ end
|
|
|
1313
1315
|
shared_examples_for 'returndifferent_hashkey_objectvalue' do
|
|
1314
1316
|
it "guarantees that a different Object value is retrieved from the Hash key" do
|
|
1315
1317
|
value = Value.new(:objval1)
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
+
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval1)
|
|
1319
|
+
store[{"hashkey1"=>"hashkey2"}].should_not be_equal(Value.new(:objval1))
|
|
1318
1320
|
end
|
|
1319
1321
|
end
|
|
1320
1322
|
|
|
@@ -1322,63 +1324,63 @@ end
|
|
|
1322
1324
|
|
|
1323
1325
|
shared_examples_for 'expires_hashkey_objectvalue' do
|
|
1324
1326
|
it 'should support expires on store and #[]' do
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
+
store.store({"hashkey1"=>"hashkey2"}, Value.new(:objval1), :expires => 2)
|
|
1328
|
+
store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval1)
|
|
1327
1329
|
sleep 1
|
|
1328
|
-
|
|
1330
|
+
store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval1)
|
|
1329
1331
|
sleep 2
|
|
1330
|
-
|
|
1332
|
+
store[{"hashkey1"=>"hashkey2"}].should == nil
|
|
1331
1333
|
end
|
|
1332
1334
|
|
|
1333
1335
|
it 'should support expires on store and load' do
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
+
store.store({"hashkey1"=>"hashkey2"}, Value.new(:objval1), :expires => 2)
|
|
1337
|
+
store.load({"hashkey1"=>"hashkey2"}).should == Value.new(:objval1)
|
|
1336
1338
|
sleep 1
|
|
1337
|
-
|
|
1339
|
+
store.load({"hashkey1"=>"hashkey2"}).should == Value.new(:objval1)
|
|
1338
1340
|
sleep 2
|
|
1339
|
-
|
|
1341
|
+
store.load({"hashkey1"=>"hashkey2"}).should == nil
|
|
1340
1342
|
end
|
|
1341
1343
|
|
|
1342
1344
|
it 'should support expires on store and key?' do
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
+
store.store({"hashkey1"=>"hashkey2"}, Value.new(:objval1), :expires => 2)
|
|
1346
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == true
|
|
1345
1347
|
sleep 1
|
|
1346
|
-
|
|
1348
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == true
|
|
1347
1349
|
sleep 2
|
|
1348
|
-
|
|
1350
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == false
|
|
1349
1351
|
end
|
|
1350
1352
|
|
|
1351
1353
|
it 'should support updating the expiration time in load' do
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
+
store.store({"hashkey3"=>"hashkey4"}, Value.new(:objval2), :expires => 2)
|
|
1355
|
+
store[{"hashkey3"=>"hashkey4"}].should == Value.new(:objval2)
|
|
1354
1356
|
sleep 1
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
+
store.load({"hashkey3"=>"hashkey4"}, :expires => 3).should == Value.new(:objval2)
|
|
1358
|
+
store[{"hashkey3"=>"hashkey4"}].should == Value.new(:objval2)
|
|
1357
1359
|
sleep 1
|
|
1358
|
-
|
|
1360
|
+
store[{"hashkey3"=>"hashkey4"}].should == Value.new(:objval2)
|
|
1359
1361
|
sleep 3
|
|
1360
|
-
|
|
1362
|
+
store[{"hashkey3"=>"hashkey4"}].should == nil
|
|
1361
1363
|
end
|
|
1362
1364
|
|
|
1363
1365
|
it 'should support updating the expiration time in fetch' do
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
+
store.store({"hashkey1"=>"hashkey2"}, Value.new(:objval1), :expires => 2)
|
|
1367
|
+
store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval1)
|
|
1366
1368
|
sleep 1
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
+
store.fetch({"hashkey1"=>"hashkey2"}, nil, :expires => 3).should == Value.new(:objval1)
|
|
1370
|
+
store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval1)
|
|
1369
1371
|
sleep 1
|
|
1370
|
-
|
|
1372
|
+
store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval1)
|
|
1371
1373
|
sleep 3
|
|
1372
|
-
|
|
1374
|
+
store[{"hashkey1"=>"hashkey2"}].should == nil
|
|
1373
1375
|
end
|
|
1374
1376
|
|
|
1375
1377
|
it 'should respect expires in delete' do
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
+
store.store({"hashkey3"=>"hashkey4"}, Value.new(:objval2), :expires => 2)
|
|
1379
|
+
store[{"hashkey3"=>"hashkey4"}].should == Value.new(:objval2)
|
|
1378
1380
|
sleep 1
|
|
1379
|
-
|
|
1381
|
+
store[{"hashkey3"=>"hashkey4"}].should == Value.new(:objval2)
|
|
1380
1382
|
sleep 2
|
|
1381
|
-
|
|
1383
|
+
store.delete({"hashkey3"=>"hashkey4"}).should == nil
|
|
1382
1384
|
end
|
|
1383
1385
|
end
|
|
1384
1386
|
|
|
@@ -1386,51 +1388,51 @@ end
|
|
|
1386
1388
|
|
|
1387
1389
|
shared_examples_for 'null_hashkey_hashvalue' do
|
|
1388
1390
|
it "reads from keys that are Hashs like a Hash" do
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
+
store[{"hashkey1"=>"hashkey2"}].should == nil
|
|
1392
|
+
store.load({"hashkey1"=>"hashkey2"}).should == nil
|
|
1391
1393
|
end
|
|
1392
1394
|
|
|
1393
1395
|
it "guarantees that the same Hash value is returned when setting a Hash key" do
|
|
1394
1396
|
value = {"hashval1"=>"hashval2"}
|
|
1395
|
-
(
|
|
1397
|
+
(store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
|
|
1396
1398
|
end
|
|
1397
1399
|
|
|
1398
1400
|
it "returns false from key? if a Hash key is not available" do
|
|
1399
|
-
|
|
1401
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == false
|
|
1400
1402
|
end
|
|
1401
1403
|
|
|
1402
1404
|
it "returns nil from delete if an element for a Hash key does not exist" do
|
|
1403
|
-
|
|
1405
|
+
store.delete({"hashkey1"=>"hashkey2"}).should == nil
|
|
1404
1406
|
end
|
|
1405
1407
|
|
|
1406
1408
|
it "removes all Hash keys from the store with clear" do
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1409
|
+
store[{"hashkey1"=>"hashkey2"}] = {"hashval1"=>"hashval2"}
|
|
1410
|
+
store[{"hashkey3"=>"hashkey4"}] = {"hashval3"=>"hashval4"}
|
|
1411
|
+
store.clear.should equal(store)
|
|
1412
|
+
store.key?({"hashkey1"=>"hashkey2"}).should_not == true
|
|
1413
|
+
store.key?({"hashkey3"=>"hashkey4"}).should_not == true
|
|
1412
1414
|
end
|
|
1413
1415
|
|
|
1414
1416
|
it "fetches a Hash key with a default value with fetch, if the key is not available" do
|
|
1415
|
-
|
|
1417
|
+
store.fetch({"hashkey1"=>"hashkey2"}, {"hashval1"=>"hashval2"}).should == {"hashval1"=>"hashval2"}
|
|
1416
1418
|
end
|
|
1417
1419
|
|
|
1418
1420
|
it "fetches a Hash key with a block with fetch, if the key is not available" do
|
|
1419
1421
|
key = {"hashkey1"=>"hashkey2"}
|
|
1420
1422
|
value = {"hashval1"=>"hashval2"}
|
|
1421
|
-
|
|
1423
|
+
store.fetch(key) do |k|
|
|
1422
1424
|
k.should equal(key)
|
|
1423
1425
|
value
|
|
1424
1426
|
end.should equal(value)
|
|
1425
1427
|
end
|
|
1426
1428
|
|
|
1427
1429
|
it 'should accept options' do
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1430
|
+
store.key?({"hashkey1"=>"hashkey2"}, :option1 => 1).should == false
|
|
1431
|
+
store.load({"hashkey1"=>"hashkey2"}, :option2 => 2).should == nil
|
|
1432
|
+
store.fetch({"hashkey1"=>"hashkey2"}, nil, :option3 => 3).should == nil
|
|
1433
|
+
store.delete({"hashkey1"=>"hashkey2"}, :option4 => 4).should == nil
|
|
1434
|
+
store.clear(:option5 => 5).should equal(store)
|
|
1435
|
+
store.store({"hashkey1"=>"hashkey2"}, {"hashval1"=>"hashval2"}, :option6 => 6).should == {"hashval1"=>"hashval2"}
|
|
1434
1436
|
end
|
|
1435
1437
|
end
|
|
1436
1438
|
|
|
@@ -1438,46 +1440,46 @@ end
|
|
|
1438
1440
|
|
|
1439
1441
|
shared_examples_for 'store_hashkey_hashvalue' do
|
|
1440
1442
|
it "writes Hash values to keys that are Hashs like a Hash" do
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1443
|
+
store[{"hashkey1"=>"hashkey2"}] = {"hashval1"=>"hashval2"}
|
|
1444
|
+
store[{"hashkey1"=>"hashkey2"}].should == {"hashval1"=>"hashval2"}
|
|
1445
|
+
store.load({"hashkey1"=>"hashkey2"}).should == {"hashval1"=>"hashval2"}
|
|
1444
1446
|
end
|
|
1445
1447
|
|
|
1446
1448
|
it "returns true from key? if a Hash key is available" do
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
+
store[{"hashkey1"=>"hashkey2"}] = {"hashval1"=>"hashval2"}
|
|
1450
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == true
|
|
1449
1451
|
end
|
|
1450
1452
|
|
|
1451
1453
|
it "stores Hash values with Hash keys with #store" do
|
|
1452
1454
|
value = {"hashval1"=>"hashval2"}
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1455
|
+
store.store({"hashkey1"=>"hashkey2"}, value).should equal(value)
|
|
1456
|
+
store[{"hashkey1"=>"hashkey2"}].should == {"hashval1"=>"hashval2"}
|
|
1457
|
+
store.load({"hashkey1"=>"hashkey2"}).should == {"hashval1"=>"hashval2"}
|
|
1456
1458
|
end
|
|
1457
1459
|
|
|
1458
1460
|
it "removes and returns a Hash element with a Hash key from the backing store via delete if it exists" do
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1461
|
+
store[{"hashkey1"=>"hashkey2"}] = {"hashval1"=>"hashval2"}
|
|
1462
|
+
store.delete({"hashkey1"=>"hashkey2"}).should == {"hashval1"=>"hashval2"}
|
|
1463
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == false
|
|
1462
1464
|
end
|
|
1463
1465
|
|
|
1464
1466
|
it "overwrites existing Hash values with Hash" do
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1467
|
+
store[{"hashkey1"=>"hashkey2"}] = {"hashval1"=>"hashval2"}
|
|
1468
|
+
store[{"hashkey1"=>"hashkey2"}].should == {"hashval1"=>"hashval2"}
|
|
1469
|
+
store[{"hashkey1"=>"hashkey2"}] = {"hashval3"=>"hashval4"}
|
|
1470
|
+
store[{"hashkey1"=>"hashkey2"}].should == {"hashval3"=>"hashval4"}
|
|
1469
1471
|
end
|
|
1470
1472
|
|
|
1471
1473
|
it "does not run the block if the Hash key is available" do
|
|
1472
|
-
|
|
1474
|
+
store[{"hashkey1"=>"hashkey2"}] = {"hashval1"=>"hashval2"}
|
|
1473
1475
|
unaltered = "unaltered"
|
|
1474
|
-
|
|
1476
|
+
store.fetch({"hashkey1"=>"hashkey2"}) { unaltered = "altered" }
|
|
1475
1477
|
unaltered.should == "unaltered"
|
|
1476
1478
|
end
|
|
1477
1479
|
|
|
1478
1480
|
it "fetches a Hash key with a default value with fetch, if the key is available" do
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
+
store[{"hashkey1"=>"hashkey2"}] = {"hashval1"=>"hashval2"}
|
|
1482
|
+
store.fetch({"hashkey1"=>"hashkey2"}, {"hashval3"=>"hashval4"}).should == {"hashval1"=>"hashval2"}
|
|
1481
1483
|
end
|
|
1482
1484
|
end
|
|
1483
1485
|
|
|
@@ -1486,8 +1488,8 @@ end
|
|
|
1486
1488
|
shared_examples_for 'returndifferent_hashkey_hashvalue' do
|
|
1487
1489
|
it "guarantees that a different Hash value is retrieved from the Hash key" do
|
|
1488
1490
|
value = {"hashval1"=>"hashval2"}
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
+
store[{"hashkey1"=>"hashkey2"}] = {"hashval1"=>"hashval2"}
|
|
1492
|
+
store[{"hashkey1"=>"hashkey2"}].should_not be_equal({"hashval1"=>"hashval2"})
|
|
1491
1493
|
end
|
|
1492
1494
|
end
|
|
1493
1495
|
|
|
@@ -1495,63 +1497,63 @@ end
|
|
|
1495
1497
|
|
|
1496
1498
|
shared_examples_for 'expires_hashkey_hashvalue' do
|
|
1497
1499
|
it 'should support expires on store and #[]' do
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
+
store.store({"hashkey1"=>"hashkey2"}, {"hashval1"=>"hashval2"}, :expires => 2)
|
|
1501
|
+
store[{"hashkey1"=>"hashkey2"}].should == {"hashval1"=>"hashval2"}
|
|
1500
1502
|
sleep 1
|
|
1501
|
-
|
|
1503
|
+
store[{"hashkey1"=>"hashkey2"}].should == {"hashval1"=>"hashval2"}
|
|
1502
1504
|
sleep 2
|
|
1503
|
-
|
|
1505
|
+
store[{"hashkey1"=>"hashkey2"}].should == nil
|
|
1504
1506
|
end
|
|
1505
1507
|
|
|
1506
1508
|
it 'should support expires on store and load' do
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
+
store.store({"hashkey1"=>"hashkey2"}, {"hashval1"=>"hashval2"}, :expires => 2)
|
|
1510
|
+
store.load({"hashkey1"=>"hashkey2"}).should == {"hashval1"=>"hashval2"}
|
|
1509
1511
|
sleep 1
|
|
1510
|
-
|
|
1512
|
+
store.load({"hashkey1"=>"hashkey2"}).should == {"hashval1"=>"hashval2"}
|
|
1511
1513
|
sleep 2
|
|
1512
|
-
|
|
1514
|
+
store.load({"hashkey1"=>"hashkey2"}).should == nil
|
|
1513
1515
|
end
|
|
1514
1516
|
|
|
1515
1517
|
it 'should support expires on store and key?' do
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
+
store.store({"hashkey1"=>"hashkey2"}, {"hashval1"=>"hashval2"}, :expires => 2)
|
|
1519
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == true
|
|
1518
1520
|
sleep 1
|
|
1519
|
-
|
|
1521
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == true
|
|
1520
1522
|
sleep 2
|
|
1521
|
-
|
|
1523
|
+
store.key?({"hashkey1"=>"hashkey2"}).should == false
|
|
1522
1524
|
end
|
|
1523
1525
|
|
|
1524
1526
|
it 'should support updating the expiration time in load' do
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
+
store.store({"hashkey3"=>"hashkey4"}, {"hashval3"=>"hashval4"}, :expires => 2)
|
|
1528
|
+
store[{"hashkey3"=>"hashkey4"}].should == {"hashval3"=>"hashval4"}
|
|
1527
1529
|
sleep 1
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
+
store.load({"hashkey3"=>"hashkey4"}, :expires => 3).should == {"hashval3"=>"hashval4"}
|
|
1531
|
+
store[{"hashkey3"=>"hashkey4"}].should == {"hashval3"=>"hashval4"}
|
|
1530
1532
|
sleep 1
|
|
1531
|
-
|
|
1533
|
+
store[{"hashkey3"=>"hashkey4"}].should == {"hashval3"=>"hashval4"}
|
|
1532
1534
|
sleep 3
|
|
1533
|
-
|
|
1535
|
+
store[{"hashkey3"=>"hashkey4"}].should == nil
|
|
1534
1536
|
end
|
|
1535
1537
|
|
|
1536
1538
|
it 'should support updating the expiration time in fetch' do
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
+
store.store({"hashkey1"=>"hashkey2"}, {"hashval1"=>"hashval2"}, :expires => 2)
|
|
1540
|
+
store[{"hashkey1"=>"hashkey2"}].should == {"hashval1"=>"hashval2"}
|
|
1539
1541
|
sleep 1
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
+
store.fetch({"hashkey1"=>"hashkey2"}, nil, :expires => 3).should == {"hashval1"=>"hashval2"}
|
|
1543
|
+
store[{"hashkey1"=>"hashkey2"}].should == {"hashval1"=>"hashval2"}
|
|
1542
1544
|
sleep 1
|
|
1543
|
-
|
|
1545
|
+
store[{"hashkey1"=>"hashkey2"}].should == {"hashval1"=>"hashval2"}
|
|
1544
1546
|
sleep 3
|
|
1545
|
-
|
|
1547
|
+
store[{"hashkey1"=>"hashkey2"}].should == nil
|
|
1546
1548
|
end
|
|
1547
1549
|
|
|
1548
1550
|
it 'should respect expires in delete' do
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
+
store.store({"hashkey3"=>"hashkey4"}, {"hashval3"=>"hashval4"}, :expires => 2)
|
|
1552
|
+
store[{"hashkey3"=>"hashkey4"}].should == {"hashval3"=>"hashval4"}
|
|
1551
1553
|
sleep 1
|
|
1552
|
-
|
|
1554
|
+
store[{"hashkey3"=>"hashkey4"}].should == {"hashval3"=>"hashval4"}
|
|
1553
1555
|
sleep 2
|
|
1554
|
-
|
|
1556
|
+
store.delete({"hashkey3"=>"hashkey4"}).should == nil
|
|
1555
1557
|
end
|
|
1556
1558
|
end
|
|
1557
1559
|
|
|
@@ -1560,43 +1562,43 @@ end
|
|
|
1560
1562
|
shared_examples_for 'marshallable_key' do
|
|
1561
1563
|
it "refuses to #[] from keys that cannot be marshalled" do
|
|
1562
1564
|
expect do
|
|
1563
|
-
|
|
1565
|
+
store[Struct.new(:foo).new(:bar)]
|
|
1564
1566
|
end.to raise_error(marshal_error)
|
|
1565
1567
|
end
|
|
1566
1568
|
|
|
1567
1569
|
it "refuses to load from keys that cannot be marshalled" do
|
|
1568
1570
|
expect do
|
|
1569
|
-
|
|
1571
|
+
store.load(Struct.new(:foo).new(:bar))
|
|
1570
1572
|
end.to raise_error(marshal_error)
|
|
1571
1573
|
end
|
|
1572
1574
|
|
|
1573
1575
|
it "refuses to fetch from keys that cannot be marshalled" do
|
|
1574
1576
|
expect do
|
|
1575
|
-
|
|
1577
|
+
store.fetch(Struct.new(:foo).new(:bar), true)
|
|
1576
1578
|
end.to raise_error(marshal_error)
|
|
1577
1579
|
end
|
|
1578
1580
|
|
|
1579
1581
|
it "refuses to #[]= to keys that cannot be marshalled" do
|
|
1580
1582
|
expect do
|
|
1581
|
-
|
|
1583
|
+
store[Struct.new(:foo).new(:bar)] = 'value'
|
|
1582
1584
|
end.to raise_error(marshal_error)
|
|
1583
1585
|
end
|
|
1584
1586
|
|
|
1585
1587
|
it "refuses to store to keys that cannot be marshalled" do
|
|
1586
1588
|
expect do
|
|
1587
|
-
|
|
1589
|
+
store.store Struct.new(:foo).new(:bar), 'value'
|
|
1588
1590
|
end.to raise_error(marshal_error)
|
|
1589
1591
|
end
|
|
1590
1592
|
|
|
1591
1593
|
it "refuses to check for key? if the key cannot be marshalled" do
|
|
1592
1594
|
expect do
|
|
1593
|
-
|
|
1595
|
+
store.key? Struct.new(:foo).new(:bar)
|
|
1594
1596
|
end.to raise_error(marshal_error)
|
|
1595
1597
|
end
|
|
1596
1598
|
|
|
1597
1599
|
it "refuses to delete a key if the key cannot be marshalled" do
|
|
1598
1600
|
expect do
|
|
1599
|
-
|
|
1601
|
+
store.delete Struct.new(:foo).new(:bar)
|
|
1600
1602
|
end.to raise_error(marshal_error)
|
|
1601
1603
|
end
|
|
1602
1604
|
end
|