Skip to content

Commit

Permalink
Firstboot, publish cache refresh when content is imported.
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Feb 13, 2025
1 parent 0e8f89d commit 3fd689b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions uSync.BackOffice/Services/SyncService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public partial class SyncService : ISyncService

private readonly IAppCache _appCache;

private readonly DistributedCache _distributedCache;

/// <summary>
/// Create a new uSyncService (done via DI)
/// </summary>
Expand All @@ -69,7 +71,8 @@ public SyncService(
AppCaches appCaches,
ICoreScopeProvider scopeProvider,
ILoggerFactory loggerFactory,
IBackgroundTaskQueue backgroundTaskQueue)
IBackgroundTaskQueue backgroundTaskQueue,
DistributedCache distributedCache)
{
this._logger = logger;

Expand All @@ -88,7 +91,7 @@ public SyncService(
_loggerFactory = loggerFactory;

_backgroundTaskQueue = backgroundTaskQueue;

_distributedCache = distributedCache;
}

/// <inheritdoc/>>
Expand Down Expand Up @@ -189,7 +192,15 @@ public async Task<IEnumerable<uSyncAction>> StartupImportAsync(string[] folders,
handlerOptions ??= new SyncHandlerOptions();
handlerOptions.Action = HandlerActions.Import;
var handlers = _handlerFactory.GetValidHandlers(handlerOptions);
return await ImportAsync(folders, force, handlers, handlerOptions, callbacks);

var changes = await ImportAsync(folders, force, handlers, handlerOptions, callbacks);

// on first boot, we refresh the snapshot cache if we have imported any content
// just because it seems not to refresh as part of the boot.
if (changes.Any(x => x.Change > ChangeType.NoChange && x.ItemType == "IContent"))
_distributedCache.RefreshAllPublishedSnapshot();

return changes;
}

/// <inheritdoc/>>
Expand Down

0 comments on commit 3fd689b

Please sign in to comment.