Example #1
0
 /// <summary>
 /// Clears nodes from the storage
 /// </summary>
 public void Clear()
 {
     rwLock.AcquireWriterLock(-1);
     try
     {
         storage.Clear();
     }
     finally
     {
         rwLock.ReleaseLock();
     }
 }
Example #2
0
        public static async Task ReadTest(IKeyValueStorage storage)
        {
            await storage.Clear();

            var rd = new Random();

            for (int i = 0; i < 50; i++)
            {
                await storage.Set("somekey" + i, "qwwwwwwww");
            }

            await storage.Set("mykey", "val");

            for (int i = 0; i < 500; i++)
            {
                var val = await storage.Get <string>("mykey");

                Assert.AreEqual("val", val);
            }
            await storage.Clear();
        }
Example #3
0
        public static async Task SynchronizationTest(IKeyValueStorage storage)
        {
            await storage.Clear();

            var rd = new Random();

            for (int i = 0; i < 50; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    await storage.Set("key" + rd.Next(10000, 99999).ToString(), "qwwwwwwww");
                }


                string key     = "key" + i.ToString();
                string prevKey = "key" + (i - 1).ToString();

                //await storage.Clear();
                await storage.Set(prevKey, null);

                var prevVal = await storage.GetOrDefault <string>(prevKey);

                if (prevVal != null)
                {
                    Assert.Fail($"Not null value after cleaning. Iteration {i}.");
                }

                await storage.Set(key, "val");

                var val = await storage.Get <string>(key);

                Assert.AreEqual(val, "val");
                var isContains = await storage.ContainsKey(key);

                Assert.IsTrue(isContains);
            }

            await storage.Clear();
        }
 /// <summary>
 /// Clears nodes from the storage
 /// </summary>
 public void Clear()
 {
     storage.Clear();
 }