Esempio n. 1
0
        protected virtual void SetInternal(IData keyData, TValue value, long ttl, TimeUnit timeunit)
        {
            var valueData = ToData(value);
            var request   = MapSetCodec.EncodeRequest(Name, keyData, valueData, GetThreadId(), timeunit.ToMillis(ttl));

            Invoke(request, keyData);
        }
        public void Set(K key, V value, long ttl, TimeUnit timeunit)
        {
            var keyData   = ToData(key);
            var valueData = ToData(value);
            var request   = MapSetCodec.EncodeRequest(GetName(), keyData, valueData, ThreadUtil.GetThreadId(),
                                                      timeunit.ToMillis(ttl));

            InvalidateNearCacheEntry(keyData);
            Invoke(request, keyData);
        }
        protected virtual async Task SetAsync(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
                ? MapSetWithMaxIdleCodec.EncodeRequest(Name, keyData, valueData, ContextId, timeToLiveMs, maxIdleMs)
                : MapSetCodec.EncodeRequest(Name, keyData, valueData, ContextId, timeToLiveMs);

            await Cluster.Messaging.SendToKeyPartitionOwnerAsync(requestMessage, keyData).CfAwait();
        }
Esempio n. 4
0
 protected virtual async Task SetAsync(IData keyData, IData valueData, TimeSpan timeToLive)
 {
     var timeToLiveMs   = timeToLive.CodecMilliseconds(-1000);
     var requestMessage = MapSetCodec.EncodeRequest(Name, keyData, valueData, ContextId, timeToLiveMs);
     await Cluster.Messaging.SendToKeyPartitionOwnerAsync(requestMessage, keyData).CAF();
 }