layeredcache: add Stop() and fix races in tests

worker goroutine running concurrently with tests would cause data race errors
when running tests with -race enabled.
This commit is contained in:
Anthony Romano
2017-02-10 10:26:41 -08:00
parent 12c7ffdc19
commit c69270ce08
3 changed files with 45 additions and 18 deletions

View File

@@ -96,10 +96,10 @@ func (_ SecondaryCacheTests) TrackerDoesNotCleanupHeldInstance() {
sCache := cache.GetOrCreateSecondaryCache("0")
item := sCache.TrackingGet("a")
time.Sleep(time.Millisecond * 10)
cache.gc()
gcLayeredCache(cache)
Expect(cache.Get("0", "a").Value()).To.Equal(0)
Expect(cache.Get("1", "a")).To.Equal(nil)
item.Release()
cache.gc()
gcLayeredCache(cache)
Expect(cache.Get("0", "a")).To.Equal(nil)
}