Пример #1
0
        public async Task RemoveAsync(string dekId)
        {
            CachedDekProperties cachedDekProperties = await this.DekPropertiesCache.RemoveAsync(dekId);

            if (cachedDekProperties != null)
            {
                this.RawDekCache.Remove(dekId);
            }
        }
Пример #2
0
        public async Task <DataEncryptionKeyProperties> GetOrAddDekPropertiesAsync(
            string dekId,
            Func <string, CosmosDiagnosticsContext, CancellationToken, Task <DataEncryptionKeyProperties> > fetcher,
            CosmosDiagnosticsContext diagnosticsContext,
            CancellationToken cancellationToken)
        {
            CachedDekProperties cachedDekProperties = await this.DekPropertiesCache.GetAsync(
                dekId,
                null,
                () => this.FetchAsync(dekId, fetcher, diagnosticsContext, cancellationToken),
                cancellationToken);

            if (cachedDekProperties.ServerPropertiesExpiryUtc <= DateTime.UtcNow)
            {
                cachedDekProperties = await this.DekPropertiesCache.GetAsync(
                    dekId,
                    null,
                    () => this.FetchAsync(dekId, fetcher, diagnosticsContext, cancellationToken),
                    cancellationToken,
                    forceRefresh : true);
            }

            return(cachedDekProperties.ServerProperties);
        }
Пример #3
0
        public void SetDekProperties(string dekId, DataEncryptionKeyProperties dekProperties)
        {
            CachedDekProperties cachedDekProperties = new CachedDekProperties(dekProperties, DateTime.UtcNow + this.dekPropertiesTimeToLive);

            this.DekPropertiesCache.Set(dekId, cachedDekProperties);
        }