public override void Refresh(JsonPayload[] payloads)
        {
            // TODO: refactor
            // we should NOT directly clear caches here, but instead ask whatever class
            // is managing the cache to please clear that cache properly

            _contentTypeCommonRepository.ClearCache(); // always

            if (payloads.Any(x => x.ItemType == typeof(IContentType).Name))
            {
                ClearAllIsolatedCacheByEntityType <IContent>();
                ClearAllIsolatedCacheByEntityType <IContentType>();
            }

            if (payloads.Any(x => x.ItemType == typeof(IMediaType).Name))
            {
                ClearAllIsolatedCacheByEntityType <IMedia>();
                ClearAllIsolatedCacheByEntityType <IMediaType>();
            }

            if (payloads.Any(x => x.ItemType == typeof(IMemberType).Name))
            {
                ClearAllIsolatedCacheByEntityType <IMember>();
                ClearAllIsolatedCacheByEntityType <IMemberType>();
            }

            foreach (var id in payloads.Select(x => x.Id))
            {
                _idkMap.ClearCache(id);
            }

            if (payloads.Any(x => x.ItemType == typeof(IContentType).Name))
            {
                // don't try to be clever - refresh all
                ContentCacheRefresher.RefreshContentTypes(AppCaches);
            }

            if (payloads.Any(x => x.ItemType == typeof(IMediaType).Name))
            {
                // don't try to be clever - refresh all
                MediaCacheRefresher.RefreshMediaTypes(AppCaches);
            }

            if (payloads.Any(x => x.ItemType == typeof(IMemberType).Name))
            {
                // don't try to be clever - refresh all
                MemberCacheRefresher.RefreshMemberTypes(AppCaches);
            }

            // we have to refresh models before we notify the published snapshot
            // service of changes, else factories may try to rebuild models while
            // we are using the database to load content into caches

            _publishedModelFactory.WithSafeLiveFactory(() =>
                                                       _publishedSnapshotService.Notify(payloads));

            // now we can trigger the event
            base.Refresh(payloads);
        }
Пример #2
0
        public override void Refresh(JsonPayload[] payloads)
        {
            // TODO: refactor
            // we should NOT directly clear caches here, but instead ask whatever class
            // is managing the cache to please clear that cache properly

            if (payloads.Any(x => x.ItemType == typeof(IContentType).Name))
            {
                ClearAllIsolatedCacheByEntityType <IContent>();
                ClearAllIsolatedCacheByEntityType <IContentType>();
            }

            if (payloads.Any(x => x.ItemType == typeof(IMediaType).Name))
            {
                ClearAllIsolatedCacheByEntityType <IMedia>();
                ClearAllIsolatedCacheByEntityType <IMediaType>();
            }

            if (payloads.Any(x => x.ItemType == typeof(IMemberType).Name))
            {
                ClearAllIsolatedCacheByEntityType <IMember>();
                ClearAllIsolatedCacheByEntityType <IMemberType>();
            }

            foreach (var id in payloads.Select(x => x.Id))
            {
                _idkMap.ClearCache(id);
            }

            if (payloads.Any(x => x.ItemType == typeof(IContentType).Name))
            {
                // don't try to be clever - refresh all
                ContentCacheRefresher.RefreshContentTypes(CacheHelper);
            }

            if (payloads.Any(x => x.ItemType == typeof(IMediaType).Name))
            {
                // don't try to be clever - refresh all
                MediaCacheRefresher.RefreshMediaTypes(CacheHelper);
            }

            if (payloads.Any(x => x.ItemType == typeof(IMemberType).Name))
            {
                // don't try to be clever - refresh all
                MemberCacheRefresher.RefreshMemberTypes(CacheHelper);
            }

            // notify
            _publishedSnapshotService.Notify(payloads);

            // now we can trigger the event
            base.Refresh(payloads);
        }
 public static void RemoveMediaCachePermanently(this DistributedCache dc, params int[] mediaIds)
 {
     dc.RefreshByJson(DistributedCache.MediaCacheRefresherGuid, MediaCacheRefresher.SerializeToJsonPayloadForPermanentDeletion(mediaIds));
 }
 public static void RemoveMediaCacheAfterRecycling(this DistributedCache dc, params MoveEventInfo <IMedia>[] media)
 {
     dc.RefreshByJson(DistributedCache.MediaCacheRefresherGuid, MediaCacheRefresher.SerializeToJsonPayloadForMoving(MediaCacheRefresher.OperationType.Trashed, media));
 }
 public static void RefreshMediaCache(this DistributedCache dc, params IMedia[] media)
 {
     dc.RefreshByJson(DistributedCache.MediaCacheRefresherGuid, MediaCacheRefresher.SerializeToJsonPayload(MediaCacheRefresher.OperationType.Saved, media));
 }
Пример #6
0
 /// <summary>
 /// Removes the cache amongst servers for media items
 /// </summary>
 /// <param name="dc"></param>
 /// <param name="media"></param>
 public static void RemoveMediaCache(this DistributedCache dc, params IMedia[] media)
 {
     dc.RefreshByJson(new Guid(DistributedCache.MediaCacheRefresherId),
                      MediaCacheRefresher.SerializeToJsonPayload(media));
 }