public async Task SetAsync(string key, byte[] value, DistributedCacheEntryOptions options, CancellationToken token = default(CancellationToken)) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } token.ThrowIfCancellationRequested(); var creationTime = DateTimeOffset.UtcNow; var expiryDate = CassandraCacheHelper.GetAbsoluteExpiration(creationTime, options); var ttl = CassandraCacheHelper.GetExpirationInSeconds(creationTime, expiryDate); var boundStatement = this.preparedStatements[DbOperations.Insert].Bind(key, expiryDate, value, ttl).SetConsistencyLevel(this.cacheOptions.WriteConsistencyLevel); await this.cacheOptions.Session.ExecuteAsync(boundStatement); }
public void Set(string key, byte[] value, DistributedCacheEntryOptions options) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } if (options == null) { throw new ArgumentNullException(nameof(value)); } var creationTime = DateTimeOffset.UtcNow; var expiryDate = CassandraCacheHelper.GetAbsoluteExpiration(creationTime, options); var ttl = CassandraCacheHelper.GetExpirationInSeconds(creationTime, expiryDate); var boundStatement = this.preparedStatements[DbOperations.Insert].Bind(key, expiryDate, value, ttl).SetConsistencyLevel(this.cacheOptions.WriteConsistencyLevel); this.cacheOptions.Session.Execute(boundStatement); }