Skip to content

Commit 58cc769

Browse files
authored
Adds configuration for document and media hybrid cache seed batch size (#19894)
Adds configuration for document and media hybrid cache seed batch size.
1 parent 937f4b8 commit 58cc769

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

src/Umbraco.Core/Models/CacheSettings.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,39 @@ public class CacheSettings
88
{
99
internal const int StaticDocumentBreadthFirstSeedCount = 100;
1010
internal const int StaticMediaBreadthFirstSeedCount = 100;
11+
internal const int StaticDocumentSeedBatchSize = 100;
12+
internal const int StaticMediaSeedBatchSize = 100;
1113

1214
/// <summary>
13-
/// Gets or sets a value for the collection of content type ids to always have in the cache.
15+
/// Gets or sets a value for the collection of content type ids to always have in the cache.
1416
/// </summary>
1517
public List<Guid> ContentTypeKeys { get; set; } =
1618
new();
1719

20+
/// <summary>
21+
/// Gets or sets a value for the document breadth first seed count.
22+
/// </summary>
1823
[DefaultValue(StaticDocumentBreadthFirstSeedCount)]
1924
public int DocumentBreadthFirstSeedCount { get; set; } = StaticDocumentBreadthFirstSeedCount;
2025

26+
/// <summary>
27+
/// Gets or sets a value for the media breadth first seed count.
28+
/// </summary>
2129
[DefaultValue(StaticMediaBreadthFirstSeedCount)]
2230
public int MediaBreadthFirstSeedCount { get; set; } = StaticDocumentBreadthFirstSeedCount;
2331

32+
/// <summary>
33+
/// Gets or sets a value for the document seed batch size.
34+
/// </summary>
35+
[DefaultValue(StaticDocumentSeedBatchSize)]
36+
public int DocumentSeedBatchSize { get; set; } = StaticDocumentSeedBatchSize;
37+
38+
/// <summary>
39+
/// Gets or sets a value for the media seed batch size.
40+
/// </summary>
41+
[DefaultValue(StaticMediaSeedBatchSize)]
42+
public int MediaSeedBatchSize { get; set; } = StaticMediaSeedBatchSize;
43+
2444
public CacheEntry Entry { get; set; } = new CacheEntry();
2545

2646
public class CacheEntry

src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ public async Task SeedAsync(CancellationToken cancellationToken)
195195
sw.Start();
196196
#endif
197197

198-
const int GroupSize = 100;
199-
foreach (IEnumerable<Guid> group in SeedKeys.InGroupsOf(GroupSize))
198+
foreach (IEnumerable<Guid> group in SeedKeys.InGroupsOf(_cacheSettings.DocumentSeedBatchSize))
200199
{
201200
var uncachedKeys = new HashSet<Guid>();
202201
foreach (Guid key in group)

src/Umbraco.PublishedCache.HybridCache/Services/MediaCacheService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ public async Task SeedAsync(CancellationToken cancellationToken)
158158
sw.Start();
159159
#endif
160160

161-
const int GroupSize = 100;
162-
foreach (IEnumerable<Guid> group in SeedKeys.InGroupsOf(GroupSize))
161+
foreach (IEnumerable<Guid> group in SeedKeys.InGroupsOf(_cacheSettings.MediaSeedBatchSize))
163162
{
164163
var uncachedKeys = new HashSet<Guid>();
165164
foreach (Guid key in group)

0 commit comments

Comments
 (0)