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))
            {
                _idKeyMap.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);
            }

            // refresh the models and cache
            _publishedModelFactory.WithSafeLiveFactoryReset(() =>
                                                            _publishedSnapshotService.Notify(payloads));

            // now we can trigger the event
            base.Refresh(payloads);
        }
        public override void Refresh(JsonPayload[] payloads)
        {
            if (payloads.Length == 0)
            {
                return;
            }

            var clearDictionary = false;
            var clearContent    = false;

            //clear all no matter what type of payload
            ClearAllIsolatedCacheByEntityType <ILanguage>();

            foreach (var payload in payloads)
            {
                switch (payload.ChangeType)
                {
                case LanguageChangeType.Update:
                    clearDictionary = true;
                    break;

                case LanguageChangeType.Remove:
                case LanguageChangeType.ChangeCulture:
                    clearDictionary = true;
                    clearContent    = true;
                    break;
                }
            }

            if (clearDictionary)
            {
                ClearAllIsolatedCacheByEntityType <IDictionaryItem>();
            }

            //if this flag is set, we will tell the published snapshot service to refresh ALL content and evict ALL IContent items
            if (clearContent)
            {
                //clear all domain caches
                RefreshDomains();
                ContentCacheRefresher.RefreshContentTypes(AppCaches); // we need to evict all IContent items
                //now refresh all nucache
                var clearContentPayload = new[] { new ContentCacheRefresher.JsonPayload(0, null, TreeChangeTypes.RefreshAll) };
                ContentCacheRefresher.NotifyPublishedSnapshotService(_publishedSnapshotService, AppCaches, clearContentPayload);
            }

            // then trigger event
            base.Refresh(payloads);
        }