Пример #1
0
        static void ReadAndUpdateCacheSimple(MyCache cache)
        {
            var cachedItems = cache.GetCachedItems();

            foreach (var item in cachedItems)
            {
                Console.WriteLine($"found item with id {item.Id } and name {item.Name}");
            }

            cache.RefreshCachedItems();
            cachedItems = cache.GetCachedItems();

            foreach (var item in cachedItems)
            {
                Console.WriteLine($"found item with id {item.Id } and name {item.Name}");
            }
        }
Пример #2
0
        public static void ReadCacheAndCountItems(MyCache cache, int i)
        {
            Random rnd   = new Random();
            int    rnNum = rnd.Next(1, 20);

            Thread.Sleep(200 * rnNum);

            var itemCount = cache.GetCachedItems().Count;

            Console.WriteLine($"Task {i}: found {itemCount} items in cache after sleeping for {200 * rnNum}");
        }