- 
                Notifications
    You must be signed in to change notification settings 
- Fork 164
Using LazyCache and Ninject
        Alastair Crabtree edited this page May 16, 2018 
        ·
        2 revisions
      
    NOTE: This quickstart is for LazyCache version 2.x
Add LazyCache.Ninject to your project (LazyCache.Ninject has a dependency on LazyCache so it should get installed automatically)
dotnet add MyProject package LazyCache.Ninjector in the Package Manager Console
Install-Package LazyCache.NinjectNext we demonstrate how to create a kernel, and activate and use an instance of the CachingService by requesting an implementation of IAppCache:
class Program
{
    public static void Main() 
    {
        IKernel kernel = new StandardKernel(new LazyCacheModule());
        var cache = kernel.Get<IAppCache>();
        cache.GetOrAdd("get-blog-pages", () => GetPages());
    }
    List<BlogPages> GetPages() 
    {
        // ..... get pages from a DB .....
    }
}