DocSpace-client/common/ASC.Data.Storage/Encryption/EncryptionServiceNotifier.cs

37 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using ASC.Common;
using ASC.Common.Caching;
namespace ASC.Data.Storage.Encryption
{
[Singletone]
public class EncryptionServiceNotifier
{
private ICacheNotify<ProgressEncryption> СacheBackupProgress { get; }
private ICache Cache { get; }
public EncryptionServiceNotifier(ICacheNotify<ProgressEncryption> сacheBackupProgress, ICache cache)
{
Cache = cache;
СacheBackupProgress = сacheBackupProgress;
СacheBackupProgress.Subscribe((a) =>
{
Cache.Insert(GetCacheKey(a.TenantId), a, DateTime.UtcNow.AddDays(1));
},
CacheNotifyAction.InsertOrUpdate);
}
public ProgressEncryption GetEncryptionProgress(int tenantId)
{
return Cache.Get<ProgressEncryption>(GetCacheKey(tenantId));
}
private string GetCacheKey(int tenantId)
{
return $"encryption{tenantId}";
}
}
}