コード例 #1
0
        /// <inheritdoc/>
        public async Task SetAsync(string key, byte[] value, DistributedCacheEntryOptions options, CancellationToken token = default(CancellationToken))
        {
            token.ThrowIfCancellationRequested();

            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            await this.ConnectAsync();

            await this.cosmosContainer.UpsertItemAsync(
                partitionKey : new PartitionKey(key),
                item : CosmosCache.BuildCosmosCacheSession(
                    key,
                    value,
                    options),
                requestOptions : null,
                cancellationToken : token).ConfigureAwait(false);
        }
コード例 #2
0
        /// <inheritdoc/>
        public async Task SetAsync(string key, byte[] value, DistributedCacheEntryOptions options, CancellationToken token = default(CancellationToken))
        {
            token.ThrowIfCancellationRequested();

            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            await this.ConnectAsync(token).ConfigureAwait(false);

            ItemResponse <CosmosCacheSession> setCacheSessionResponse = await this.cosmosContainer.UpsertItemAsync(
                partitionKey : new PartitionKey(key),
                item : CosmosCache.BuildCosmosCacheSession(
                    key,
                    value,
                    options,
                    this.options),
                requestOptions : new ItemRequestOptions()
            {
                EnableContentResponseOnWrite = false,
            },
                cancellationToken : token).ConfigureAwait(false);

            this.options.DiagnosticsHandler?.Invoke(setCacheSessionResponse.Diagnostics);
        }