예제 #1
0
    private static Boolean IsDerived(TemplateItem template, ID templateId)
    {
      if (template == null || ID.IsNullOrEmpty(templateId))
        return false;

      String key = String.Format("template_isderived_cache_{0},{1}", templateId, template.ID);
      if (MemoryCache.Default.Contains(key))
        return (Boolean) MemoryCache.Default[key];

      Boolean isDerived = template.IsDerived(templateId);
      if (!MemoryCache.Default.Contains(key))
      {
        MemoryCache.Default.Add(key, isDerived, new CacheItemPolicy {SlidingExpiration = TimeSpan.FromMinutes(30)});
      }
      return isDerived;
    }
예제 #2
0
        private static Boolean IsDerived(TemplateItem template, ID templateId)
        {
            if (template == null || ID.IsNullOrEmpty(templateId))
            {
                return(false);
            }

            String key = String.Format("template_isderived_cache_{0},{1}", templateId, template.ID);

            if (MemoryCache.Default.Contains(key))
            {
                return((Boolean)MemoryCache.Default[key]);
            }

            Boolean isDerived = template.IsDerived(templateId);

            if (!MemoryCache.Default.Contains(key))
            {
                MemoryCache.Default.Add(key, isDerived, new CacheItemPolicy {
                    SlidingExpiration = TimeSpan.FromMinutes(30)
                });
            }
            return(isDerived);
        }
예제 #3
0
 public static Template GetTemplate([NotNull] this TemplateItem template, [NotNull] ID templateId) => !template.IsDerived(templateId) ? null : TemplateManager.GetTemplate(template);