Exemplo n.º 1
0
        public string GetRouteById(bool preview, int contentId, string culture = null)
        {
            var cache = (preview == false || PublishedSnapshotService.FullCacheWhenPreviewing) ? _elementsCache : _snapshotCache;
            var key   = CacheKeys.ContentCacheRouteByContent(contentId, preview, culture);

            return(cache.GetCacheItem <string>(key, () => GetRouteByIdInternal(preview, contentId, null, culture)));
        }
Exemplo n.º 2
0
        private string GetProfileNameById(int id)
        {
            var cache = GetCurrentSnapshotCache();

            return(cache == null
                ? GetProfileNameByIdNoCache(id)
                : (string)cache.Get(CacheKeys.ProfileName(id), () => GetProfileNameByIdNoCache(id)));
        }
Exemplo n.º 3
0
 public IPublishedContent /*IPublishedMember*/ GetByUsername(string username)
 {
     return(GetCacheItem(CacheKeys.MemberCacheMember("ByUsername", _previewDefault, username), () =>
     {
         EnsureProvider();
         var member = _memberService.GetByUsername(username);
         return member == null ? null : GetById(member, _previewDefault);
     }));
 }
Exemplo n.º 4
0
 public IPublishedContent /*IPublishedMember*/ GetByProviderKey(object key)
 {
     return(GetCacheItem(CacheKeys.MemberCacheMember("ByProviderKey", _previewDefault, key), () =>
     {
         EnsureProvider();
         var member = _memberService.GetByProviderKey(key);
         return member == null ? null : GetById(member, _previewDefault);
     }));
 }
Exemplo n.º 5
0
 public IPublishedContent /*IPublishedMember*/ GetByEmail(string email)
 {
     return(GetCacheItem(CacheKeys.MemberCacheMember("ByEmail", _previewDefault, email), () =>
     {
         EnsureProvider();
         var member = _memberService.GetByEmail(email);
         return member == null ? null : GetById(member, _previewDefault);
     }));
 }
Exemplo n.º 6
0
 public IPublishedContent /*IPublishedMember*/ GetById(int memberId)
 {
     return(GetCacheItem(CacheKeys.MemberCacheMember("ById", _previewDefault, memberId), () =>
     {
         EnsureProvider();
         var member = _memberService.GetById(memberId);
         return member == null
                 ? null
                 : PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor, VariationContextAccessor, _umbracoContextAccessor);
     }));
 }
Exemplo n.º 7
0
        public IPublishedContent GetByRoute(bool preview, string route, bool?hideTopLevelNode = null, string culture = null)
        {
            if (route == null)
            {
                throw new ArgumentNullException(nameof(route));
            }

            var cache = preview == false || PublishedSnapshotService.FullCacheWhenPreviewing ? _elementsCache : _snapshotCache;
            var key   = CacheKeys.ContentCacheContentByRoute(route, preview, culture);

            return(cache.GetCacheItem <IPublishedContent>(key, () => GetByRouteInternal(preview, route, hideTopLevelNode, culture)));
        }
Exemplo n.º 8
0
        public override IEnumerable <IPublishedContent> GetAtRoot(bool preview)
        {
            if (PublishedSnapshotService.CacheContentCacheRoots == false)
            {
                return(GetAtRootNoCache(preview));
            }

            var cache = preview == false || PublishedSnapshotService.FullCacheWhenPreviewing
                ? _elementsCache
                : _snapshotCache;

            if (cache == null)
            {
                return(GetAtRootNoCache(preview));
            }

            // note: ToArray is important here, we want to cache the result, not the function!
            return((IEnumerable <IPublishedContent>)cache.Get(
                       CacheKeys.ContentCacheRoots(preview),
                       () => GetAtRootNoCache(preview).ToArray()));
        }
Exemplo n.º 9
0
 private IPublishedContent /*IPublishedMember*/ GetById(IMember member, bool previewing)
 {
     return(GetCacheItem(CacheKeys.MemberCacheMember("ById", _previewDefault, member.Id), () =>
                         PublishedMember.Create(member, GetContentType(member.ContentTypeId), previewing, _publishedSnapshotAccessor, VariationContextAccessor, _umbracoContextAccessor)));
 }