public void TestHasKeyWithoutPopulateAtStartupWithoutAwaitingIndex() { ICacheKey key = PutOneThingInCache(); // A new cache object in the same directory. Equivalent to a process restart. // Index may not yet updated. DiskStorageCache cache2 = CreateDiskCache(_storage, false); Assert.IsFalse(cache2.HasKeySync(key)); Assert.IsTrue(cache2.HasKey(key)); // HasKey() adds item to the index Assert.IsTrue(cache2.HasKeySync(key)); }
public void TestHasKeyWithPopulateAtStartupWithAwaitingIndex() { ICacheKey key = PutOneThingInCache(); // A new cache object in the same directory. Equivalent to a process restart. // Index should be updated. DiskStorageCache cache2 = CreateDiskCache(_storage, true); // Wait for index populated in cache before use of cache cache2.AwaitIndex(); Assert.IsTrue(cache2.HasKeySync(key)); Assert.IsTrue(cache2.HasKey(key)); }