コード例 #1
0
        protected virtual TValue PutInternal(IData keyData, TValue value, long ttl, TimeUnit timeunit)
        {
            var valueData     = ToData(value);
            var request       = MapPutCodec.EncodeRequest(Name, keyData, valueData, GetThreadId(), timeunit.ToMillis(ttl));
            var clientMessage = Invoke(request, keyData);
            var response      = MapPutCodec.DecodeResponse(clientMessage).Response;

            return(ToObject <TValue>(response));
        }
コード例 #2
0
        protected virtual async Task <TValue> GetAndSetAsync(IData keyData, IData valueData, TimeSpan timeToLive)
        {
            var timeToLiveMs    = timeToLive.CodecMilliseconds(-1000);
            var requestMessage  = MapPutCodec.EncodeRequest(Name, keyData, valueData, ContextId, timeToLiveMs);
            var responseMessage = await Cluster.Messaging.SendToKeyPartitionOwnerAsync(requestMessage, keyData).CAF();

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

            return(ToObject <TValue>(response));
        }
コード例 #3
0
        protected virtual Task <TValue> PutAsyncInternal(IData keyData, TValue value, long ttl, TimeUnit timeunit)
        {
            var valueData = ToData(value);
            var request   = MapPutCodec.EncodeRequest(Name, keyData, valueData, GetThreadId(), timeunit.ToMillis(ttl));

            return(InvokeAsync(request, keyData, m =>
            {
                var response = MapPutCodec.DecodeResponse(m).Response;
                return ToObject <TValue>(response);
            }));
        }
コード例 #4
0
        public V Put(K key, V value, long ttl, TimeUnit timeunit)
        {
            var keyData   = ToData(key);
            var valueData = ToData(value);
            var request   = MapPutCodec.EncodeRequest(GetName(), keyData, valueData, ThreadUtil.GetThreadId(),
                                                      timeunit.ToMillis(ttl));

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

            return(ToObject <V>(response));
        }
コード例 #5
0
        public Task <TValue> PutAsync(TKey key, TValue value, long ttl, TimeUnit timeunit)
        {
            var keyData   = ToData(key);
            var valueData = ToData(value);
            var request   = MapPutCodec.EncodeRequest(GetName(), keyData, valueData, ThreadUtil.GetThreadId(),
                                                      timeunit.ToMillis(ttl));

            InvalidateNearCacheEntry(keyData);

            return(InvokeAsync(request, keyData, m =>
            {
                var response = MapPutCodec.DecodeResponse(m).response;
                return ToObject <TValue>(response);
            }));
        }
コード例 #6
0
        protected virtual async Task <TValue> GetAndSetAsync(IData keyData, IData valueData, TimeSpan timeToLive, TimeSpan maxIdle)
        {
            var timeToLiveMs = timeToLive.RoundedMilliseconds(false); // codec: 0 is infinite, -1 is server
            var maxIdleMs    = maxIdle.RoundedMilliseconds(false);    // codec: 0 is infinite, -1 is server
            var withMaxIdle  = maxIdleMs != -1;

            var requestMessage = withMaxIdle
                ? MapPutWithMaxIdleCodec.EncodeRequest(Name, keyData, valueData, ContextId, timeToLiveMs, maxIdleMs)
                : MapPutCodec.EncodeRequest(Name, keyData, valueData, ContextId, timeToLiveMs);

            var responseMessage = await Cluster.Messaging.SendToKeyPartitionOwnerAsync(requestMessage, keyData).CfAwait();

            var response = withMaxIdle
                ? MapPutWithMaxIdleCodec.DecodeResponse(responseMessage).Response
                : MapPutCodec.DecodeResponse(responseMessage).Response;

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