Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firstboot, publish cache refresh when content is imported. #710

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading