Exemplo n.º 1
0
        public TValue ReplaceInternal(IData keyData, TValue value)
        {
            var valueData     = ToData(value);
            var request       = MapReplaceCodec.EncodeRequest(Name, keyData, valueData, GetThreadId());
            var clientMessage = Invoke(request, keyData);
            var response      = MapReplaceCodec.DecodeResponse(clientMessage).Response;

            return(ToObject <TValue>(response));
        }
        private async Task <TValue> TryUpdateAsync(TKey key, TValue newValue, CancellationToken cancellationToken)
        {
            var(keyData, valueData) = ToSafeData(key, newValue);

            var requestMessage  = MapReplaceCodec.EncodeRequest(Name, keyData, valueData, ContextId);
            var responseMessage = await Cluster.Messaging.SendToKeyPartitionOwnerAsync(requestMessage, keyData, cancellationToken).CfAwait();

            var response = MapReplaceCodec.DecodeResponse(responseMessage).Response;

            return(ToObject <TValue>(response));
        }
        public V Replace(K key, V value)
        {
            var keyData   = ToData(key);
            var valueData = ToData(value);
            var request   = MapReplaceCodec.EncodeRequest(GetName(), keyData, valueData, ThreadUtil.GetThreadId());

            InvalidateNearCacheEntry(keyData);
            var clientMessage = Invoke(request, keyData);
            var response      = MapReplaceCodec.DecodeResponse(clientMessage).response;

            return(ToObject <V>(response));
        }