Example #1
0
        public async Task StopAsync(CancellationToken cancellationToken)
        {
            logger?.LogInformation("HybridCache is shutting down...");
            var sw = Stopwatch.StartNew();
            await AsyncCache.AwaitEnqueuedTasks();

            await Database.StopAsync(cancellationToken);

            sw.Stop();
            logger?.LogInformation("HybridCache shut down in {ShutdownTime}", sw.Elapsed);
        }
Example #2
0
        public HybridCache(ICacheDatabase cacheDatabase, HybridCacheOptions options, ILogger logger)
        {
            this.logger = logger;
            Database    = cacheDatabase;
            PathBuilder = new HashBasedPathBuilder(options.PhysicalCacheDir, options.Subfolders,
                                                   Path.DirectorySeparatorChar, ".jpg");
            options.CleanupManagerOptions.MoveFileOverwriteFunc = options.CleanupManagerOptions.MoveFileOverwriteFunc ??
                                                                  options.AsyncCacheOptions.MoveFileOverwriteFunc;

            CleanupManager = new CleanupManager(options.CleanupManagerOptions, Database, logger, PathBuilder);
            AsyncCache     = new AsyncCache(options.AsyncCacheOptions, CleanupManager, PathBuilder, logger);
        }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="key"></param>
 /// <param name="dataProviderCallback"></param>
 /// <param name="cancellationToken"></param>
 /// <param name="retrieveContentType">When true, and using Sqlite, increases execution time by 50% or more as a database call must be made</param>
 /// <returns></returns>
 public async Task <IStreamCacheResult> GetOrCreateBytes(byte[] key, AsyncBytesResult dataProviderCallback, CancellationToken cancellationToken, bool retrieveContentType)
 {
     return(await AsyncCache.GetOrCreateBytes(key, dataProviderCallback, cancellationToken, retrieveContentType));
 }
Example #4
0
 public Task AwaitEnqueuedTasks()
 {
     return(AsyncCache.AwaitEnqueuedTasks());
 }