Commit 34e459ec authored by Alessio Parma's avatar Alessio Parma

uploaded file cache

parent b13d1968
Pipeline #148879888 passed with stages
in 35 minutes and 30 seconds
...@@ -169,10 +169,13 @@ public TempFileDTO(string contentType, string? extension) ...@@ -169,10 +169,13 @@ public TempFileDTO(string contentType, string? extension)
ICache cache, IOptions<CacheConfiguration> cacheConfiguration, ICache cache, IOptions<CacheConfiguration> cacheConfiguration,
TempFileDTO file, CancellationToken cancellationToken) TempFileDTO file, CancellationToken cancellationToken)
{ {
using var fileStream = File.OpenRead(file.Path); string hash;
var hash = ComputeHash(fileStream); using (var fileStream = File.OpenRead(file.Path))
{
hash = ComputeHash(fileStream);
}
var cachedFile = await cache.GetOrAddTimedAsync<TempFileDTO>( var cachedFile = await cache.GetOrAddTimedAsync(
partition: nameof(TempFileDTO), partition: nameof(TempFileDTO),
key: new CacheKey(hash), key: new CacheKey(hash),
valueGetter: () => Task.FromResult(file), valueGetter: () => Task.FromResult(file),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment