private void Indexer_IndexOperationComplete(object sender, EventArgs e)
        {
            var indexer = (IIndex)sender;

            _logger.LogDebug("Logging operation completed for index {IndexName}", indexer.Name);

            //ensure it's not listening anymore
            indexer.IndexOperationComplete -= Indexer_IndexOperationComplete;

            _logger.LogInformation($"Rebuilding index '{indexer.Name}' done.");

            var cacheKey = "temp_indexing_op_" + indexer.Name;

            _runtimeCache.Clear(cacheKey);
        }
Exemplo n.º 2
0
        private void Indexer_IndexOperationComplete(object sender, EventArgs e)
        {
            var indexer = (LuceneIndex)sender;

            _logger.Debug <ExamineManagementController>("Logging operation completed for index {IndexName}", indexer.Name);

            //ensure it's not listening anymore
            indexer.IndexOperationComplete -= Indexer_IndexOperationComplete;

            _logger
            .Info <ExamineManagementController
                   >($"Rebuilding index '{indexer.Name}' done, {indexer.CommitCount} items committed (can differ from the number of items in the index)");

            var cacheKey = "temp_indexing_op_" + indexer.Name;

            _runtimeCache.Clear(cacheKey);
        }
Exemplo n.º 3
0
    public override void Refresh(JsonPayload[] payloads)
    {
        AppCaches.RuntimeCache.ClearOfType <PublicAccessEntry>();
        AppCaches.RuntimeCache.ClearByKey(CacheKeys.ContentRecycleBinCacheKey);

        var             idsRemoved    = new HashSet <int>();
        IAppPolicyCache isolatedCache = AppCaches.IsolatedCaches.GetOrCreate <IContent>();

        foreach (JsonPayload payload in payloads.Where(x => x.Id != default))
        {
            // By INT Id
            isolatedCache.Clear(RepositoryCacheKeys.GetKey <IContent, int>(payload.Id));

            // By GUID Key
            isolatedCache.Clear(RepositoryCacheKeys.GetKey <IContent, Guid?>(payload.Key));

            _idKeyMap.ClearCache(payload.Id);

            // remove those that are in the branch
            if (payload.ChangeTypes.HasTypesAny(TreeChangeTypes.RefreshBranch | TreeChangeTypes.Remove))
            {
                var pathid = "," + payload.Id + ",";
                isolatedCache.ClearOfType <IContent>((k, v) => v.Path?.Contains(pathid) ?? false);
            }

            // if the item is being completely removed, we need to refresh the domains cache if any domain was assigned to the content
            if (payload.ChangeTypes.HasTypesAny(TreeChangeTypes.Remove))
            {
                idsRemoved.Add(payload.Id);
            }
        }

        if (idsRemoved.Count > 0)
        {
            var assignedDomains = _domainService.GetAll(true)
                                  ?.Where(x => x.RootContentId.HasValue && idsRemoved.Contains(x.RootContentId.Value)).ToList();

            if (assignedDomains?.Count > 0)
            {
                // TODO: this is duplicating the logic in DomainCacheRefresher BUT we cannot inject that into this because it it not registered explicitly in the container,
                // and we cannot inject the CacheRefresherCollection since that would be a circular reference, so what is the best way to call directly in to the
                // DomainCacheRefresher?
                ClearAllIsolatedCacheByEntityType <IDomain>();

                // note: must do what's above FIRST else the repositories still have the old cached
                // content and when the PublishedCachesService is notified of changes it does not see
                // the new content...
                // notify
                _publishedSnapshotService.Notify(assignedDomains
                                                 .Select(x => new DomainCacheRefresher.JsonPayload(x.Id, DomainChangeTypes.Remove)).ToArray());
            }
        }

        // note: must do what's above FIRST else the repositories still have the old cached
        // content and when the PublishedCachesService is notified of changes it does not see
        // the new content...

        // TODO: what about this?
        // should rename it, and then, this is only for Deploy, and then, ???
        // if (Suspendable.PageCacheRefresher.CanUpdateDocumentCache)
        //   ...
        NotifyPublishedSnapshotService(_publishedSnapshotService, AppCaches, payloads);

        base.Refresh(payloads);
    }