FIX: distributed cache leak and potential infinite loop

This commit is contained in:
Sam
2014-11-13 12:41:35 +11:00
parent 8783ff11be
commit 564fb0b100
2 changed files with 41 additions and 1 deletions

View File

@ -11,6 +11,37 @@ describe DistributedCache do
DistributedCache.new("test")
end
def add_throw_away_cache
c = DistributedCache.new("test")
c["foofoo"] = "bar"
end
it 'correctly clears up caches' do
start = DistributedCache.subscribers.length
add_throw_away_cache
GC.start
cache1["foofoo"] = "bar1"
wait_for do
cache2["foofoo"] == "bar1"
end
DistributedCache.subscribers.length.should == start
end
it 'does not leak state across caches' do
c2 = DistributedCache.new("test1")
c3 = DistributedCache.new("test1")
c2["hi"] = "hi"
wait_for do
c3["hi"] == "hi"
end
Thread.pass
cache1["hi"].should == nil
end
it 'allows coerces symbol keys to strings' do
cache1[:key] = "test"
cache1["key"].should == "test"