예제 #1
0
        public void CacheTemplate(string key, Func <ITemplatePage> pageFactory, IChangeToken expirationToken = null)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException(nameof(key));
            }

            if (pageFactory == null)
            {
                throw new ArgumentNullException(nameof(pageFactory));
            }

            var cacheEntryOptions = new MemoryCacheEntryOptions();

            if (expirationToken != null)
            {
                cacheEntryOptions.ExpirationTokens.Add(expirationToken);
            }

            var cacheItem = new TemplateCacheItem(key, pageFactory);

            LookupCache.Set(key, cacheItem, cacheEntryOptions);
        }
 public TemplateCacheLookupResult(TemplateCacheItem cacheItem)
 {
     Template = cacheItem;
     Success  = true;
 }