Introduction to ICacheManager

ICacheManager is a interface in namespace Aaron.Core.Caching; it use ObjectCache that's in namespace System.Runtime.Caching to cache any object. This action is useful for data loading, means it saves the page load time.

Easy to use, you just do as follows:
public class ArticleService : IArticleService
{
    private readonly ICacheManager _cache;

    public ArticleService(ICacheManager cache)
    {
        _cache = cache;
    }
}
    public IList<Article> GetAllArticles()
    {
        return _cache.Get("key_of_cache", () =>
        {
            // Write something here...
        });
    }
Get is a method in pointer of ICacheManager that include the following attributes:
  1. string key: it's a key to identify a value in ObjectCache.
  2. Func<T> acquire: it's a delegate to encapsulates a method and returns a T object.
public static T Get<T>(this ICacheManager cacheManager, string key, Func<T> acquire)
I hope this article helpful for you, thanks for the reference. In the next article, we shall discuss the CRUD with Aaron.