@@ -150,8 +150,12 @@ describe Cache do
150150 store = Cache ::RedisCacheStore (String , String ).new(12 .hours)
151151 store.write(" foo" , " bar" , expires_in: 1 .second)
152152
153+ store.keys.should eq(Set {" foo" })
154+
153155 sleep 2 .seconds
154156
157+ store.keys.should be_empty
158+
155159 value = store.read(" foo" )
156160 value.should eq(nil )
157161 end
@@ -167,7 +171,7 @@ describe Cache do
167171
168172 value = store.read(" foo" )
169173 value.should eq(nil )
170- store.keys.should eq( Set ( String ).new)
174+ store.keys.should be_empty
171175 end
172176
173177 it " deletes all items from the cache" do
@@ -247,10 +251,16 @@ describe Cache do
247251
248252 context " with namespace" do
249253 it " write" do
250- store = Cache ::RedisCacheStore (String , String ).new(12 .hours, namespace: " myapp-cache" )
251- store.write(" foo" , " bar" , expires_in: 1 .minute)
254+ store1 = Cache ::RedisCacheStore (String , String ).new(12 .hours, namespace: " myapp-cache" )
255+ store1 .write(" foo1" , " bar" , expires_in: 1 .minute)
256+
257+ store2 = Cache ::RedisCacheStore (String , String ).new(12 .hours)
258+ store2 .write(" foo2" , " baz" , expires_in: 1 .minute)
259+
260+ store1 .keys.should eq(Set {" myapp-cache:foo1" })
261+ store2 .keys.should eq(Set {" myapp-cache:foo1" , " foo2" })
252262
253- value = store .fetch(" foo" ) { " bar" }
263+ value = store 1 .fetch(" foo" ) { " bar" }
254264 value.should eq(" bar" )
255265 end
256266
0 commit comments