protected virtual bool TryRemoveInternal(IData keyData, long timeout, TimeUnit timeunit) { var request = MapTryRemoveCodec.EncodeRequest(Name, keyData, GetThreadId(), timeunit.ToMillis(timeout)); var result = Invoke(request, keyData); var response = MapTryRemoveCodec.DecodeResponse(result).Response; return(response); }
/// <summary> /// Tries to remove an entry from the map within a timeout. /// </summary> /// <param name="keyData">A key.</param> /// <param name="timeToWait">A timeout.</param> /// <param name="cancellationToken">A cancellation token.</param> /// <returns>true if the entry was removed; otherwise false.</returns> /// <remarks> /// <para>This method returns false when no lock on the key could be /// acquired within the timeout.</para> /// TODO or when there was no value with that key? /// </remarks> protected virtual async Task <bool> TryRemoveAsync(IData keyData, TimeSpan timeToWait, CancellationToken cancellationToken) { var timeoutMs = timeToWait.CodecMilliseconds(0); var requestMessage = MapTryRemoveCodec.EncodeRequest(Name, keyData, ContextId, timeoutMs); var responseMessage = await Cluster.Messaging.SendToKeyPartitionOwnerAsync(requestMessage, keyData, cancellationToken).CAF(); var response = MapTryRemoveCodec.DecodeResponse(responseMessage).Response; return(response); }
public bool TryRemove(K key, long timeout, TimeUnit timeunit) { var keyData = ToData(key); var request = MapTryRemoveCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId(), timeunit.ToMillis(timeout)); var result = Invoke(request, keyData); var response = MapTryRemoveCodec.DecodeResponse(result).response; if (response) { InvalidateNearCacheEntry(keyData); } return(response); }