Exemplo n.º 1
0
        static void Main()
        {
            //check one - basic LazyCache
            IAppCache cache = new CachingService(CachingService.DefaultCacheProvider);

            var item = cache.GetOrAdd("Program.Main.Person", () => Tuple.Create("Joe Blogs", DateTime.UtcNow));

            System.Console.WriteLine(item.Item1);

            //check two - using Ninject
            IKernel kernel = new StandardKernel(new LazyCacheModule());

            cache = kernel.Get <IAppCache>();

            item = cache.GetOrAdd("Program.Main.Person", () => Tuple.Create("Joe Blogs", DateTime.UtcNow));

            System.Console.WriteLine(item.Item1);

            System.Console.WriteLine("Enumerating keys...");
            foreach (var key in cache.GetCacheKeys().Keys)
            {
                System.Console.WriteLine($"{key}");
            }
            System.Console.WriteLine("Finished enumerating keys...");

            System.Console.ReadLine();
        }