public async Task Test_GetAsync() { var key = "thekey"; var value = "thevalue"; await _bucket.RemoveAsync(key); await _bucket.InsertAsync(key, value); var result = await _bucket.GetAsync <string>(key); Assert.AreEqual(ResponseStatus.Success, result.Status); }
public async Task Delete(T entity) { entity.DeletedDate = DateTime.Now; await _bucket.RemoveAsync(new Document <T> { Id = entity.Id.ToString(), Content = entity, }); }
public async Task DeleteEventsAsync(string actorName, ulong fromEventIndex) { var q = $"SELECT FROM `{_bucket.Name}` b WHERE b.actorName='{actorName}' AND b.eventIndex<={fromEventIndex} AND b.type='event'"; var req = QueryRequest.Create(q); req.ScanConsistency(ScanConsistency.RequestPlus); var res = await _bucket.QueryAsync <Envelope>(req); ThrowOnError(res); var envelopes = res.Rows; foreach (var envelope in envelopes) { await _bucket.RemoveAsync(envelope.Key); } }
private async Task DeleteUrlKey(string urlKey) { var documentResult = await _groupsBucket.RemoveAsync($"urlkey::{urlKey}"); if (!documentResult.Success) { throw documentResult.Exception; } }
public async Task Delete(string id) { var key = CreateKey(id); var result = await _bucket.RemoveAsync(key); if (!result.Success) { throw result.Exception; } }
public async Task DeleteStarAsync(long id) { var result = await _bucket.RemoveAsync(Star.GetKey(id)); if (!result.Success && result.Status != ResponseStatus.KeyNotFound) { // Throw an exception on a low-level error result.EnsureSuccess(); } }
/// <summary> /// Deletes a document representing a grain state object. /// </summary> /// <param name="collectionName">The type of the grain state object.</param> /// <param name="key">The grain id string.</param> /// <returns>Completion promise for this operation.</returns> public async Task Delete(string collectionName, string key, string eTag) { var docID = GetDocumentID(collectionName, key); var result = await bucket.RemoveAsync(docID, ulong.Parse(eTag)); if (!result.Success) { throw new Orleans.Storage.InconsistentStateException(result.Message, eTag, result.Cas.ToString()); } }
public bool Remove(string key, CacheRegion region) { // In case of CAS (optimistic concurrency is set) // var loaded = bucket.GetDocument<dynamic>("document_id"); // var removed = bucket.Remove(loaded); var result = bucket.RemoveAsync(key).Result; return(result.Success); }
/// <inheritdoc /> public async Task DeleteAsync(string grainTypeName, string key, string eTag) { var documentId = GetDocumentId(grainTypeName, key); var result = await bucket.RemoveAsync(documentId, ulong.Parse(eTag)); if (!result.Success) { throw new InconsistentStateException(result.Message, eTag, result.Cas.ToString()); } }
/// <summary> /// Deletes a document asynchronously. /// </summary> /// <param name="key">The key.</param> /// <returns></returns> /// <exception cref="CouchbaseException">All server responses other than Success.</exception> /// <exception cref="Exception">Any client error condition.</exception> public async Task DeleteAsync(string key) { var result = await _bucket.RemoveAsync(key); if (!result.Success) { if (result.Exception != null) { throw result.Exception; } throw new CouchbaseException(result, key); } }
/// <summary> /// Deletes a role as an asynchronous operation. /// </summary> /// <param name="role">The role.</param> /// <returns></returns> /// <exception cref="CouchbaseException"></exception> public async Task DeleteAsync(T role) { var result = await _bucket.RemoveAsync(role.Id); if (!result.Success) { if (result.Exception != null) { throw result.Exception; } throw new CouchbaseException(result, role.Id); } }
public async Task RemoveAsync(string entityId) { if (entityId == null) { throw new ArgumentNullException(nameof(entityId)); } var documentId = _context.DocumentIdFor(entityId); var result = await _bucket.RemoveAsync(documentId); result.ThrowIfFailure(); }
public async Task When_Key_Is_Touched_Expiration_Is_Extended_Async() { var key = "When_Key_Is_Touched_Expiration_Is_Extended_Async"; await _bucket.RemoveAsync(key); await _bucket.InsertAsync(key, "{value}", new TimeSpan(0, 0, 0, 2)); Thread.Sleep(3000); var result = await _bucket.GetAsync <string>(key); Assert.AreEqual(result.Status, ResponseStatus.KeyNotFound); await _bucket.RemoveAsync(key); await _bucket.InsertAsync(key, "{value}", new TimeSpan(0, 0, 0, 2)); await _bucket.TouchAsync(key, new TimeSpan(0, 0, 0, 5)); Thread.Sleep(3000); result = await _bucket.GetAsync <string>(key); Assert.AreEqual(result.Status, ResponseStatus.Success); }
/// <summary> /// Revokes all permissions the subject has given to a client. /// </summary> /// <param name="subject">The subject.</param> /// <param name="client">The client.</param> /// <returns></returns> public Task RevokeAsync(string subject, string client) { var query = from c in _context.Query <ConsentWrapper>() where c.Model.Subject == subject && c.Model.ClientId == client select c.Id; var item = query.SingleOrDefault(); if (item != null) { _bucket.RemoveAsync(item); } return(Task.FromResult(0)); }
public async Task RetrieveAndUpdateAsync() { var key = "SampleAppAsync--" + DateTime.Now.Ticks; var data = new Data { Number = 42, Text = "Life, the Universe, and Everything", Date = DateTime.UtcNow }; // Get non-existent document. // Note that it's enough to check the Status property, // We're only checking all three to show they exist. var notFound = await _bucket.GetAsync <dynamic>(key); if (!notFound.Success && notFound.Status == ResponseStatus.KeyNotFound) { Console.WriteLine("Document doesn't exist!"); } // Prepare a JSON document value await _bucket.UpsertAsync(key, data); // Get a JSON document string value var docResult = await _bucket.GetAsync <Data>(key); Console.WriteLine("Found: " + docResult.Value); // Change the data data.Number++; data.Text = "What's 7 * 6 + 1?"; data.Date = DateTime.UtcNow; // Try to insert under the same key should fail var insertResult = await _bucket.InsertAsync(key, data); if (!insertResult.Success) { Console.WriteLine("Inserting under an existing key fails as expected."); } // Replace existing document // Note this only works if the key already exists var replaceResult = await _bucket.ReplaceAsync(key, data); var res = await _bucket.RemoveAsync(key); Console.WriteLine("Got: " + res.Status); }
/// <inheritdoc/> public void Dispose() { if (_cancellationTokenSource != null) { _cancellationTokenSource.Cancel(false); _cancellationTokenSource.Dispose(); _cancellationTokenSource = null; } if (_cas == 0) { // Never locked return; } var key = LockDocument.GetKey(Name); _bucket.RemoveAsync(key, _cas) .ContinueWith(t => { if (t.IsFaulted) { _log.Warn($"Error releasing lock '{Name}' for holder '{Holder}'", t.Exception); } else if (t.Result != null) { var result = t.Result; if (result.Status == ResponseStatus.KeyNotFound) { _log.Debug("Did not release lock '{0}' for holder '{1}' because it was already released.", Name, Holder); } else if (result.Status == ResponseStatus.DocumentMutationDetected) { _log.Debug( "Did not release lock '{0}' for holder '{1}' because it was already held by another.", Name, Holder); } else if (!result.Success) { _log.Warn("Error releasing lock '{0}' for holder '{1}': {2}", Name, Holder, result.Exception?.Message ?? result.Message); } } }); }
public async Task <IActionResult> Delete([FromBody] Person person) { if (string.IsNullOrEmpty(person.Id)) { return(BadRequest("Missing or invalid 'document_id' body parameter")); } var result = await _bucket.RemoveAsync(person.Id); if (!result.Success) { return(StatusCode((int)HttpStatusCode.InternalServerError, result.Exception?.Message ?? result.Message)); } return(Ok(result)); }
public async Task <IHttpActionResult> Delete(string id) { try { var result = await _bucket.RemoveAsync(id); if (!result.Success) { return(Content(HttpStatusCode.Conflict, MessageResponse.Message(HttpStatusCode.Conflict.ToString(), "Data has not been updated."), new JsonMediaTypeFormatter())); } return(Content(HttpStatusCode.Accepted, "deleted")); } catch (Exception ex) { return(Content(HttpStatusCode.Forbidden, ex.StackTrace)); } }
/// <summary> /// Removes the data. /// </summary> /// <param name="key">The key.</param> /// <returns></returns> public Task RemoveAsync(string key) { return(_bucket.RemoveAsync(AuthorizationCodeWrapper.AuthorizationCodeId(key))); }
public Task <IOperationResult> RemoveAsync(string key) => _bucket.RemoveAsync(key);
/// <summary> /// Removes the data. /// </summary> /// <param name="key">The key.</param> /// <returns></returns> public Task RemoveAsync(string key) { return(_bucket.RemoveAsync(TokenWrapper.TokenWrapperId(key))); }
public async Task Remove(string key) { await _bucket.RemoveAsync(key); }
public async Task <bool> Delete(string id) { var result = await _bucket.RemoveAsync(id); return(result.Success); }
/// <summary> /// Removes the asynchronous. /// </summary> /// <param name="key">The key.</param> /// <returns></returns> public async Task <IOperationResult> RemoveAsync(string key) { return(await _bucket.RemoveAsync(key.ToLower())); }