@@ -27,10 +27,11 @@ public void AddCacheDependencies(IEnumerable<string>? tags)
2727 {
2828 tags ??= [ ] ;
2929
30- // NOTE: hybridCache doesn't have a synchronous API!! So ... we will wait!
31-
32- var currentTags = await hybridCache . GetOrCreateAsync < List < string > > ( TagsCacheKey ,
33- factory => ValueTask . FromResult < List < string > > ( [ ] ) ) ;
30+ var currentTags = hybridCache . GetOrCreateAsync < List < string > > ( TagsCacheKey ,
31+ factory => ValueTask . FromResult < List < string > > ( [ ] ) )
32+ . Preserve ( )
33+ . GetAwaiter ( )
34+ . GetResult ( ) ;
3435
3536 foreach ( var tag in tags )
3637 {
@@ -40,7 +41,7 @@ public void AddCacheDependencies(IEnumerable<string>? tags)
4041 }
4142 }
4243
43- hybridCache . SetAsync ( TagsCacheKey , currentTags , Options ) ;
44+ hybridCache . SetAsync ( TagsCacheKey , currentTags , Options ) . Preserve ( ) . GetAwaiter ( ) . GetResult ( ) ;
4445 }
4546
4647 /// <summary>
@@ -51,22 +52,27 @@ public void RemoveCacheDependencies(IEnumerable<string>? tags)
5152 {
5253 tags ??= [ ] ;
5354
54- var currentTags = await hybridCache . GetOrCreateAsync < List < string > > ( TagsCacheKey ,
55- factory => ValueTask . FromResult < List < string > > ( [ ] ) ) ;
55+ var currentTags = hybridCache . GetOrCreateAsync < List < string > > ( TagsCacheKey ,
56+ factory => ValueTask . FromResult < List < string > > ( [ ] ) )
57+ . Preserve ( )
58+ . GetAwaiter ( )
59+ . GetResult ( ) ;
5660
5761 foreach ( var tag in tags )
5862 {
5963 currentTags . Remove ( tag ) ;
6064 }
6165
62- hybridCache . SetAsync ( TagsCacheKey , currentTags , Options ) ;
66+ hybridCache . SetAsync ( TagsCacheKey , currentTags , Options ) . Preserve ( ) . GetAwaiter ( ) . GetResult ( ) ;
6367 }
6468
6569 /// <summary>
6670 /// Returns the cached entries added by this library.
6771 /// </summary>
6872 public ISet < string > GetAllCacheDependencies ( )
6973 => new HashSet < string > (
70- await hybridCache . GetOrCreateAsync < List < string > > ( TagsCacheKey ,
71- factory => ValueTask . FromResult < List < string > > ( [ ] ) ) , StringComparer . Ordinal ) ;
74+ hybridCache . GetOrCreateAsync < List < string > > ( TagsCacheKey , factory => ValueTask . FromResult < List < string > > ( [ ] ) )
75+ . Preserve ( )
76+ . GetAwaiter ( )
77+ . GetResult ( ) , StringComparer . Ordinal ) ;
7278}
0 commit comments