public TValue Put(TKey key, TValue value, long ttl, TimeUnit timeunit) { var keyData = ToData(key); var valueData = ToData(value); var request = TransactionalMapPutCodec.EncodeRequest(GetName(), GetTransactionId(), GetThreadId(), keyData, valueData, timeunit.ToMillis(ttl)); var result = Invoke(request, m => TransactionalMapPutCodec.DecodeResponse(m).response); return(ToObject <TValue>(result)); }
public async Task <TValue> GetAndSetAsync(TKey key, TValue value, TimeSpan timeToLive) { var(keyData, valueData) = ToSafeData(key, value); var timeToLiveMilliseconds = timeToLive.CodecMilliseconds(-1); var requestMessage = TransactionalMapPutCodec.EncodeRequest(Name, TransactionId, ContextId, keyData, valueData, timeToLiveMilliseconds); var responseMessage = await Cluster.Messaging.SendToMemberAsync(requestMessage, TransactionClientConnection).CAF(); var response = TransactionalMapPutCodec.DecodeResponse(responseMessage).Response; return(ToObject <TValue>(response)); }