6
6
using Imazen . Common . Extensibility . Support ;
7
7
using Imazen . Common . Issues ;
8
8
using Imazen . HybridCache . MetaStore ;
9
+ using Microsoft . Extensions . Hosting ;
9
10
using Microsoft . Extensions . Logging ;
10
11
11
12
namespace Imazen . HybridCache
12
13
{
13
- public class HybridCache : IBlobCache
14
+ public class HybridCache : IBlobCache , IHostedService
14
15
{
15
16
private readonly IReLogger logger ;
16
17
private HashBasedPathBuilder PathBuilder { get ; }
@@ -97,10 +98,8 @@ private void FillMoveFileOverwriteFunc(HybridCacheAdvancedOptions options)
97
98
File . Move ( from , to ) ;
98
99
#endif
99
100
} ;
100
- options . CleanupManagerOptions . MoveFileOverwriteFunc = options . CleanupManagerOptions . MoveFileOverwriteFunc ??
101
- options . AsyncCacheOptions . MoveFileOverwriteFunc ?? moveFileOverwriteFunc ;
102
- options . AsyncCacheOptions . MoveFileOverwriteFunc = options . AsyncCacheOptions . MoveFileOverwriteFunc ??
103
- options . CleanupManagerOptions . MoveFileOverwriteFunc ?? moveFileOverwriteFunc ;
101
+ options . CleanupManagerOptions . MoveFileOverwriteFunc ??= options . AsyncCacheOptions . MoveFileOverwriteFunc ?? moveFileOverwriteFunc ;
102
+ options . AsyncCacheOptions . MoveFileOverwriteFunc ??= options . CleanupManagerOptions . MoveFileOverwriteFunc ?? moveFileOverwriteFunc ;
104
103
}
105
104
106
105
@@ -118,7 +117,10 @@ public async Task StopAsync(CancellationToken cancellationToken)
118
117
{
119
118
logger ? . LogInformation ( "HybridCache is shutting down..." ) ;
120
119
var sw = Stopwatch . StartNew ( ) ;
121
- await SupportData . AwaitBeforeShutdown ( ) ;
120
+ if ( SupportData != null )
121
+ {
122
+ await SupportData . AwaitBeforeShutdown ( ) ;
123
+ }
122
124
await Database . StopAsync ( cancellationToken ) ;
123
125
sw . Stop ( ) ;
124
126
logger ? . LogInformation ( "HybridCache shut down in {ShutdownTime}" , sw . Elapsed ) ;
0 commit comments